diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-12 12:29:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-12 12:29:42 -0400 |
commit | d614aec4752f8c61b2e7cb77806b6bd59aa50836 (patch) | |
tree | 3b0cfb3085c43415931dbf18666d582fb8ae3c75 /drivers/ide/ide-probe.c | |
parent | db8e7f10ed67933ca272f4030eb7057b7f13de07 (diff) | |
parent | ad7c52d0988a8965989dc06d630c52a5bde849d5 (diff) |
Merge branch 'for-2.6.31' of git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
* 'for-2.6.31' of git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (29 commits)
ide: re-implement ide_pci_init_one() on top of ide_pci_init_two()
ide: unexport ide_find_dma_mode()
ide: fix PowerMac bootup oops
ide: skip probe if there are no devices on the port (v2)
sl82c105: add printk() logging facility
ide-tape: fix proc warning
ide: add IDE_DFLAG_NIEN_QUIRK device flag
ide: respect quirk_drives[] list on all controllers
hpt366: enable all quirks for devices on quirk_drives[] list
hpt366: sync quirk_drives[] list with pdc202xx_{new,old}.c
ide: remove superfluous SELECT_MASK() call from do_rw_taskfile()
ide: remove superfluous SELECT_MASK() call from ide_driveid_update()
icside: remove superfluous ->maskproc method
ide-tape: fix IDE_AFLAG_* atomic accesses
ide-tape: change IDE_AFLAG_IGNORE_DSC non-atomically
pdc202xx_old: kill resetproc() method
pdc202xx_old: don't call pdc202xx_reset() on IRQ timeout
pdc202xx_old: use ide_dma_test_irq()
ide: preserve Host Protected Area by default (v2)
ide-gd: implement block device ->set_capacity method (v2)
...
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r-- | drivers/ide/ide-probe.c | 95 |
1 files changed, 53 insertions, 42 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index c895ed52b2e8..f371b0de314f 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -97,7 +97,7 @@ static void ide_disk_init_mult_count(ide_drive_t *drive) | |||
97 | drive->mult_req = id[ATA_ID_MULTSECT] & 0xff; | 97 | drive->mult_req = id[ATA_ID_MULTSECT] & 0xff; |
98 | 98 | ||
99 | if (drive->mult_req) | 99 | if (drive->mult_req) |
100 | drive->special.b.set_multmode = 1; | 100 | drive->special_flags |= IDE_SFLAG_SET_MULTMODE; |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
@@ -465,23 +465,8 @@ static u8 probe_for_drive(ide_drive_t *drive) | |||
465 | int rc; | 465 | int rc; |
466 | u8 cmd; | 466 | u8 cmd; |
467 | 467 | ||
468 | /* | ||
469 | * In order to keep things simple we have an id | ||
470 | * block for all drives at all times. If the device | ||
471 | * is pre ATA or refuses ATA/ATAPI identify we | ||
472 | * will add faked data to this. | ||
473 | * | ||
474 | * Also note that 0 everywhere means "can't do X" | ||
475 | */ | ||
476 | |||
477 | drive->dev_flags &= ~IDE_DFLAG_ID_READ; | 468 | drive->dev_flags &= ~IDE_DFLAG_ID_READ; |
478 | 469 | ||
479 | drive->id = kzalloc(SECTOR_SIZE, GFP_KERNEL); | ||
480 | if (drive->id == NULL) { | ||
481 | printk(KERN_ERR "ide: out of memory for id data.\n"); | ||
482 | return 0; | ||
483 | } | ||
484 | |||
485 | m = (char *)&drive->id[ATA_ID_PROD]; | 470 | m = (char *)&drive->id[ATA_ID_PROD]; |
486 | strcpy(m, "UNKNOWN"); | 471 | strcpy(m, "UNKNOWN"); |
487 | 472 | ||
@@ -497,7 +482,7 @@ static u8 probe_for_drive(ide_drive_t *drive) | |||
497 | } | 482 | } |
498 | 483 | ||
499 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) | 484 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) |
500 | goto out_free; | 485 | return 0; |
501 | 486 | ||
502 | /* identification failed? */ | 487 | /* identification failed? */ |
503 | if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { | 488 | if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { |
@@ -521,7 +506,7 @@ static u8 probe_for_drive(ide_drive_t *drive) | |||
521 | } | 506 | } |
522 | 507 | ||
523 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) | 508 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) |
524 | goto out_free; | 509 | return 0; |
525 | 510 | ||
526 | /* The drive wasn't being helpful. Add generic info only */ | 511 | /* The drive wasn't being helpful. Add generic info only */ |
527 | if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { | 512 | if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { |
@@ -535,9 +520,6 @@ static u8 probe_for_drive(ide_drive_t *drive) | |||
535 | } | 520 | } |
536 | 521 | ||
537 | return 1; | 522 | return 1; |
538 | out_free: | ||
539 | kfree(drive->id); | ||
540 | return 0; | ||
541 | } | 523 | } |
542 | 524 | ||
543 | static void hwif_release_dev(struct device *dev) | 525 | static void hwif_release_dev(struct device *dev) |
@@ -702,8 +684,14 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
702 | if (irqd) | 684 | if (irqd) |
703 | disable_irq(hwif->irq); | 685 | disable_irq(hwif->irq); |
704 | 686 | ||
705 | if (ide_port_wait_ready(hwif) == -EBUSY) | 687 | rc = ide_port_wait_ready(hwif); |
706 | printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); | 688 | if (rc == -ENODEV) { |
689 | printk(KERN_INFO "%s: no devices on the port\n", hwif->name); | ||
690 | goto out; | ||
691 | } else if (rc == -EBUSY) | ||
692 | printk(KERN_ERR "%s: not ready before the probe\n", hwif->name); | ||
693 | else | ||
694 | rc = -ENODEV; | ||
707 | 695 | ||
708 | /* | 696 | /* |
709 | * Second drive should only exist if first drive was found, | 697 | * Second drive should only exist if first drive was found, |
@@ -714,7 +702,7 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
714 | if (drive->dev_flags & IDE_DFLAG_PRESENT) | 702 | if (drive->dev_flags & IDE_DFLAG_PRESENT) |
715 | rc = 0; | 703 | rc = 0; |
716 | } | 704 | } |
717 | 705 | out: | |
718 | /* | 706 | /* |
719 | * Use cached IRQ number. It might be (and is...) changed by probe | 707 | * Use cached IRQ number. It might be (and is...) changed by probe |
720 | * code above | 708 | * code above |
@@ -732,6 +720,8 @@ static void ide_port_tune_devices(ide_hwif_t *hwif) | |||
732 | int i; | 720 | int i; |
733 | 721 | ||
734 | ide_port_for_each_present_dev(i, drive, hwif) { | 722 | ide_port_for_each_present_dev(i, drive, hwif) { |
723 | ide_check_nien_quirk_list(drive); | ||
724 | |||
735 | if (port_ops && port_ops->quirkproc) | 725 | if (port_ops && port_ops->quirkproc) |
736 | port_ops->quirkproc(drive); | 726 | port_ops->quirkproc(drive); |
737 | } | 727 | } |
@@ -817,8 +807,6 @@ static int ide_port_setup_devices(ide_hwif_t *hwif) | |||
817 | if (ide_init_queue(drive)) { | 807 | if (ide_init_queue(drive)) { |
818 | printk(KERN_ERR "ide: failed to init %s\n", | 808 | printk(KERN_ERR "ide: failed to init %s\n", |
819 | drive->name); | 809 | drive->name); |
820 | kfree(drive->id); | ||
821 | drive->id = NULL; | ||
822 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; | 810 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; |
823 | continue; | 811 | continue; |
824 | } | 812 | } |
@@ -947,9 +935,6 @@ static void drive_release_dev (struct device *dev) | |||
947 | blk_cleanup_queue(drive->queue); | 935 | blk_cleanup_queue(drive->queue); |
948 | drive->queue = NULL; | 936 | drive->queue = NULL; |
949 | 937 | ||
950 | kfree(drive->id); | ||
951 | drive->id = NULL; | ||
952 | |||
953 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; | 938 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; |
954 | 939 | ||
955 | complete(&drive->gendev_rel_comp); | 940 | complete(&drive->gendev_rel_comp); |
@@ -1035,6 +1020,15 @@ static void ide_port_init_devices(ide_hwif_t *hwif) | |||
1035 | if (port_ops && port_ops->init_dev) | 1020 | if (port_ops && port_ops->init_dev) |
1036 | port_ops->init_dev(drive); | 1021 | port_ops->init_dev(drive); |
1037 | } | 1022 | } |
1023 | |||
1024 | ide_port_for_each_dev(i, drive, hwif) { | ||
1025 | /* | ||
1026 | * default to PIO Mode 0 before we figure out | ||
1027 | * the most suited mode for the attached device | ||
1028 | */ | ||
1029 | if (port_ops && port_ops->set_pio_mode) | ||
1030 | port_ops->set_pio_mode(drive, 0); | ||
1031 | } | ||
1038 | } | 1032 | } |
1039 | 1033 | ||
1040 | static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | 1034 | static void ide_init_port(ide_hwif_t *hwif, unsigned int port, |
@@ -1042,8 +1036,7 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | |||
1042 | { | 1036 | { |
1043 | hwif->channel = port; | 1037 | hwif->channel = port; |
1044 | 1038 | ||
1045 | if (d->chipset) | 1039 | hwif->chipset = d->chipset ? d->chipset : ide_pci; |
1046 | hwif->chipset = d->chipset; | ||
1047 | 1040 | ||
1048 | if (d->init_iops) | 1041 | if (d->init_iops) |
1049 | d->init_iops(hwif); | 1042 | d->init_iops(hwif); |
@@ -1124,16 +1117,19 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif) | |||
1124 | 1117 | ||
1125 | ide_port_for_each_dev(i, drive, hwif) { | 1118 | ide_port_for_each_dev(i, drive, hwif) { |
1126 | u8 j = (hwif->index * MAX_DRIVES) + i; | 1119 | u8 j = (hwif->index * MAX_DRIVES) + i; |
1120 | u16 *saved_id = drive->id; | ||
1127 | 1121 | ||
1128 | memset(drive, 0, sizeof(*drive)); | 1122 | memset(drive, 0, sizeof(*drive)); |
1123 | memset(saved_id, 0, SECTOR_SIZE); | ||
1124 | drive->id = saved_id; | ||
1129 | 1125 | ||
1130 | drive->media = ide_disk; | 1126 | drive->media = ide_disk; |
1131 | drive->select = (i << 4) | ATA_DEVICE_OBS; | 1127 | drive->select = (i << 4) | ATA_DEVICE_OBS; |
1132 | drive->hwif = hwif; | 1128 | drive->hwif = hwif; |
1133 | drive->ready_stat = ATA_DRDY; | 1129 | drive->ready_stat = ATA_DRDY; |
1134 | drive->bad_wstat = BAD_W_STAT; | 1130 | drive->bad_wstat = BAD_W_STAT; |
1135 | drive->special.b.recalibrate = 1; | 1131 | drive->special_flags = IDE_SFLAG_RECALIBRATE | |
1136 | drive->special.b.set_geometry = 1; | 1132 | IDE_SFLAG_SET_GEOMETRY; |
1137 | drive->name[0] = 'h'; | 1133 | drive->name[0] = 'h'; |
1138 | drive->name[1] = 'd'; | 1134 | drive->name[1] = 'd'; |
1139 | drive->name[2] = 'a' + j; | 1135 | drive->name[2] = 'a' + j; |
@@ -1168,11 +1164,10 @@ static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index) | |||
1168 | ide_port_init_devices_data(hwif); | 1164 | ide_port_init_devices_data(hwif); |
1169 | } | 1165 | } |
1170 | 1166 | ||
1171 | static void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) | 1167 | static void ide_init_port_hw(ide_hwif_t *hwif, struct ide_hw *hw) |
1172 | { | 1168 | { |
1173 | memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); | 1169 | memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); |
1174 | hwif->irq = hw->irq; | 1170 | hwif->irq = hw->irq; |
1175 | hwif->chipset = hw->chipset; | ||
1176 | hwif->dev = hw->dev; | 1171 | hwif->dev = hw->dev; |
1177 | hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; | 1172 | hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; |
1178 | hwif->ack_intr = hw->ack_intr; | 1173 | hwif->ack_intr = hw->ack_intr; |
@@ -1233,8 +1228,10 @@ static void ide_port_free_devices(ide_hwif_t *hwif) | |||
1233 | ide_drive_t *drive; | 1228 | ide_drive_t *drive; |
1234 | int i; | 1229 | int i; |
1235 | 1230 | ||
1236 | ide_port_for_each_dev(i, drive, hwif) | 1231 | ide_port_for_each_dev(i, drive, hwif) { |
1232 | kfree(drive->id); | ||
1237 | kfree(drive); | 1233 | kfree(drive); |
1234 | } | ||
1238 | } | 1235 | } |
1239 | 1236 | ||
1240 | static int ide_port_alloc_devices(ide_hwif_t *hwif, int node) | 1237 | static int ide_port_alloc_devices(ide_hwif_t *hwif, int node) |
@@ -1248,6 +1245,18 @@ static int ide_port_alloc_devices(ide_hwif_t *hwif, int node) | |||
1248 | if (drive == NULL) | 1245 | if (drive == NULL) |
1249 | goto out_nomem; | 1246 | goto out_nomem; |
1250 | 1247 | ||
1248 | /* | ||
1249 | * In order to keep things simple we have an id | ||
1250 | * block for all drives at all times. If the device | ||
1251 | * is pre ATA or refuses ATA/ATAPI identify we | ||
1252 | * will add faked data to this. | ||
1253 | * | ||
1254 | * Also note that 0 everywhere means "can't do X" | ||
1255 | */ | ||
1256 | drive->id = kzalloc_node(SECTOR_SIZE, GFP_KERNEL, node); | ||
1257 | if (drive->id == NULL) | ||
1258 | goto out_nomem; | ||
1259 | |||
1251 | hwif->devices[i] = drive; | 1260 | hwif->devices[i] = drive; |
1252 | } | 1261 | } |
1253 | return 0; | 1262 | return 0; |
@@ -1257,7 +1266,8 @@ out_nomem: | |||
1257 | return -ENOMEM; | 1266 | return -ENOMEM; |
1258 | } | 1267 | } |
1259 | 1268 | ||
1260 | struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) | 1269 | struct ide_host *ide_host_alloc(const struct ide_port_info *d, |
1270 | struct ide_hw **hws, unsigned int n_ports) | ||
1261 | { | 1271 | { |
1262 | struct ide_host *host; | 1272 | struct ide_host *host; |
1263 | struct device *dev = hws[0] ? hws[0]->dev : NULL; | 1273 | struct device *dev = hws[0] ? hws[0]->dev : NULL; |
@@ -1268,7 +1278,7 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) | |||
1268 | if (host == NULL) | 1278 | if (host == NULL) |
1269 | return NULL; | 1279 | return NULL; |
1270 | 1280 | ||
1271 | for (i = 0; i < MAX_HOST_PORTS; i++) { | 1281 | for (i = 0; i < n_ports; i++) { |
1272 | ide_hwif_t *hwif; | 1282 | ide_hwif_t *hwif; |
1273 | int idx; | 1283 | int idx; |
1274 | 1284 | ||
@@ -1288,6 +1298,7 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) | |||
1288 | if (idx < 0) { | 1298 | if (idx < 0) { |
1289 | printk(KERN_ERR "%s: no free slot for interface\n", | 1299 | printk(KERN_ERR "%s: no free slot for interface\n", |
1290 | d ? d->name : "ide"); | 1300 | d ? d->name : "ide"); |
1301 | ide_port_free_devices(hwif); | ||
1291 | kfree(hwif); | 1302 | kfree(hwif); |
1292 | continue; | 1303 | continue; |
1293 | } | 1304 | } |
@@ -1344,7 +1355,7 @@ static void ide_disable_port(ide_hwif_t *hwif) | |||
1344 | } | 1355 | } |
1345 | 1356 | ||
1346 | int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | 1357 | int ide_host_register(struct ide_host *host, const struct ide_port_info *d, |
1347 | hw_regs_t **hws) | 1358 | struct ide_hw **hws) |
1348 | { | 1359 | { |
1349 | ide_hwif_t *hwif, *mate = NULL; | 1360 | ide_hwif_t *hwif, *mate = NULL; |
1350 | int i, j = 0; | 1361 | int i, j = 0; |
@@ -1438,13 +1449,13 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1438 | } | 1449 | } |
1439 | EXPORT_SYMBOL_GPL(ide_host_register); | 1450 | EXPORT_SYMBOL_GPL(ide_host_register); |
1440 | 1451 | ||
1441 | int ide_host_add(const struct ide_port_info *d, hw_regs_t **hws, | 1452 | int ide_host_add(const struct ide_port_info *d, struct ide_hw **hws, |
1442 | struct ide_host **hostp) | 1453 | unsigned int n_ports, struct ide_host **hostp) |
1443 | { | 1454 | { |
1444 | struct ide_host *host; | 1455 | struct ide_host *host; |
1445 | int rc; | 1456 | int rc; |
1446 | 1457 | ||
1447 | host = ide_host_alloc(d, hws); | 1458 | host = ide_host_alloc(d, hws, n_ports); |
1448 | if (host == NULL) | 1459 | if (host == NULL) |
1449 | return -ENOMEM; | 1460 | return -ENOMEM; |
1450 | 1461 | ||