ide: dynamic allocation of device structures
Allocate device structures dynamically instead of having them embedded
in ide_hwif_t:
* Remove needless zeroing of port structure from ide_init_port_data().
* Add ide_hwif_t.devices[MAX_DRIVES] (table of pointers to the devices).
* Add ide_port_{alloc,free}_devices() helpers and use them respectively
in ide_{host,free}_alloc().
* Convert all users of ->drives[] to use ->devices[] instead.
While at it:
* Use drive->dn for the slave device check in scc_pata.c.
As a nice side-effect this patch cuts ~1kB (x86-32) from the resulting
code size:
text data bss dec hex filename
53963 1244 237 55444 d894 drivers/ide/ide-core.o.before
52981 1244 237 54462 d4be drivers/ide/ide-core.o.after
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index f89b6ec..fd155b8 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -656,7 +656,7 @@
if (on)
acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0);
for (unit = 0; unit < MAX_DRIVES; ++unit) {
- ide_drive_t *drive = &hwif->drives[unit];
+ ide_drive_t *drive = hwif->devices[unit];
if (!drive->acpidata->obj_handle)
drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive);
@@ -711,14 +711,14 @@
* for both drives, regardless whether they are connected
* or not.
*/
- hwif->drives[0].acpidata = &hwif->acpidata->master;
- hwif->drives[1].acpidata = &hwif->acpidata->slave;
+ hwif->devices[0]->acpidata = &hwif->acpidata->master;
+ hwif->devices[1]->acpidata = &hwif->acpidata->slave;
/*
* Send IDENTIFY for each drive
*/
for (i = 0; i < MAX_DRIVES; i++) {
- drive = &hwif->drives[i];
+ drive = hwif->devices[i];
memset(drive->acpidata, 0, sizeof(*drive->acpidata));
@@ -745,7 +745,7 @@
ide_acpi_push_timing(hwif);
for (i = 0; i < MAX_DRIVES; i++) {
- drive = &hwif->drives[i];
+ drive = hwif->devices[i];
if (drive->dev_flags & IDE_DFLAG_PRESENT)
/* Execute ACPI startup code */