diff options
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r-- | drivers/ide/ide-probe.c | 215 |
1 files changed, 111 insertions, 104 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 06575a12b635..f27baa5f140e 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -121,7 +121,8 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
121 | /* read 512 bytes of id info */ | 121 | /* read 512 bytes of id info */ |
122 | hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); | 122 | hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); |
123 | 123 | ||
124 | drive->id_read = 1; | 124 | drive->dev_flags |= IDE_DFLAG_ID_READ; |
125 | |||
125 | local_irq_enable(); | 126 | local_irq_enable(); |
126 | #ifdef DEBUG | 127 | #ifdef DEBUG |
127 | printk(KERN_INFO "%s: dumping identify data\n", drive->name); | 128 | printk(KERN_INFO "%s: dumping identify data\n", drive->name); |
@@ -153,8 +154,8 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
153 | 154 | ||
154 | printk(KERN_INFO "%s: %s, ", drive->name, m); | 155 | printk(KERN_INFO "%s: %s, ", drive->name, m); |
155 | 156 | ||
156 | drive->present = 1; | 157 | drive->dev_flags |= IDE_DFLAG_PRESENT; |
157 | drive->dead = 0; | 158 | drive->dev_flags &= ~IDE_DFLAG_DEAD; |
158 | 159 | ||
159 | /* | 160 | /* |
160 | * Check for an ATAPI device | 161 | * Check for an ATAPI device |
@@ -172,14 +173,14 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
172 | printk(KERN_CONT "cdrom or floppy?, assuming "); | 173 | printk(KERN_CONT "cdrom or floppy?, assuming "); |
173 | if (drive->media != ide_cdrom) { | 174 | if (drive->media != ide_cdrom) { |
174 | printk(KERN_CONT "FLOPPY"); | 175 | printk(KERN_CONT "FLOPPY"); |
175 | drive->removable = 1; | 176 | drive->dev_flags |= IDE_DFLAG_REMOVABLE; |
176 | break; | 177 | break; |
177 | } | 178 | } |
178 | } | 179 | } |
179 | /* Early cdrom models used zero */ | 180 | /* Early cdrom models used zero */ |
180 | type = ide_cdrom; | 181 | type = ide_cdrom; |
181 | case ide_cdrom: | 182 | case ide_cdrom: |
182 | drive->removable = 1; | 183 | drive->dev_flags |= IDE_DFLAG_REMOVABLE; |
183 | #ifdef CONFIG_PPC | 184 | #ifdef CONFIG_PPC |
184 | /* kludge for Apple PowerBook internal zip */ | 185 | /* kludge for Apple PowerBook internal zip */ |
185 | if (!strstr(m, "CD-ROM") && strstr(m, "ZIP")) { | 186 | if (!strstr(m, "CD-ROM") && strstr(m, "ZIP")) { |
@@ -195,7 +196,7 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
195 | break; | 196 | break; |
196 | case ide_optical: | 197 | case ide_optical: |
197 | printk(KERN_CONT "OPTICAL"); | 198 | printk(KERN_CONT "OPTICAL"); |
198 | drive->removable = 1; | 199 | drive->dev_flags |= IDE_DFLAG_REMOVABLE; |
199 | break; | 200 | break; |
200 | default: | 201 | default: |
201 | printk(KERN_CONT "UNKNOWN (type %d)", type); | 202 | printk(KERN_CONT "UNKNOWN (type %d)", type); |
@@ -205,6 +206,10 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
205 | drive->media = type; | 206 | drive->media = type; |
206 | /* an ATAPI device ignores DRDY */ | 207 | /* an ATAPI device ignores DRDY */ |
207 | drive->ready_stat = 0; | 208 | drive->ready_stat = 0; |
209 | if (ata_id_cdb_intr(id)) | ||
210 | drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT; | ||
211 | /* we don't do head unloading on ATAPI devices */ | ||
212 | drive->dev_flags |= IDE_DFLAG_NO_UNLOAD; | ||
208 | return; | 213 | return; |
209 | } | 214 | } |
210 | 215 | ||
@@ -216,17 +221,20 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
216 | 221 | ||
217 | /* CF devices are *not* removable in Linux definition of the term */ | 222 | /* CF devices are *not* removable in Linux definition of the term */ |
218 | if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7))) | 223 | if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7))) |
219 | drive->removable = 1; | 224 | drive->dev_flags |= IDE_DFLAG_REMOVABLE; |
220 | 225 | ||
221 | drive->media = ide_disk; | 226 | drive->media = ide_disk; |
222 | 227 | ||
228 | if (!ata_id_has_unload(drive->id)) | ||
229 | drive->dev_flags |= IDE_DFLAG_NO_UNLOAD; | ||
230 | |||
223 | printk(KERN_CONT "%s DISK drive\n", is_cfa ? "CFA" : "ATA"); | 231 | printk(KERN_CONT "%s DISK drive\n", is_cfa ? "CFA" : "ATA"); |
224 | 232 | ||
225 | return; | 233 | return; |
226 | 234 | ||
227 | err_misc: | 235 | err_misc: |
228 | kfree(id); | 236 | kfree(id); |
229 | drive->present = 0; | 237 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; |
230 | return; | 238 | return; |
231 | } | 239 | } |
232 | 240 | ||
@@ -426,16 +434,15 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
426 | ide_hwif_t *hwif = HWIF(drive); | 434 | ide_hwif_t *hwif = HWIF(drive); |
427 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 435 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
428 | int rc; | 436 | int rc; |
429 | u8 stat; | 437 | u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat; |
438 | |||
439 | /* avoid waiting for inappropriate probes */ | ||
440 | if (present && drive->media != ide_disk && cmd == ATA_CMD_ID_ATA) | ||
441 | return 4; | ||
430 | 442 | ||
431 | if (drive->present) { | ||
432 | /* avoid waiting for inappropriate probes */ | ||
433 | if (drive->media != ide_disk && cmd == ATA_CMD_ID_ATA) | ||
434 | return 4; | ||
435 | } | ||
436 | #ifdef DEBUG | 443 | #ifdef DEBUG |
437 | printk(KERN_INFO "probing for %s: present=%d, media=%d, probetype=%s\n", | 444 | printk(KERN_INFO "probing for %s: present=%d, media=%d, probetype=%s\n", |
438 | drive->name, drive->present, drive->media, | 445 | drive->name, present, drive->media, |
439 | (cmd == ATA_CMD_ID_ATA) ? "ATA" : "ATAPI"); | 446 | (cmd == ATA_CMD_ID_ATA) ? "ATA" : "ATAPI"); |
440 | #endif | 447 | #endif |
441 | 448 | ||
@@ -446,8 +453,8 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
446 | SELECT_DRIVE(drive); | 453 | SELECT_DRIVE(drive); |
447 | msleep(50); | 454 | msleep(50); |
448 | 455 | ||
449 | if (ide_read_device(drive) != drive->select.all && !drive->present) { | 456 | if (ide_read_device(drive) != drive->select && present == 0) { |
450 | if (drive->select.b.unit != 0) { | 457 | if (drive->dn & 1) { |
451 | /* exit with drive0 selected */ | 458 | /* exit with drive0 selected */ |
452 | SELECT_DRIVE(&hwif->drives[0]); | 459 | SELECT_DRIVE(&hwif->drives[0]); |
453 | /* allow ATA_BUSY to assert & clear */ | 460 | /* allow ATA_BUSY to assert & clear */ |
@@ -460,7 +467,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
460 | stat = tp_ops->read_status(hwif); | 467 | stat = tp_ops->read_status(hwif); |
461 | 468 | ||
462 | if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) || | 469 | if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) || |
463 | drive->present || cmd == ATA_CMD_ID_ATAPI) { | 470 | present || cmd == ATA_CMD_ID_ATAPI) { |
464 | /* send cmd and wait */ | 471 | /* send cmd and wait */ |
465 | if ((rc = try_to_identify(drive, cmd))) { | 472 | if ((rc = try_to_identify(drive, cmd))) { |
466 | /* failed: try again */ | 473 | /* failed: try again */ |
@@ -493,7 +500,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
493 | /* not present or maybe ATAPI */ | 500 | /* not present or maybe ATAPI */ |
494 | rc = 3; | 501 | rc = 3; |
495 | } | 502 | } |
496 | if (drive->select.b.unit != 0) { | 503 | if (drive->dn & 1) { |
497 | /* exit with drive0 selected */ | 504 | /* exit with drive0 selected */ |
498 | SELECT_DRIVE(&hwif->drives[0]); | 505 | SELECT_DRIVE(&hwif->drives[0]); |
499 | msleep(50); | 506 | msleep(50); |
@@ -542,8 +549,8 @@ static void enable_nest (ide_drive_t *drive) | |||
542 | * and presents things to the user as needed. | 549 | * and presents things to the user as needed. |
543 | * | 550 | * |
544 | * Returns: 0 no device was found | 551 | * Returns: 0 no device was found |
545 | * 1 device was found (note: drive->present might | 552 | * 1 device was found |
546 | * still be 0) | 553 | * (note: IDE_DFLAG_PRESENT might still be not set) |
547 | */ | 554 | */ |
548 | 555 | ||
549 | static inline u8 probe_for_drive (ide_drive_t *drive) | 556 | static inline u8 probe_for_drive (ide_drive_t *drive) |
@@ -559,10 +566,10 @@ static inline u8 probe_for_drive (ide_drive_t *drive) | |||
559 | * Also note that 0 everywhere means "can't do X" | 566 | * Also note that 0 everywhere means "can't do X" |
560 | */ | 567 | */ |
561 | 568 | ||
569 | drive->dev_flags &= ~IDE_DFLAG_ID_READ; | ||
570 | |||
562 | drive->id = kzalloc(SECTOR_SIZE, GFP_KERNEL); | 571 | drive->id = kzalloc(SECTOR_SIZE, GFP_KERNEL); |
563 | drive->id_read = 0; | 572 | if (drive->id == NULL) { |
564 | if(drive->id == NULL) | ||
565 | { | ||
566 | printk(KERN_ERR "ide: out of memory for id data.\n"); | 573 | printk(KERN_ERR "ide: out of memory for id data.\n"); |
567 | return 0; | 574 | return 0; |
568 | } | 575 | } |
@@ -571,14 +578,14 @@ static inline u8 probe_for_drive (ide_drive_t *drive) | |||
571 | strcpy(m, "UNKNOWN"); | 578 | strcpy(m, "UNKNOWN"); |
572 | 579 | ||
573 | /* skip probing? */ | 580 | /* skip probing? */ |
574 | if (!drive->noprobe) { | 581 | if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0) { |
575 | retry: | 582 | retry: |
576 | /* if !(success||timed-out) */ | 583 | /* if !(success||timed-out) */ |
577 | if (do_probe(drive, ATA_CMD_ID_ATA) >= 2) | 584 | if (do_probe(drive, ATA_CMD_ID_ATA) >= 2) |
578 | /* look for ATAPI device */ | 585 | /* look for ATAPI device */ |
579 | (void)do_probe(drive, ATA_CMD_ID_ATAPI); | 586 | (void)do_probe(drive, ATA_CMD_ID_ATAPI); |
580 | 587 | ||
581 | if (!drive->present) | 588 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) |
582 | /* drive not found */ | 589 | /* drive not found */ |
583 | return 0; | 590 | return 0; |
584 | 591 | ||
@@ -588,7 +595,7 @@ retry: | |||
588 | } | 595 | } |
589 | 596 | ||
590 | /* identification failed? */ | 597 | /* identification failed? */ |
591 | if (!drive->id_read) { | 598 | if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { |
592 | if (drive->media == ide_disk) { | 599 | if (drive->media == ide_disk) { |
593 | printk(KERN_INFO "%s: non-IDE drive, CHS=%d/%d/%d\n", | 600 | printk(KERN_INFO "%s: non-IDE drive, CHS=%d/%d/%d\n", |
594 | drive->name, drive->cyl, | 601 | drive->name, drive->cyl, |
@@ -598,15 +605,17 @@ retry: | |||
598 | } else { | 605 | } else { |
599 | /* nuke it */ | 606 | /* nuke it */ |
600 | printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name); | 607 | printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name); |
601 | drive->present = 0; | 608 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; |
602 | } | 609 | } |
603 | } | 610 | } |
604 | /* drive was found */ | 611 | /* drive was found */ |
605 | } | 612 | } |
606 | if(!drive->present) | 613 | |
614 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) | ||
607 | return 0; | 615 | return 0; |
616 | |||
608 | /* The drive wasn't being helpful. Add generic info only */ | 617 | /* The drive wasn't being helpful. Add generic info only */ |
609 | if (drive->id_read == 0) { | 618 | if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { |
610 | generic_id(drive); | 619 | generic_id(drive); |
611 | return 1; | 620 | return 1; |
612 | } | 621 | } |
@@ -616,7 +625,7 @@ retry: | |||
616 | ide_disk_init_mult_count(drive); | 625 | ide_disk_init_mult_count(drive); |
617 | } | 626 | } |
618 | 627 | ||
619 | return drive->present; | 628 | return !!(drive->dev_flags & IDE_DFLAG_PRESENT); |
620 | } | 629 | } |
621 | 630 | ||
622 | static void hwif_release_dev(struct device *dev) | 631 | static void hwif_release_dev(struct device *dev) |
@@ -707,7 +716,8 @@ static int ide_port_wait_ready(ide_hwif_t *hwif) | |||
707 | ide_drive_t *drive = &hwif->drives[unit]; | 716 | ide_drive_t *drive = &hwif->drives[unit]; |
708 | 717 | ||
709 | /* Ignore disks that we will not probe for later. */ | 718 | /* Ignore disks that we will not probe for later. */ |
710 | if (!drive->noprobe || drive->present) { | 719 | if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0 || |
720 | (drive->dev_flags & IDE_DFLAG_PRESENT)) { | ||
711 | SELECT_DRIVE(drive); | 721 | SELECT_DRIVE(drive); |
712 | hwif->tp_ops->set_irq(hwif, 1); | 722 | hwif->tp_ops->set_irq(hwif, 1); |
713 | mdelay(2); | 723 | mdelay(2); |
@@ -739,7 +749,7 @@ void ide_undecoded_slave(ide_drive_t *dev1) | |||
739 | { | 749 | { |
740 | ide_drive_t *dev0 = &dev1->hwif->drives[0]; | 750 | ide_drive_t *dev0 = &dev1->hwif->drives[0]; |
741 | 751 | ||
742 | if ((dev1->dn & 1) == 0 || dev0->present == 0) | 752 | if ((dev1->dn & 1) == 0 || (dev0->dev_flags & IDE_DFLAG_PRESENT) == 0) |
743 | return; | 753 | return; |
744 | 754 | ||
745 | /* If the models don't match they are not the same product */ | 755 | /* If the models don't match they are not the same product */ |
@@ -759,7 +769,7 @@ void ide_undecoded_slave(ide_drive_t *dev1) | |||
759 | /* Appears to be an IDE flash adapter with decode bugs */ | 769 | /* Appears to be an IDE flash adapter with decode bugs */ |
760 | printk(KERN_WARNING "ide-probe: ignoring undecoded slave\n"); | 770 | printk(KERN_WARNING "ide-probe: ignoring undecoded slave\n"); |
761 | 771 | ||
762 | dev1->present = 0; | 772 | dev1->dev_flags &= ~IDE_DFLAG_PRESENT; |
763 | } | 773 | } |
764 | 774 | ||
765 | EXPORT_SYMBOL_GPL(ide_undecoded_slave); | 775 | EXPORT_SYMBOL_GPL(ide_undecoded_slave); |
@@ -772,7 +782,8 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
772 | 782 | ||
773 | BUG_ON(hwif->present); | 783 | BUG_ON(hwif->present); |
774 | 784 | ||
775 | if (hwif->drives[0].noprobe && hwif->drives[1].noprobe) | 785 | if ((hwif->drives[0].dev_flags & IDE_DFLAG_NOPROBE) && |
786 | (hwif->drives[1].dev_flags & IDE_DFLAG_NOPROBE)) | ||
776 | return -EACCES; | 787 | return -EACCES; |
777 | 788 | ||
778 | /* | 789 | /* |
@@ -794,9 +805,9 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
794 | */ | 805 | */ |
795 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | 806 | for (unit = 0; unit < MAX_DRIVES; ++unit) { |
796 | ide_drive_t *drive = &hwif->drives[unit]; | 807 | ide_drive_t *drive = &hwif->drives[unit]; |
797 | drive->dn = (hwif->channel ? 2 : 0) + unit; | 808 | |
798 | (void) probe_for_drive(drive); | 809 | (void) probe_for_drive(drive); |
799 | if (drive->present) | 810 | if (drive->dev_flags & IDE_DFLAG_PRESENT) |
800 | rc = 0; | 811 | rc = 0; |
801 | } | 812 | } |
802 | 813 | ||
@@ -820,17 +831,19 @@ static void ide_port_tune_devices(ide_hwif_t *hwif) | |||
820 | for (unit = 0; unit < MAX_DRIVES; unit++) { | 831 | for (unit = 0; unit < MAX_DRIVES; unit++) { |
821 | ide_drive_t *drive = &hwif->drives[unit]; | 832 | ide_drive_t *drive = &hwif->drives[unit]; |
822 | 833 | ||
823 | if (drive->present && port_ops && port_ops->quirkproc) | 834 | if (drive->dev_flags & IDE_DFLAG_PRESENT) { |
824 | port_ops->quirkproc(drive); | 835 | if (port_ops && port_ops->quirkproc) |
836 | port_ops->quirkproc(drive); | ||
837 | } | ||
825 | } | 838 | } |
826 | 839 | ||
827 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | 840 | for (unit = 0; unit < MAX_DRIVES; ++unit) { |
828 | ide_drive_t *drive = &hwif->drives[unit]; | 841 | ide_drive_t *drive = &hwif->drives[unit]; |
829 | 842 | ||
830 | if (drive->present) { | 843 | if (drive->dev_flags & IDE_DFLAG_PRESENT) { |
831 | ide_set_max_pio(drive); | 844 | ide_set_max_pio(drive); |
832 | 845 | ||
833 | drive->nice1 = 1; | 846 | drive->dev_flags |= IDE_DFLAG_NICE1; |
834 | 847 | ||
835 | if (hwif->dma_ops) | 848 | if (hwif->dma_ops) |
836 | ide_set_dma(drive); | 849 | ide_set_dma(drive); |
@@ -840,14 +853,14 @@ static void ide_port_tune_devices(ide_hwif_t *hwif) | |||
840 | for (unit = 0; unit < MAX_DRIVES; ++unit) { | 853 | for (unit = 0; unit < MAX_DRIVES; ++unit) { |
841 | ide_drive_t *drive = &hwif->drives[unit]; | 854 | ide_drive_t *drive = &hwif->drives[unit]; |
842 | 855 | ||
843 | if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) | 856 | if ((hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) || |
844 | drive->no_io_32bit = 1; | 857 | drive->id[ATA_ID_DWORD_IO]) |
858 | drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT; | ||
845 | else | 859 | else |
846 | drive->no_io_32bit = drive->id[ATA_ID_DWORD_IO] ? 1 : 0; | 860 | drive->dev_flags &= ~IDE_DFLAG_NO_IO_32BIT; |
847 | } | 861 | } |
848 | } | 862 | } |
849 | 863 | ||
850 | #if MAX_HWIFS > 1 | ||
851 | /* | 864 | /* |
852 | * save_match() is used to simplify logic in init_irq() below. | 865 | * save_match() is used to simplify logic in init_irq() below. |
853 | * | 866 | * |
@@ -872,7 +885,6 @@ static void save_match(ide_hwif_t *hwif, ide_hwif_t *new, ide_hwif_t **match) | |||
872 | if (!m || m->irq != hwif->irq) /* don't undo a prior perfect match */ | 885 | if (!m || m->irq != hwif->irq) /* don't undo a prior perfect match */ |
873 | *match = new; | 886 | *match = new; |
874 | } | 887 | } |
875 | #endif /* MAX_HWIFS > 1 */ | ||
876 | 888 | ||
877 | /* | 889 | /* |
878 | * init request queue | 890 | * init request queue |
@@ -951,26 +963,33 @@ static void ide_add_drive_to_hwgroup(ide_drive_t *drive) | |||
951 | * - allocate the block device queue | 963 | * - allocate the block device queue |
952 | * - link drive into the hwgroup | 964 | * - link drive into the hwgroup |
953 | */ | 965 | */ |
954 | static void ide_port_setup_devices(ide_hwif_t *hwif) | 966 | static int ide_port_setup_devices(ide_hwif_t *hwif) |
955 | { | 967 | { |
956 | int i; | 968 | int i, j = 0; |
957 | 969 | ||
958 | mutex_lock(&ide_cfg_mtx); | 970 | mutex_lock(&ide_cfg_mtx); |
959 | for (i = 0; i < MAX_DRIVES; i++) { | 971 | for (i = 0; i < MAX_DRIVES; i++) { |
960 | ide_drive_t *drive = &hwif->drives[i]; | 972 | ide_drive_t *drive = &hwif->drives[i]; |
961 | 973 | ||
962 | if (!drive->present) | 974 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) |
963 | continue; | 975 | continue; |
964 | 976 | ||
965 | if (ide_init_queue(drive)) { | 977 | if (ide_init_queue(drive)) { |
966 | printk(KERN_ERR "ide: failed to init %s\n", | 978 | printk(KERN_ERR "ide: failed to init %s\n", |
967 | drive->name); | 979 | drive->name); |
980 | kfree(drive->id); | ||
981 | drive->id = NULL; | ||
982 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; | ||
968 | continue; | 983 | continue; |
969 | } | 984 | } |
970 | 985 | ||
986 | j++; | ||
987 | |||
971 | ide_add_drive_to_hwgroup(drive); | 988 | ide_add_drive_to_hwgroup(drive); |
972 | } | 989 | } |
973 | mutex_unlock(&ide_cfg_mtx); | 990 | mutex_unlock(&ide_cfg_mtx); |
991 | |||
992 | return j; | ||
974 | } | 993 | } |
975 | 994 | ||
976 | static ide_hwif_t *ide_ports[MAX_HWIFS]; | 995 | static ide_hwif_t *ide_ports[MAX_HWIFS]; |
@@ -1029,7 +1048,7 @@ static int init_irq (ide_hwif_t *hwif) | |||
1029 | 1048 | ||
1030 | mutex_lock(&ide_cfg_mtx); | 1049 | mutex_lock(&ide_cfg_mtx); |
1031 | hwif->hwgroup = NULL; | 1050 | hwif->hwgroup = NULL; |
1032 | #if MAX_HWIFS > 1 | 1051 | |
1033 | /* | 1052 | /* |
1034 | * Group up with any other hwifs that share our irq(s). | 1053 | * Group up with any other hwifs that share our irq(s). |
1035 | */ | 1054 | */ |
@@ -1054,7 +1073,7 @@ static int init_irq (ide_hwif_t *hwif) | |||
1054 | } | 1073 | } |
1055 | } | 1074 | } |
1056 | } | 1075 | } |
1057 | #endif /* MAX_HWIFS > 1 */ | 1076 | |
1058 | /* | 1077 | /* |
1059 | * If we are still without a hwgroup, then form a new one | 1078 | * If we are still without a hwgroup, then form a new one |
1060 | */ | 1079 | */ |
@@ -1153,12 +1172,13 @@ static struct kobject *ata_probe(dev_t dev, int *part, void *data) | |||
1153 | ide_hwif_t *hwif = data; | 1172 | ide_hwif_t *hwif = data; |
1154 | int unit = *part >> PARTN_BITS; | 1173 | int unit = *part >> PARTN_BITS; |
1155 | ide_drive_t *drive = &hwif->drives[unit]; | 1174 | ide_drive_t *drive = &hwif->drives[unit]; |
1156 | if (!drive->present) | 1175 | |
1176 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) | ||
1157 | return NULL; | 1177 | return NULL; |
1158 | 1178 | ||
1159 | if (drive->media == ide_disk) | 1179 | if (drive->media == ide_disk) |
1160 | request_module("ide-disk"); | 1180 | request_module("ide-disk"); |
1161 | if (drive->scsi) | 1181 | if (drive->dev_flags & IDE_DFLAG_SCSI) |
1162 | request_module("ide-scsi"); | 1182 | request_module("ide-scsi"); |
1163 | if (drive->media == ide_cdrom || drive->media == ide_optical) | 1183 | if (drive->media == ide_cdrom || drive->media == ide_optical) |
1164 | request_module("ide-cd"); | 1184 | request_module("ide-cd"); |
@@ -1205,7 +1225,7 @@ EXPORT_SYMBOL_GPL(ide_unregister_region); | |||
1205 | void ide_init_disk(struct gendisk *disk, ide_drive_t *drive) | 1225 | void ide_init_disk(struct gendisk *disk, ide_drive_t *drive) |
1206 | { | 1226 | { |
1207 | ide_hwif_t *hwif = drive->hwif; | 1227 | ide_hwif_t *hwif = drive->hwif; |
1208 | unsigned int unit = (drive->select.all >> 4) & 1; | 1228 | unsigned int unit = drive->dn & 1; |
1209 | 1229 | ||
1210 | disk->major = hwif->major; | 1230 | disk->major = hwif->major; |
1211 | disk->first_minor = unit << PARTN_BITS; | 1231 | disk->first_minor = unit << PARTN_BITS; |
@@ -1248,7 +1268,7 @@ static void drive_release_dev (struct device *dev) | |||
1248 | ide_remove_drive_from_hwgroup(drive); | 1268 | ide_remove_drive_from_hwgroup(drive); |
1249 | kfree(drive->id); | 1269 | kfree(drive->id); |
1250 | drive->id = NULL; | 1270 | drive->id = NULL; |
1251 | drive->present = 0; | 1271 | drive->dev_flags &= ~IDE_DFLAG_PRESENT; |
1252 | /* Messed up locking ... */ | 1272 | /* Messed up locking ... */ |
1253 | spin_unlock_irq(&ide_lock); | 1273 | spin_unlock_irq(&ide_lock); |
1254 | blk_cleanup_queue(drive->queue); | 1274 | blk_cleanup_queue(drive->queue); |
@@ -1327,7 +1347,7 @@ static void hwif_register_devices(ide_hwif_t *hwif) | |||
1327 | struct device *dev = &drive->gendev; | 1347 | struct device *dev = &drive->gendev; |
1328 | int ret; | 1348 | int ret; |
1329 | 1349 | ||
1330 | if (!drive->present) | 1350 | if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) |
1331 | continue; | 1351 | continue; |
1332 | 1352 | ||
1333 | snprintf(dev->bus_id, BUS_ID_SIZE, "%u.%u", hwif->index, i); | 1353 | snprintf(dev->bus_id, BUS_ID_SIZE, "%u.%u", hwif->index, i); |
@@ -1351,12 +1371,14 @@ static void ide_port_init_devices(ide_hwif_t *hwif) | |||
1351 | for (i = 0; i < MAX_DRIVES; i++) { | 1371 | for (i = 0; i < MAX_DRIVES; i++) { |
1352 | ide_drive_t *drive = &hwif->drives[i]; | 1372 | ide_drive_t *drive = &hwif->drives[i]; |
1353 | 1373 | ||
1374 | drive->dn = i + hwif->channel * 2; | ||
1375 | |||
1354 | if (hwif->host_flags & IDE_HFLAG_IO_32BIT) | 1376 | if (hwif->host_flags & IDE_HFLAG_IO_32BIT) |
1355 | drive->io_32bit = 1; | 1377 | drive->io_32bit = 1; |
1356 | if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS) | 1378 | if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS) |
1357 | drive->unmask = 1; | 1379 | drive->dev_flags |= IDE_DFLAG_UNMASK; |
1358 | if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) | 1380 | if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) |
1359 | drive->no_unmask = 1; | 1381 | drive->dev_flags |= IDE_DFLAG_NO_UNMASK; |
1360 | 1382 | ||
1361 | if (port_ops && port_ops->init_dev) | 1383 | if (port_ops && port_ops->init_dev) |
1362 | port_ops->init_dev(drive); | 1384 | port_ops->init_dev(drive); |
@@ -1513,19 +1535,14 @@ static int ide_find_port_slot(const struct ide_port_info *d) | |||
1513 | * ports 0x1f0/0x170 (the ide0/ide1 defaults). | 1535 | * ports 0x1f0/0x170 (the ide0/ide1 defaults). |
1514 | */ | 1536 | */ |
1515 | mutex_lock(&ide_cfg_mtx); | 1537 | mutex_lock(&ide_cfg_mtx); |
1516 | if (MAX_HWIFS == 1) { | 1538 | if (bootable) { |
1517 | if (ide_indexes == 0 && i == 0) | 1539 | if ((ide_indexes | i) != (1 << MAX_HWIFS) - 1) |
1518 | idx = 1; | 1540 | idx = ffz(ide_indexes | i); |
1519 | } else { | 1541 | } else { |
1520 | if (bootable) { | 1542 | if ((ide_indexes | 3) != (1 << MAX_HWIFS) - 1) |
1521 | if ((ide_indexes | i) != (1 << MAX_HWIFS) - 1) | 1543 | idx = ffz(ide_indexes | 3); |
1522 | idx = ffz(ide_indexes | i); | 1544 | else if ((ide_indexes & 3) != 3) |
1523 | } else { | 1545 | idx = ffz(ide_indexes); |
1524 | if ((ide_indexes | 3) != (1 << MAX_HWIFS) - 1) | ||
1525 | idx = ffz(ide_indexes | 3); | ||
1526 | else if ((ide_indexes & 3) != 3) | ||
1527 | idx = ffz(ide_indexes); | ||
1528 | } | ||
1529 | } | 1546 | } |
1530 | if (idx >= 0) | 1547 | if (idx >= 0) |
1531 | ide_indexes |= (1 << idx); | 1548 | ide_indexes |= (1 << idx); |
@@ -1541,8 +1558,7 @@ static void ide_free_port_slot(int idx) | |||
1541 | mutex_unlock(&ide_cfg_mtx); | 1558 | mutex_unlock(&ide_cfg_mtx); |
1542 | } | 1559 | } |
1543 | 1560 | ||
1544 | struct ide_host *ide_host_alloc_all(const struct ide_port_info *d, | 1561 | struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) |
1545 | hw_regs_t **hws) | ||
1546 | { | 1562 | { |
1547 | struct ide_host *host; | 1563 | struct ide_host *host; |
1548 | int i; | 1564 | int i; |
@@ -1551,7 +1567,7 @@ struct ide_host *ide_host_alloc_all(const struct ide_port_info *d, | |||
1551 | if (host == NULL) | 1567 | if (host == NULL) |
1552 | return NULL; | 1568 | return NULL; |
1553 | 1569 | ||
1554 | for (i = 0; i < MAX_HWIFS; i++) { | 1570 | for (i = 0; i < MAX_HOST_PORTS; i++) { |
1555 | ide_hwif_t *hwif; | 1571 | ide_hwif_t *hwif; |
1556 | int idx; | 1572 | int idx; |
1557 | 1573 | ||
@@ -1593,18 +1609,6 @@ struct ide_host *ide_host_alloc_all(const struct ide_port_info *d, | |||
1593 | 1609 | ||
1594 | return host; | 1610 | return host; |
1595 | } | 1611 | } |
1596 | EXPORT_SYMBOL_GPL(ide_host_alloc_all); | ||
1597 | |||
1598 | struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) | ||
1599 | { | ||
1600 | hw_regs_t *hws_all[MAX_HWIFS]; | ||
1601 | int i; | ||
1602 | |||
1603 | for (i = 0; i < MAX_HWIFS; i++) | ||
1604 | hws_all[i] = (i < 4) ? hws[i] : NULL; | ||
1605 | |||
1606 | return ide_host_alloc_all(d, hws_all); | ||
1607 | } | ||
1608 | EXPORT_SYMBOL_GPL(ide_host_alloc); | 1612 | EXPORT_SYMBOL_GPL(ide_host_alloc); |
1609 | 1613 | ||
1610 | int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | 1614 | int ide_host_register(struct ide_host *host, const struct ide_port_info *d, |
@@ -1613,7 +1617,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1613 | ide_hwif_t *hwif, *mate = NULL; | 1617 | ide_hwif_t *hwif, *mate = NULL; |
1614 | int i, j = 0; | 1618 | int i, j = 0; |
1615 | 1619 | ||
1616 | for (i = 0; i < MAX_HWIFS; i++) { | 1620 | for (i = 0; i < MAX_HOST_PORTS; i++) { |
1617 | hwif = host->ports[i]; | 1621 | hwif = host->ports[i]; |
1618 | 1622 | ||
1619 | if (hwif == NULL) { | 1623 | if (hwif == NULL) { |
@@ -1626,22 +1630,22 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1626 | 1630 | ||
1627 | if (d == NULL) { | 1631 | if (d == NULL) { |
1628 | mate = NULL; | 1632 | mate = NULL; |
1629 | continue; | 1633 | } else { |
1630 | } | 1634 | if ((i & 1) && mate) { |
1635 | hwif->mate = mate; | ||
1636 | mate->mate = hwif; | ||
1637 | } | ||
1631 | 1638 | ||
1632 | if ((i & 1) && mate) { | 1639 | mate = (i & 1) ? NULL : hwif; |
1633 | hwif->mate = mate; | ||
1634 | mate->mate = hwif; | ||
1635 | } | ||
1636 | 1640 | ||
1637 | mate = (i & 1) ? NULL : hwif; | 1641 | ide_init_port(hwif, i & 1, d); |
1642 | ide_port_cable_detect(hwif); | ||
1643 | } | ||
1638 | 1644 | ||
1639 | ide_init_port(hwif, i & 1, d); | ||
1640 | ide_port_cable_detect(hwif); | ||
1641 | ide_port_init_devices(hwif); | 1645 | ide_port_init_devices(hwif); |
1642 | } | 1646 | } |
1643 | 1647 | ||
1644 | for (i = 0; i < MAX_HWIFS; i++) { | 1648 | for (i = 0; i < MAX_HOST_PORTS; i++) { |
1645 | hwif = host->ports[i]; | 1649 | hwif = host->ports[i]; |
1646 | 1650 | ||
1647 | if (hwif == NULL) | 1651 | if (hwif == NULL) |
@@ -1658,7 +1662,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1658 | ide_port_tune_devices(hwif); | 1662 | ide_port_tune_devices(hwif); |
1659 | } | 1663 | } |
1660 | 1664 | ||
1661 | for (i = 0; i < MAX_HWIFS; i++) { | 1665 | for (i = 0; i < MAX_HOST_PORTS; i++) { |
1662 | hwif = host->ports[i]; | 1666 | hwif = host->ports[i]; |
1663 | 1667 | ||
1664 | if (hwif == NULL) | 1668 | if (hwif == NULL) |
@@ -1671,10 +1675,13 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1671 | continue; | 1675 | continue; |
1672 | } | 1676 | } |
1673 | 1677 | ||
1674 | j++; | ||
1675 | |||
1676 | if (hwif->present) | 1678 | if (hwif->present) |
1677 | ide_port_setup_devices(hwif); | 1679 | if (ide_port_setup_devices(hwif) == 0) { |
1680 | hwif->present = 0; | ||
1681 | continue; | ||
1682 | } | ||
1683 | |||
1684 | j++; | ||
1678 | 1685 | ||
1679 | ide_acpi_init(hwif); | 1686 | ide_acpi_init(hwif); |
1680 | 1687 | ||
@@ -1682,7 +1689,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1682 | ide_acpi_port_init_devices(hwif); | 1689 | ide_acpi_port_init_devices(hwif); |
1683 | } | 1690 | } |
1684 | 1691 | ||
1685 | for (i = 0; i < MAX_HWIFS; i++) { | 1692 | for (i = 0; i < MAX_HOST_PORTS; i++) { |
1686 | hwif = host->ports[i]; | 1693 | hwif = host->ports[i]; |
1687 | 1694 | ||
1688 | if (hwif == NULL) | 1695 | if (hwif == NULL) |
@@ -1695,7 +1702,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | |||
1695 | hwif_register_devices(hwif); | 1702 | hwif_register_devices(hwif); |
1696 | } | 1703 | } |
1697 | 1704 | ||
1698 | for (i = 0; i < MAX_HWIFS; i++) { | 1705 | for (i = 0; i < MAX_HOST_PORTS; i++) { |
1699 | hwif = host->ports[i]; | 1706 | hwif = host->ports[i]; |
1700 | 1707 | ||
1701 | if (hwif == NULL) | 1708 | if (hwif == NULL) |
@@ -1740,7 +1747,7 @@ void ide_host_free(struct ide_host *host) | |||
1740 | ide_hwif_t *hwif; | 1747 | ide_hwif_t *hwif; |
1741 | int i; | 1748 | int i; |
1742 | 1749 | ||
1743 | for (i = 0; i < MAX_HWIFS; i++) { | 1750 | for (i = 0; i < MAX_HOST_PORTS; i++) { |
1744 | hwif = host->ports[i]; | 1751 | hwif = host->ports[i]; |
1745 | 1752 | ||
1746 | if (hwif == NULL) | 1753 | if (hwif == NULL) |
@@ -1758,7 +1765,7 @@ void ide_host_remove(struct ide_host *host) | |||
1758 | { | 1765 | { |
1759 | int i; | 1766 | int i; |
1760 | 1767 | ||
1761 | for (i = 0; i < MAX_HWIFS; i++) { | 1768 | for (i = 0; i < MAX_HOST_PORTS; i++) { |
1762 | if (host->ports[i]) | 1769 | if (host->ports[i]) |
1763 | ide_unregister(host->ports[i]); | 1770 | ide_unregister(host->ports[i]); |
1764 | } | 1771 | } |