ide: factor out devices setup from ide_acpi_init()

* Factor out devices setup from ide_acpi_init() to
  ide_acpi_port_init_devices().

* Call ide_acpi_port_init_devices() in ide_device_add_all().

While at it:
* Remove no longer needed 'drive' field from struct ide_acpi_drive_link.

There should be no functionality changes caused by this patch.
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 070ecb84
...@@ -39,7 +39,6 @@ struct GTM_buffer { ...@@ -39,7 +39,6 @@ struct GTM_buffer {
}; };
struct ide_acpi_drive_link { struct ide_acpi_drive_link {
ide_drive_t *drive;
acpi_handle obj_handle; acpi_handle obj_handle;
u8 idbuff[512]; u8 idbuff[512];
}; };
...@@ -675,11 +674,6 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on) ...@@ -675,11 +674,6 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on)
*/ */
void ide_acpi_init(ide_hwif_t *hwif) void ide_acpi_init(ide_hwif_t *hwif)
{ {
int unit;
int err;
struct ide_acpi_drive_link *master;
struct ide_acpi_drive_link *slave;
ide_acpi_blacklist(); ide_acpi_blacklist();
hwif->acpidata = kzalloc(sizeof(struct ide_acpi_hwif_link), GFP_KERNEL); hwif->acpidata = kzalloc(sizeof(struct ide_acpi_hwif_link), GFP_KERNEL);
...@@ -691,40 +685,38 @@ void ide_acpi_init(ide_hwif_t *hwif) ...@@ -691,40 +685,38 @@ void ide_acpi_init(ide_hwif_t *hwif)
DEBPRINT("no ACPI object for %s found\n", hwif->name); DEBPRINT("no ACPI object for %s found\n", hwif->name);
kfree(hwif->acpidata); kfree(hwif->acpidata);
hwif->acpidata = NULL; hwif->acpidata = NULL;
return;
} }
}
void ide_acpi_port_init_devices(ide_hwif_t *hwif)
{
ide_drive_t *drive;
int i, err;
if (hwif->acpidata == NULL)
return;
/* /*
* The ACPI spec mandates that we send information * The ACPI spec mandates that we send information
* for both drives, regardless whether they are connected * for both drives, regardless whether they are connected
* or not. * or not.
*/ */
hwif->acpidata->master.drive = &hwif->drives[0];
hwif->drives[0].acpidata = &hwif->acpidata->master; hwif->drives[0].acpidata = &hwif->acpidata->master;
master = &hwif->acpidata->master;
hwif->acpidata->slave.drive = &hwif->drives[1];
hwif->drives[1].acpidata = &hwif->acpidata->slave; hwif->drives[1].acpidata = &hwif->acpidata->slave;
slave = &hwif->acpidata->slave;
/* /*
* Send IDENTIFY for each drive * Send IDENTIFY for each drive
*/ */
if (master->drive->present) { for (i = 0; i < MAX_DRIVES; i++) {
err = taskfile_lib_get_identify(master->drive, master->idbuff); drive = &hwif->drives[i];
if (err) {
DEBPRINT("identify device %s failed (%d)\n", if (!drive->present)
master->drive->name, err); continue;
}
}
if (slave->drive->present) { err = taskfile_lib_get_identify(drive, drive->acpidata->idbuff);
err = taskfile_lib_get_identify(slave->drive, slave->idbuff); if (err)
if (err) {
DEBPRINT("identify device %s failed (%d)\n", DEBPRINT("identify device %s failed (%d)\n",
slave->drive->name, err); drive->name, err);
}
} }
if (ide_noacpionboot) { if (ide_noacpionboot) {
...@@ -740,12 +732,11 @@ void ide_acpi_init(ide_hwif_t *hwif) ...@@ -740,12 +732,11 @@ void ide_acpi_init(ide_hwif_t *hwif)
ide_acpi_get_timing(hwif); ide_acpi_get_timing(hwif);
ide_acpi_push_timing(hwif); ide_acpi_push_timing(hwif);
for (unit = 0; unit < MAX_DRIVES; ++unit) { for (i = 0; i < MAX_DRIVES; i++) {
ide_drive_t *drive = &hwif->drives[unit]; drive = &hwif->drives[i];
if (drive->present) { if (drive->present)
/* Execute ACPI startup code */ /* Execute ACPI startup code */
ide_acpi_exec_tfs(drive); ide_acpi_exec_tfs(drive);
} }
}
} }
...@@ -1430,6 +1430,7 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) ...@@ -1430,6 +1430,7 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
} }
ide_acpi_init(hwif); ide_acpi_init(hwif);
ide_acpi_port_init_devices(hwif);
} }
for (i = 0; i < MAX_HWIFS; i++) { for (i = 0; i < MAX_HWIFS; i++) {
......
...@@ -1202,12 +1202,14 @@ extern int ide_acpi_exec_tfs(ide_drive_t *drive); ...@@ -1202,12 +1202,14 @@ extern int ide_acpi_exec_tfs(ide_drive_t *drive);
extern void ide_acpi_get_timing(ide_hwif_t *hwif); extern void ide_acpi_get_timing(ide_hwif_t *hwif);
extern void ide_acpi_push_timing(ide_hwif_t *hwif); extern void ide_acpi_push_timing(ide_hwif_t *hwif);
extern void ide_acpi_init(ide_hwif_t *hwif); extern void ide_acpi_init(ide_hwif_t *hwif);
void ide_acpi_port_init_devices(ide_hwif_t *);
extern void ide_acpi_set_state(ide_hwif_t *hwif, int on); extern void ide_acpi_set_state(ide_hwif_t *hwif, int on);
#else #else
static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; } static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; }
static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; } static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; }
static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; } static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; }
static inline void ide_acpi_init(ide_hwif_t *hwif) { ; } static inline void ide_acpi_init(ide_hwif_t *hwif) { ; }
static inline void ide_acpi_port_init_devices(ide_hwif_t *hwif) { ; }
static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {} static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {}
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment