clps711xfb: convert to proc_fops
[safe/jmp/linux-2.6] / drivers / ide / ide-acpi.c
index ce5b213..c0cf45a 100644 (file)
@@ -20,9 +20,6 @@
 #include <acpi/acpi_bus.h>
 
 #define REGS_PER_GTF           7
-struct taskfile_array {
-       u8      tfa[REGS_PER_GTF];      /* regs. 0x1f1 - 0x1f7 */
-};
 
 struct GTM_buffer {
        u32     PIO_speed0;
@@ -95,6 +92,11 @@ int ide_acpi_init(void)
        return 0;
 }
 
+bool ide_port_acpi(ide_hwif_t *hwif)
+{
+       return ide_noacpi == 0 && hwif->acpidata;
+}
+
 /**
  * ide_get_dev_handle - finds acpi_handle and PCI device.function
  * @dev: device to locate
@@ -112,8 +114,6 @@ static int ide_get_dev_handle(struct device *dev, acpi_handle *handle,
        unsigned int bus, devnum, func;
        acpi_integer addr;
        acpi_handle dev_handle;
-       struct acpi_buffer buffer = {.length = ACPI_ALLOCATE_BUFFER,
-                                       .pointer = NULL};
        acpi_status status;
        struct acpi_device_info *dinfo = NULL;
        int ret = -ENODEV;
@@ -132,12 +132,11 @@ static int ide_get_dev_handle(struct device *dev, acpi_handle *handle,
                goto err;
        }
 
-       status = acpi_get_object_info(dev_handle, &buffer);
+       status = acpi_get_object_info(dev_handle, &dinfo);
        if (ACPI_FAILURE(status)) {
                DEBPRINT("get_object_info for device failed\n");
                goto err;
        }
-       dinfo = buffer.pointer;
        if (dinfo && (dinfo->valid & ACPI_VALID_ADR) &&
            dinfo->address == addr) {
                *pcidevfn = addr;
@@ -285,43 +284,6 @@ out:
 }
 
 /**
- * taskfile_load_raw - send taskfile registers to drive
- * @drive: drive to which output is sent
- * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7)
- *
- * Outputs IDE taskfile to the drive.
- */
-static int taskfile_load_raw(ide_drive_t *drive,
-                             const struct taskfile_array *gtf)
-{
-       ide_task_t args;
-       int err = 0;
-
-       DEBPRINT("(0x1f1-1f7): hex: "
-              "%02x %02x %02x %02x %02x %02x %02x\n",
-              gtf->tfa[0], gtf->tfa[1], gtf->tfa[2],
-              gtf->tfa[3], gtf->tfa[4], gtf->tfa[5], gtf->tfa[6]);
-
-       memset(&args, 0, sizeof(ide_task_t));
-
-       /* convert gtf to IDE Taskfile */
-       memcpy(&args.tf_array[7], &gtf->tfa, 7);
-       args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
-
-       if (!ide_acpigtf) {
-               DEBPRINT("_GTF execution disabled\n");
-               return err;
-       }
-
-       err = ide_no_data_taskfile(drive, &args);
-       if (err)
-               printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n",
-                      __func__, err);
-
-       return err;
-}
-
-/**
  * do_drive_set_taskfiles - write the drive taskfile settings from _GTF
  * @drive: the drive to which the taskfile command should be sent
  * @gtf_length: total number of bytes of _GTF taskfiles
@@ -337,19 +299,37 @@ static int do_drive_set_taskfiles(ide_drive_t *drive,
        int                     rc = 0, err;
        int                     gtf_count = gtf_length / REGS_PER_GTF;
        int                     ix;
-       struct taskfile_array   *gtf;
 
        DEBPRINT("total GTF bytes=%u (0x%x), gtf_count=%d, addr=0x%lx\n",
                 gtf_length, gtf_length, gtf_count, gtf_address);
 
+       /* send all taskfile registers (0x1f1-0x1f7) *in*that*order* */
        for (ix = 0; ix < gtf_count; ix++) {
-               gtf = (struct taskfile_array *)
-                       (gtf_address + ix * REGS_PER_GTF);
-
-               /* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */
-               err = taskfile_load_raw(drive, gtf);
-               if (err)
+               u8 *gtf = (u8 *)(gtf_address + ix * REGS_PER_GTF);
+               struct ide_cmd cmd;
+
+               DEBPRINT("(0x1f1-1f7): "
+                        "hex: %02x %02x %02x %02x %02x %02x %02x\n",
+                        gtf[0], gtf[1], gtf[2],
+                        gtf[3], gtf[4], gtf[5], gtf[6]);
+
+               if (!ide_acpigtf) {
+                       DEBPRINT("_GTF execution disabled\n");
+                       continue;
+               }
+
+               /* convert GTF to taskfile */
+               memset(&cmd, 0, sizeof(cmd));
+               memcpy(&cmd.tf.feature, gtf, REGS_PER_GTF);
+               cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
+               cmd.valid.in.tf  = IDE_VALID_IN_TF  | IDE_VALID_DEVICE;
+
+               err = ide_no_data_taskfile(drive, &cmd);
+               if (err) {
+                       printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n",
+                                       __func__, err);
                        rc = err;
+               }
        }
 
        return rc;
@@ -374,9 +354,6 @@ int ide_acpi_exec_tfs(ide_drive_t *drive)
        unsigned long   gtf_address;
        unsigned long   obj_loc;
 
-       if (ide_noacpi)
-               return 0;
-
        DEBPRINT("call get_GTF, drive=%s port=%d\n", drive->name, drive->dn);
 
        ret = do_drive_get_GTF(drive, &gtf_length, &gtf_address, &obj_loc);
@@ -411,16 +388,6 @@ void ide_acpi_get_timing(ide_hwif_t *hwif)
        struct acpi_buffer      output;
        union acpi_object       *out_obj;
 
-       if (ide_noacpi)
-               return;
-
-       DEBPRINT("ENTER:\n");
-
-       if (!hwif->acpidata) {
-               DEBPRINT("no ACPI data for %s\n", hwif->name);
-               return;
-       }
-
        /* Setting up output buffer for _GTM */
        output.length = ACPI_ALLOCATE_BUFFER;
        output.pointer = NULL;  /* ACPI-CA sets this; save/free it later */
@@ -501,16 +468,6 @@ void ide_acpi_push_timing(ide_hwif_t *hwif)
        struct ide_acpi_drive_link      *master = &hwif->acpidata->master;
        struct ide_acpi_drive_link      *slave = &hwif->acpidata->slave;
 
-       if (ide_noacpi)
-               return;
-
-       DEBPRINT("ENTER:\n");
-
-       if (!hwif->acpidata) {
-               DEBPRINT("no ACPI data for %s\n", hwif->name);
-               return;
-       }
-
        /* Give the GTM buffer + drive Identify data to the channel via the
         * _STM method: */
        /* setup input parameters buffer for _STM */
@@ -549,16 +506,11 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on)
        ide_drive_t *drive;
        int i;
 
-       if (ide_noacpi || ide_noacpi_psx)
+       if (ide_noacpi_psx)
                return;
 
        DEBPRINT("ENTER:\n");
 
-       if (!hwif->acpidata) {
-               DEBPRINT("no ACPI data for %s\n", hwif->name);
-               return;
-       }
-
        /* channel first and then drives for power on and verse versa for power off */
        if (on)
                acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0);
@@ -638,7 +590,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
                                 drive->name, err);
        }
 
-       if (!ide_acpionboot) {
+       if (ide_noacpi || ide_acpionboot == 0) {
                DEBPRINT("ACPI methods disabled on boot\n");
                return;
        }