aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-acpi.c10
-rw-r--r--drivers/ide/ide-iops.c4
-rw-r--r--drivers/ide/ide-probe.c71
-rw-r--r--drivers/ide/ide-proc.c2
-rw-r--r--drivers/ide/ide.c2
-rw-r--r--drivers/ide/scc_pata.c5
6 files changed, 63 insertions, 31 deletions
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index f89b6ecf7d1a..fd155b8a256c 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -656,7 +656,7 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on)
656 if (on) 656 if (on)
657 acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0); 657 acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0);
658 for (unit = 0; unit < MAX_DRIVES; ++unit) { 658 for (unit = 0; unit < MAX_DRIVES; ++unit) {
659 ide_drive_t *drive = &hwif->drives[unit]; 659 ide_drive_t *drive = hwif->devices[unit];
660 660
661 if (!drive->acpidata->obj_handle) 661 if (!drive->acpidata->obj_handle)
662 drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive); 662 drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive);
@@ -711,14 +711,14 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
711 * for both drives, regardless whether they are connected 711 * for both drives, regardless whether they are connected
712 * or not. 712 * or not.
713 */ 713 */
714 hwif->drives[0].acpidata = &hwif->acpidata->master; 714 hwif->devices[0]->acpidata = &hwif->acpidata->master;
715 hwif->drives[1].acpidata = &hwif->acpidata->slave; 715 hwif->devices[1]->acpidata = &hwif->acpidata->slave;
716 716
717 /* 717 /*
718 * Send IDENTIFY for each drive 718 * Send IDENTIFY for each drive
719 */ 719 */
720 for (i = 0; i < MAX_DRIVES; i++) { 720 for (i = 0; i < MAX_DRIVES; i++) {
721 drive = &hwif->drives[i]; 721 drive = hwif->devices[i];
722 722
723 memset(drive->acpidata, 0, sizeof(*drive->acpidata)); 723 memset(drive->acpidata, 0, sizeof(*drive->acpidata));
724 724
@@ -745,7 +745,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
745 ide_acpi_push_timing(hwif); 745 ide_acpi_push_timing(hwif);
746 746
747 for (i = 0; i < MAX_DRIVES; i++) { 747 for (i = 0; i < MAX_DRIVES; i++) {
748 drive = &hwif->drives[i]; 748 drive = hwif->devices[i];
749 749
750 if (drive->dev_flags & IDE_DFLAG_PRESENT) 750 if (drive->dev_flags & IDE_DFLAG_PRESENT)
751 /* Execute ACPI startup code */ 751 /* Execute ACPI startup code */
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 1bcb9484f49e..26b58d15c4e6 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -1111,7 +1111,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1111 prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE); 1111 prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE);
1112 timeout = jiffies; 1112 timeout = jiffies;
1113 for (unit = 0; unit < MAX_DRIVES; unit++) { 1113 for (unit = 0; unit < MAX_DRIVES; unit++) {
1114 ide_drive_t *tdrive = &hwif->drives[unit]; 1114 ide_drive_t *tdrive = hwif->devices[unit];
1115 1115
1116 if (tdrive->dev_flags & IDE_DFLAG_PRESENT && 1116 if (tdrive->dev_flags & IDE_DFLAG_PRESENT &&
1117 tdrive->dev_flags & IDE_DFLAG_PARKED && 1117 tdrive->dev_flags & IDE_DFLAG_PARKED &&
@@ -1134,7 +1134,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1134 * for any of the drives on this interface. 1134 * for any of the drives on this interface.
1135 */ 1135 */
1136 for (unit = 0; unit < MAX_DRIVES; ++unit) 1136 for (unit = 0; unit < MAX_DRIVES; ++unit)
1137 pre_reset(&hwif->drives[unit]); 1137 pre_reset(hwif->devices[unit]);
1138 1138
1139 if (io_ports->ctl_addr == 0) { 1139 if (io_ports->ctl_addr == 0) {
1140 spin_unlock_irqrestore(&hwif->lock, flags); 1140 spin_unlock_irqrestore(&hwif->lock, flags);
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 00c7e5a67bd1..006e601cafb8 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -463,7 +463,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
463 if (ide_read_device(drive) != drive->select && present == 0) { 463 if (ide_read_device(drive) != drive->select && present == 0) {
464 if (drive->dn & 1) { 464 if (drive->dn & 1) {
465 /* exit with drive0 selected */ 465 /* exit with drive0 selected */
466 SELECT_DRIVE(&hwif->drives[0]); 466 SELECT_DRIVE(hwif->devices[0]);
467 /* allow ATA_BUSY to assert & clear */ 467 /* allow ATA_BUSY to assert & clear */
468 msleep(50); 468 msleep(50);
469 } 469 }
@@ -509,7 +509,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
509 } 509 }
510 if (drive->dn & 1) { 510 if (drive->dn & 1) {
511 /* exit with drive0 selected */ 511 /* exit with drive0 selected */
512 SELECT_DRIVE(&hwif->drives[0]); 512 SELECT_DRIVE(hwif->devices[0]);
513 msleep(50); 513 msleep(50);
514 /* ensure drive irq is clear */ 514 /* ensure drive irq is clear */
515 (void)tp_ops->read_status(hwif); 515 (void)tp_ops->read_status(hwif);
@@ -715,7 +715,7 @@ static int ide_port_wait_ready(ide_hwif_t *hwif)
715 715
716 /* Now make sure both master & slave are ready */ 716 /* Now make sure both master & slave are ready */
717 for (unit = 0; unit < MAX_DRIVES; unit++) { 717 for (unit = 0; unit < MAX_DRIVES; unit++) {
718 ide_drive_t *drive = &hwif->drives[unit]; 718 ide_drive_t *drive = hwif->devices[unit];
719 719
720 /* Ignore disks that we will not probe for later. */ 720 /* Ignore disks that we will not probe for later. */
721 if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0 || 721 if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0 ||
@@ -733,7 +733,7 @@ static int ide_port_wait_ready(ide_hwif_t *hwif)
733out: 733out:
734 /* Exit function with master reselected (let's be sane) */ 734 /* Exit function with master reselected (let's be sane) */
735 if (unit) 735 if (unit)
736 SELECT_DRIVE(&hwif->drives[0]); 736 SELECT_DRIVE(hwif->devices[0]);
737 737
738 return rc; 738 return rc;
739} 739}
@@ -749,7 +749,7 @@ out:
749 749
750void ide_undecoded_slave(ide_drive_t *dev1) 750void ide_undecoded_slave(ide_drive_t *dev1)
751{ 751{
752 ide_drive_t *dev0 = &dev1->hwif->drives[0]; 752 ide_drive_t *dev0 = dev1->hwif->devices[0];
753 753
754 if ((dev1->dn & 1) == 0 || (dev0->dev_flags & IDE_DFLAG_PRESENT) == 0) 754 if ((dev1->dn & 1) == 0 || (dev0->dev_flags & IDE_DFLAG_PRESENT) == 0)
755 return; 755 return;
@@ -784,8 +784,8 @@ static int ide_probe_port(ide_hwif_t *hwif)
784 784
785 BUG_ON(hwif->present); 785 BUG_ON(hwif->present);
786 786
787 if ((hwif->drives[0].dev_flags & IDE_DFLAG_NOPROBE) && 787 if ((hwif->devices[0]->dev_flags & IDE_DFLAG_NOPROBE) &&
788 (hwif->drives[1].dev_flags & IDE_DFLAG_NOPROBE)) 788 (hwif->devices[1]->dev_flags & IDE_DFLAG_NOPROBE))
789 return -EACCES; 789 return -EACCES;
790 790
791 /* 791 /*
@@ -807,7 +807,7 @@ static int ide_probe_port(ide_hwif_t *hwif)
807 * but a lot of cdrom drives are configured as single slaves. 807 * but a lot of cdrom drives are configured as single slaves.
808 */ 808 */
809 for (unit = 0; unit < MAX_DRIVES; ++unit) { 809 for (unit = 0; unit < MAX_DRIVES; ++unit) {
810 ide_drive_t *drive = &hwif->drives[unit]; 810 ide_drive_t *drive = hwif->devices[unit];
811 811
812 (void) probe_for_drive(drive); 812 (void) probe_for_drive(drive);
813 if (drive->dev_flags & IDE_DFLAG_PRESENT) 813 if (drive->dev_flags & IDE_DFLAG_PRESENT)
@@ -832,7 +832,7 @@ static void ide_port_tune_devices(ide_hwif_t *hwif)
832 int unit; 832 int unit;
833 833
834 for (unit = 0; unit < MAX_DRIVES; unit++) { 834 for (unit = 0; unit < MAX_DRIVES; unit++) {
835 ide_drive_t *drive = &hwif->drives[unit]; 835 ide_drive_t *drive = hwif->devices[unit];
836 836
837 if (drive->dev_flags & IDE_DFLAG_PRESENT) { 837 if (drive->dev_flags & IDE_DFLAG_PRESENT) {
838 if (port_ops && port_ops->quirkproc) 838 if (port_ops && port_ops->quirkproc)
@@ -841,7 +841,7 @@ static void ide_port_tune_devices(ide_hwif_t *hwif)
841 } 841 }
842 842
843 for (unit = 0; unit < MAX_DRIVES; ++unit) { 843 for (unit = 0; unit < MAX_DRIVES; ++unit) {
844 ide_drive_t *drive = &hwif->drives[unit]; 844 ide_drive_t *drive = hwif->devices[unit];
845 845
846 if (drive->dev_flags & IDE_DFLAG_PRESENT) { 846 if (drive->dev_flags & IDE_DFLAG_PRESENT) {
847 ide_set_max_pio(drive); 847 ide_set_max_pio(drive);
@@ -854,7 +854,7 @@ static void ide_port_tune_devices(ide_hwif_t *hwif)
854 } 854 }
855 855
856 for (unit = 0; unit < MAX_DRIVES; ++unit) { 856 for (unit = 0; unit < MAX_DRIVES; ++unit) {
857 ide_drive_t *drive = &hwif->drives[unit]; 857 ide_drive_t *drive = hwif->devices[unit];
858 858
859 if ((hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) || 859 if ((hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) ||
860 drive->id[ATA_ID_DWORD_IO]) 860 drive->id[ATA_ID_DWORD_IO])
@@ -931,7 +931,7 @@ static int ide_port_setup_devices(ide_hwif_t *hwif)
931 931
932 mutex_lock(&ide_cfg_mtx); 932 mutex_lock(&ide_cfg_mtx);
933 for (i = 0; i < MAX_DRIVES; i++) { 933 for (i = 0; i < MAX_DRIVES; i++) {
934 ide_drive_t *drive = &hwif->drives[i]; 934 ide_drive_t *drive = hwif->devices[i];
935 935
936 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 936 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
937 continue; 937 continue;
@@ -1017,7 +1017,7 @@ static struct kobject *ata_probe(dev_t dev, int *part, void *data)
1017{ 1017{
1018 ide_hwif_t *hwif = data; 1018 ide_hwif_t *hwif = data;
1019 int unit = *part >> PARTN_BITS; 1019 int unit = *part >> PARTN_BITS;
1020 ide_drive_t *drive = &hwif->drives[unit]; 1020 ide_drive_t *drive = hwif->devices[unit];
1021 1021
1022 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 1022 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
1023 return NULL; 1023 return NULL;
@@ -1164,7 +1164,7 @@ static void hwif_register_devices(ide_hwif_t *hwif)
1164 unsigned int i; 1164 unsigned int i;
1165 1165
1166 for (i = 0; i < MAX_DRIVES; i++) { 1166 for (i = 0; i < MAX_DRIVES; i++) {
1167 ide_drive_t *drive = &hwif->drives[i]; 1167 ide_drive_t *drive = hwif->devices[i];
1168 struct device *dev = &drive->gendev; 1168 struct device *dev = &drive->gendev;
1169 int ret; 1169 int ret;
1170 1170
@@ -1190,7 +1190,7 @@ static void ide_port_init_devices(ide_hwif_t *hwif)
1190 int i; 1190 int i;
1191 1191
1192 for (i = 0; i < MAX_DRIVES; i++) { 1192 for (i = 0; i < MAX_DRIVES; i++) {
1193 ide_drive_t *drive = &hwif->drives[i]; 1193 ide_drive_t *drive = hwif->devices[i];
1194 1194
1195 drive->dn = i + hwif->channel * 2; 1195 drive->dn = i + hwif->channel * 2;
1196 1196
@@ -1285,7 +1285,7 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif)
1285 int unit; 1285 int unit;
1286 1286
1287 for (unit = 0; unit < MAX_DRIVES; ++unit) { 1287 for (unit = 0; unit < MAX_DRIVES; ++unit) {
1288 ide_drive_t *drive = &hwif->drives[unit]; 1288 ide_drive_t *drive = hwif->devices[unit];
1289 u8 j = (hwif->index * MAX_DRIVES) + unit; 1289 u8 j = (hwif->index * MAX_DRIVES) + unit;
1290 1290
1291 memset(drive, 0, sizeof(*drive)); 1291 memset(drive, 0, sizeof(*drive));
@@ -1309,9 +1309,6 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif)
1309 1309
1310static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index) 1310static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
1311{ 1311{
1312 /* bulk initialize hwif & drive info with zeros */
1313 memset(hwif, 0, sizeof(ide_hwif_t));
1314
1315 /* fill in any non-zero initial values */ 1312 /* fill in any non-zero initial values */
1316 hwif->index = index; 1313 hwif->index = index;
1317 hwif->major = ide_hwif_to_major[index]; 1314 hwif->major = ide_hwif_to_major[index];
@@ -1388,6 +1385,34 @@ static void ide_free_port_slot(int idx)
1388 mutex_unlock(&ide_cfg_mtx); 1385 mutex_unlock(&ide_cfg_mtx);
1389} 1386}
1390 1387
1388static void ide_port_free_devices(ide_hwif_t *hwif)
1389{
1390 int i;
1391
1392 for (i = 0; i < MAX_DRIVES; i++)
1393 kfree(hwif->devices[i]);
1394}
1395
1396static int ide_port_alloc_devices(ide_hwif_t *hwif, int node)
1397{
1398 int i;
1399
1400 for (i = 0; i < MAX_DRIVES; i++) {
1401 ide_drive_t *drive;
1402
1403 drive = kzalloc_node(sizeof(*drive), GFP_KERNEL, node);
1404 if (drive == NULL)
1405 goto out_nomem;
1406
1407 hwif->devices[i] = drive;
1408 }
1409 return 0;
1410
1411out_nomem:
1412 ide_port_free_devices(hwif);
1413 return -ENOMEM;
1414}
1415
1391struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) 1416struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws)
1392{ 1417{
1393 struct ide_host *host; 1418 struct ide_host *host;
@@ -1410,6 +1435,11 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws)
1410 if (hwif == NULL) 1435 if (hwif == NULL)
1411 continue; 1436 continue;
1412 1437
1438 if (ide_port_alloc_devices(hwif, node) < 0) {
1439 kfree(hwif);
1440 continue;
1441 }
1442
1413 idx = ide_find_port_slot(d); 1443 idx = ide_find_port_slot(d);
1414 if (idx < 0) { 1444 if (idx < 0) {
1415 printk(KERN_ERR "%s: no free slot for interface\n", 1445 printk(KERN_ERR "%s: no free slot for interface\n",
@@ -1575,7 +1605,7 @@ static void __ide_port_unregister_devices(ide_hwif_t *hwif)
1575 int i; 1605 int i;
1576 1606
1577 for (i = 0; i < MAX_DRIVES; i++) { 1607 for (i = 0; i < MAX_DRIVES; i++) {
1578 ide_drive_t *drive = &hwif->drives[i]; 1608 ide_drive_t *drive = hwif->devices[i];
1579 1609
1580 if (drive->dev_flags & IDE_DFLAG_PRESENT) { 1610 if (drive->dev_flags & IDE_DFLAG_PRESENT) {
1581 device_unregister(&drive->gendev); 1611 device_unregister(&drive->gendev);
@@ -1651,6 +1681,7 @@ void ide_host_free(struct ide_host *host)
1651 if (hwif == NULL) 1681 if (hwif == NULL)
1652 continue; 1682 continue;
1653 1683
1684 ide_port_free_devices(hwif);
1654 ide_free_port_slot(hwif->index); 1685 ide_free_port_slot(hwif->index);
1655 kfree(hwif); 1686 kfree(hwif);
1656 } 1687 }
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index d985a9ec6bef..1dc827fa7061 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -599,7 +599,7 @@ void ide_proc_port_register_devices(ide_hwif_t *hwif)
599 char name[64]; 599 char name[64];
600 600
601 for (d = 0; d < MAX_DRIVES; d++) { 601 for (d = 0; d < MAX_DRIVES; d++) {
602 ide_drive_t *drive = &hwif->drives[d]; 602 ide_drive_t *drive = hwif->devices[d];
603 603
604 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0 || drive->proc) 604 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0 || drive->proc)
605 continue; 605 continue;
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 6971c285a212..8a6f893d127e 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -497,7 +497,7 @@ void ide_port_apply_params(ide_hwif_t *hwif)
497 } 497 }
498 498
499 for (i = 0; i < MAX_DRIVES; i++) 499 for (i = 0; i < MAX_DRIVES; i++)
500 ide_dev_apply_params(&hwif->drives[i], i); 500 ide_dev_apply_params(hwif->devices[i], i);
501} 501}
502 502
503/* 503/*
diff --git a/drivers/ide/scc_pata.c b/drivers/ide/scc_pata.c
index 90574ab76345..841164d7d3b9 100644
--- a/drivers/ide/scc_pata.c
+++ b/drivers/ide/scc_pata.c
@@ -259,7 +259,7 @@ static void scc_set_dma_mode(ide_drive_t *drive, const u8 speed)
259 unsigned long scrcst_port = ctl_base + 0x014; 259 unsigned long scrcst_port = ctl_base + 0x014;
260 unsigned long udenvt_port = ctl_base + 0x018; 260 unsigned long udenvt_port = ctl_base + 0x018;
261 unsigned long tdvhsel_port = ctl_base + 0x020; 261 unsigned long tdvhsel_port = ctl_base + 0x020;
262 int is_slave = (&hwif->drives[1] == drive); 262 int is_slave = drive->dn & 1;
263 int offset, idx; 263 int offset, idx;
264 unsigned long reg; 264 unsigned long reg;
265 unsigned long jcactsel; 265 unsigned long jcactsel;
@@ -413,7 +413,8 @@ static int scc_dma_end(ide_drive_t *drive)
413 if (rq) 413 if (rq)
414 rq->errors |= ERROR_RESET; 414 rq->errors |= ERROR_RESET;
415 for (unit = 0; unit < MAX_DRIVES; unit++) { 415 for (unit = 0; unit < MAX_DRIVES; unit++) {
416 ide_drive_t *drive = &hwif->drives[unit]; 416 ide_drive_t *drive = hwif->devices[unit];
417
417 drive->crc_count++; 418 drive->crc_count++;
418 } 419 }
419 } 420 }