]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide-acpi.c
ide: sanitize ACPI initialization
[linux-2.6-omap-h63xx.git] / drivers / ide / ide-acpi.c
index d8f295bdad766c560200065acdf263ac53a77caf..ba5932d7b1bb37a7cdbac0dc041d8d1c68efb4dc 100644 (file)
@@ -89,12 +89,8 @@ static const struct dmi_system_id ide_acpi_dmi_table[] = {
        { }     /* terminate list */
 };
 
-static int ide_acpi_blacklist(void)
+int ide_acpi_init(void)
 {
-       static int done;
-       if (done)
-               return 0;
-       done = 1;
        dmi_check_system(ide_acpi_dmi_table);
        return 0;
 }
@@ -201,40 +197,6 @@ static acpi_handle ide_acpi_hwif_get_handle(ide_hwif_t *hwif)
        return chan_handle;
 }
 
-/**
- * ide_acpi_drive_get_handle - Get ACPI object handle for a given drive
- * @drive: device to locate
- *
- * Retrieves the object handle of a given drive. According to the ACPI
- * spec the drive is a child of the hwif.
- *
- * Returns handle on success, 0 on error.
- */
-static acpi_handle ide_acpi_drive_get_handle(ide_drive_t *drive)
-{
-       ide_hwif_t      *hwif = drive->hwif;
-       int              port;
-       acpi_handle      drive_handle;
-
-       if (!hwif->acpidata)
-               return NULL;
-
-       if (!hwif->acpidata->obj_handle)
-               return NULL;
-
-       port = hwif->channel ? drive->dn - 2: drive->dn;
-
-       DEBPRINT("ENTER: %s at channel#: %d port#: %d\n",
-                drive->name, hwif->channel, port);
-
-
-       /* TBD: could also check ACPI object VALID bits */
-       drive_handle = acpi_get_child(hwif->acpidata->obj_handle, port);
-       DEBPRINT("drive %s handle 0x%p\n", drive->name, drive_handle);
-
-       return drive_handle;
-}
-
 /**
  * do_drive_get_GTF - get the drive bootup default taskfile settings
  * @drive: the drive for which the taskfile settings should be retrieved
@@ -282,7 +244,7 @@ static int do_drive_get_GTF(ide_drive_t *drive,
        port = hwif->channel ? drive->dn - 2: drive->dn;
 
        DEBPRINT("ENTER: %s at %s, port#: %d, hard_port#: %d\n",
-                hwif->name, dev->bus_id, port, hwif->channel);
+                hwif->name, dev_name(dev), port, hwif->channel);
 
        if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) {
                DEBPRINT("%s drive %d:%d not present\n",
@@ -290,14 +252,9 @@ static int do_drive_get_GTF(ide_drive_t *drive,
                goto out;
        }
 
-       /* Get this drive's _ADR info. if not already known. */
        if (!drive->acpidata->obj_handle) {
-               drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive);
-               if (!drive->acpidata->obj_handle) {
-                       DEBPRINT("No ACPI object found for %s\n",
-                                drive->name);
-                       goto out;
-               }
+               DEBPRINT("No ACPI object found for %s\n", drive->name);
+               goto out;
        }
 
        /* Setting up output buffer */
@@ -647,26 +604,23 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on)
                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);
 
-       ide_port_for_each_dev(i, drive, hwif) {
-               if (!drive->acpidata->obj_handle)
-                       drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive);
-
-               if (drive->acpidata->obj_handle &&
-                   (drive->dev_flags & IDE_DFLAG_PRESENT)) {
+       ide_port_for_each_present_dev(i, drive, hwif) {
+               if (drive->acpidata->obj_handle)
                        acpi_bus_set_power(drive->acpidata->obj_handle,
-                               on? ACPI_STATE_D0: ACPI_STATE_D3);
-               }
+                                          on ? ACPI_STATE_D0 : ACPI_STATE_D3);
        }
+
        if (!on)
                acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D3);
 }
 
 /**
- * ide_acpi_init - initialize the ACPI link for an IDE interface
+ * ide_acpi_init_port - initialize the ACPI link for an IDE interface
  * @hwif: target IDE interface (channel)
  *
  * The ACPI spec is not quite clear when the drive identify buffer
@@ -676,10 +630,8 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on)
  * So we get the information during startup; but this means that
  * any changes during run-time will be lost after resume.
  */
-void ide_acpi_init(ide_hwif_t *hwif)
+void ide_acpi_init_port(ide_hwif_t *hwif)
 {
-       ide_acpi_blacklist();
-
        hwif->acpidata = kzalloc(sizeof(struct ide_acpi_hwif_link), GFP_KERNEL);
        if (!hwif->acpidata)
                return;
@@ -708,15 +660,24 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
        hwif->devices[0]->acpidata = &hwif->acpidata->master;
        hwif->devices[1]->acpidata = &hwif->acpidata->slave;
 
-       /*
-        * Send IDENTIFY for each drive
-        */
-       ide_port_for_each_dev(i, drive, hwif) {
-               memset(drive->acpidata, 0, sizeof(*drive->acpidata));
+       /* get _ADR info for each device */
+       ide_port_for_each_present_dev(i, drive, hwif) {
+               acpi_handle dev_handle;
+
+               DEBPRINT("ENTER: %s at channel#: %d port#: %d\n",
+                        drive->name, hwif->channel, drive->dn & 1);
 
-               if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
-                       continue;
+               /* TBD: could also check ACPI object VALID bits */
+               dev_handle = acpi_get_child(hwif->acpidata->obj_handle,
+                                           drive->dn & 1);
+
+               DEBPRINT("drive %s handle 0x%p\n", drive->name, dev_handle);
+
+               drive->acpidata->obj_handle = dev_handle;
+       }
 
+       /* send IDENTIFY for each device */
+       ide_port_for_each_present_dev(i, drive, hwif) {
                err = taskfile_lib_get_identify(drive, drive->acpidata->idbuff);
                if (err)
                        DEBPRINT("identify device %s failed (%d)\n",
@@ -736,9 +697,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
        ide_acpi_get_timing(hwif);
        ide_acpi_push_timing(hwif);
 
-       ide_port_for_each_dev(i, drive, hwif) {
-               if (drive->dev_flags & IDE_DFLAG_PRESENT)
-                       /* Execute ACPI startup code */
-                       ide_acpi_exec_tfs(drive);
+       ide_port_for_each_present_dev(i, drive, hwif) {
+               ide_acpi_exec_tfs(drive);
        }
 }