aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-probe.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:36 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:36 -0400
commit97100fc816badbbc162644cfde7ad39ae9211fb4 (patch)
tree904faf5453c2dea32fa3fde5fda230118f3effda /drivers/ide/ide-probe.c
parentbe3c096ebdbe3c828aacb5473751a22840753eff (diff)
ide: add device flags
Add 'unsigned long dev_flags' to ide_drive_t and convert bitfields to IDE_DFLAG_* flags. While at it: - IDE_DFLAG_ADDRESSING -> IDE_DFLAG_LBA48 - fixup some comments - remove needless g->flags zeroing from ide*_probe() There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r--drivers/ide/ide-probe.c104
1 files changed, 56 insertions, 48 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 237b9871f80a..57c741876536 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);
@@ -216,7 +217,7 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
216 217
217 /* CF devices are *not* removable in Linux definition of the term */ 218 /* CF devices are *not* removable in Linux definition of the term */
218 if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7))) 219 if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7)))
219 drive->removable = 1; 220 drive->dev_flags |= IDE_DFLAG_REMOVABLE;
220 221
221 drive->media = ide_disk; 222 drive->media = ide_disk;
222 223
@@ -226,7 +227,7 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
226 227
227err_misc: 228err_misc:
228 kfree(id); 229 kfree(id);
229 drive->present = 0; 230 drive->dev_flags &= ~IDE_DFLAG_PRESENT;
230 return; 231 return;
231} 232}
232 233
@@ -426,16 +427,15 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
426 ide_hwif_t *hwif = HWIF(drive); 427 ide_hwif_t *hwif = HWIF(drive);
427 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 428 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
428 int rc; 429 int rc;
429 u8 stat; 430 u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat;
431
432 /* avoid waiting for inappropriate probes */
433 if (present && drive->media != ide_disk && cmd == ATA_CMD_ID_ATA)
434 return 4;
430 435
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 436#ifdef DEBUG
437 printk(KERN_INFO "probing for %s: present=%d, media=%d, probetype=%s\n", 437 printk(KERN_INFO "probing for %s: present=%d, media=%d, probetype=%s\n",
438 drive->name, drive->present, drive->media, 438 drive->name, present, drive->media,
439 (cmd == ATA_CMD_ID_ATA) ? "ATA" : "ATAPI"); 439 (cmd == ATA_CMD_ID_ATA) ? "ATA" : "ATAPI");
440#endif 440#endif
441 441
@@ -446,7 +446,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
446 SELECT_DRIVE(drive); 446 SELECT_DRIVE(drive);
447 msleep(50); 447 msleep(50);
448 448
449 if (ide_read_device(drive) != drive->select.all && !drive->present) { 449 if (ide_read_device(drive) != drive->select.all && present == 0) {
450 if (drive->select.b.unit != 0) { 450 if (drive->select.b.unit != 0) {
451 /* exit with drive0 selected */ 451 /* exit with drive0 selected */
452 SELECT_DRIVE(&hwif->drives[0]); 452 SELECT_DRIVE(&hwif->drives[0]);
@@ -460,7 +460,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
460 stat = tp_ops->read_status(hwif); 460 stat = tp_ops->read_status(hwif);
461 461
462 if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) || 462 if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) ||
463 drive->present || cmd == ATA_CMD_ID_ATAPI) { 463 present || cmd == ATA_CMD_ID_ATAPI) {
464 /* send cmd and wait */ 464 /* send cmd and wait */
465 if ((rc = try_to_identify(drive, cmd))) { 465 if ((rc = try_to_identify(drive, cmd))) {
466 /* failed: try again */ 466 /* failed: try again */
@@ -542,8 +542,8 @@ static void enable_nest (ide_drive_t *drive)
542 * and presents things to the user as needed. 542 * and presents things to the user as needed.
543 * 543 *
544 * Returns: 0 no device was found 544 * Returns: 0 no device was found
545 * 1 device was found (note: drive->present might 545 * 1 device was found
546 * still be 0) 546 * (note: IDE_DFLAG_PRESENT might still be not set)
547 */ 547 */
548 548
549static inline u8 probe_for_drive (ide_drive_t *drive) 549static inline u8 probe_for_drive (ide_drive_t *drive)
@@ -559,10 +559,10 @@ static inline u8 probe_for_drive (ide_drive_t *drive)
559 * Also note that 0 everywhere means "can't do X" 559 * Also note that 0 everywhere means "can't do X"
560 */ 560 */
561 561
562 drive->dev_flags &= ~IDE_DFLAG_ID_READ;
563
562 drive->id = kzalloc(SECTOR_SIZE, GFP_KERNEL); 564 drive->id = kzalloc(SECTOR_SIZE, GFP_KERNEL);
563 drive->id_read = 0; 565 if (drive->id == NULL) {
564 if(drive->id == NULL)
565 {
566 printk(KERN_ERR "ide: out of memory for id data.\n"); 566 printk(KERN_ERR "ide: out of memory for id data.\n");
567 return 0; 567 return 0;
568 } 568 }
@@ -571,14 +571,14 @@ static inline u8 probe_for_drive (ide_drive_t *drive)
571 strcpy(m, "UNKNOWN"); 571 strcpy(m, "UNKNOWN");
572 572
573 /* skip probing? */ 573 /* skip probing? */
574 if (!drive->noprobe) { 574 if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0) {
575retry: 575retry:
576 /* if !(success||timed-out) */ 576 /* if !(success||timed-out) */
577 if (do_probe(drive, ATA_CMD_ID_ATA) >= 2) 577 if (do_probe(drive, ATA_CMD_ID_ATA) >= 2)
578 /* look for ATAPI device */ 578 /* look for ATAPI device */
579 (void)do_probe(drive, ATA_CMD_ID_ATAPI); 579 (void)do_probe(drive, ATA_CMD_ID_ATAPI);
580 580
581 if (!drive->present) 581 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
582 /* drive not found */ 582 /* drive not found */
583 return 0; 583 return 0;
584 584
@@ -588,7 +588,7 @@ retry:
588 } 588 }
589 589
590 /* identification failed? */ 590 /* identification failed? */
591 if (!drive->id_read) { 591 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) {
592 if (drive->media == ide_disk) { 592 if (drive->media == ide_disk) {
593 printk(KERN_INFO "%s: non-IDE drive, CHS=%d/%d/%d\n", 593 printk(KERN_INFO "%s: non-IDE drive, CHS=%d/%d/%d\n",
594 drive->name, drive->cyl, 594 drive->name, drive->cyl,
@@ -598,15 +598,17 @@ retry:
598 } else { 598 } else {
599 /* nuke it */ 599 /* nuke it */
600 printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name); 600 printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name);
601 drive->present = 0; 601 drive->dev_flags &= ~IDE_DFLAG_PRESENT;
602 } 602 }
603 } 603 }
604 /* drive was found */ 604 /* drive was found */
605 } 605 }
606 if(!drive->present) 606
607 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
607 return 0; 608 return 0;
609
608 /* The drive wasn't being helpful. Add generic info only */ 610 /* The drive wasn't being helpful. Add generic info only */
609 if (drive->id_read == 0) { 611 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) {
610 generic_id(drive); 612 generic_id(drive);
611 return 1; 613 return 1;
612 } 614 }
@@ -616,7 +618,7 @@ retry:
616 ide_disk_init_mult_count(drive); 618 ide_disk_init_mult_count(drive);
617 } 619 }
618 620
619 return drive->present; 621 return !!(drive->dev_flags & IDE_DFLAG_PRESENT);
620} 622}
621 623
622static void hwif_release_dev(struct device *dev) 624static void hwif_release_dev(struct device *dev)
@@ -707,7 +709,8 @@ static int ide_port_wait_ready(ide_hwif_t *hwif)
707 ide_drive_t *drive = &hwif->drives[unit]; 709 ide_drive_t *drive = &hwif->drives[unit];
708 710
709 /* Ignore disks that we will not probe for later. */ 711 /* Ignore disks that we will not probe for later. */
710 if (!drive->noprobe || drive->present) { 712 if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0 ||
713 (drive->dev_flags & IDE_DFLAG_PRESENT)) {
711 SELECT_DRIVE(drive); 714 SELECT_DRIVE(drive);
712 hwif->tp_ops->set_irq(hwif, 1); 715 hwif->tp_ops->set_irq(hwif, 1);
713 mdelay(2); 716 mdelay(2);
@@ -739,7 +742,7 @@ void ide_undecoded_slave(ide_drive_t *dev1)
739{ 742{
740 ide_drive_t *dev0 = &dev1->hwif->drives[0]; 743 ide_drive_t *dev0 = &dev1->hwif->drives[0];
741 744
742 if ((dev1->dn & 1) == 0 || dev0->present == 0) 745 if ((dev1->dn & 1) == 0 || (dev0->dev_flags & IDE_DFLAG_PRESENT) == 0)
743 return; 746 return;
744 747
745 /* If the models don't match they are not the same product */ 748 /* If the models don't match they are not the same product */
@@ -759,7 +762,7 @@ void ide_undecoded_slave(ide_drive_t *dev1)
759 /* Appears to be an IDE flash adapter with decode bugs */ 762 /* Appears to be an IDE flash adapter with decode bugs */
760 printk(KERN_WARNING "ide-probe: ignoring undecoded slave\n"); 763 printk(KERN_WARNING "ide-probe: ignoring undecoded slave\n");
761 764
762 dev1->present = 0; 765 dev1->dev_flags &= ~IDE_DFLAG_PRESENT;
763} 766}
764 767
765EXPORT_SYMBOL_GPL(ide_undecoded_slave); 768EXPORT_SYMBOL_GPL(ide_undecoded_slave);
@@ -772,7 +775,8 @@ static int ide_probe_port(ide_hwif_t *hwif)
772 775
773 BUG_ON(hwif->present); 776 BUG_ON(hwif->present);
774 777
775 if (hwif->drives[0].noprobe && hwif->drives[1].noprobe) 778 if ((hwif->drives[0].dev_flags & IDE_DFLAG_NOPROBE) &&
779 (hwif->drives[1].dev_flags & IDE_DFLAG_NOPROBE))
776 return -EACCES; 780 return -EACCES;
777 781
778 /* 782 /*
@@ -796,7 +800,7 @@ static int ide_probe_port(ide_hwif_t *hwif)
796 ide_drive_t *drive = &hwif->drives[unit]; 800 ide_drive_t *drive = &hwif->drives[unit];
797 drive->dn = (hwif->channel ? 2 : 0) + unit; 801 drive->dn = (hwif->channel ? 2 : 0) + unit;
798 (void) probe_for_drive(drive); 802 (void) probe_for_drive(drive);
799 if (drive->present) 803 if (drive->dev_flags & IDE_DFLAG_PRESENT)
800 rc = 0; 804 rc = 0;
801 } 805 }
802 806
@@ -820,17 +824,19 @@ static void ide_port_tune_devices(ide_hwif_t *hwif)
820 for (unit = 0; unit < MAX_DRIVES; unit++) { 824 for (unit = 0; unit < MAX_DRIVES; unit++) {
821 ide_drive_t *drive = &hwif->drives[unit]; 825 ide_drive_t *drive = &hwif->drives[unit];
822 826
823 if (drive->present && port_ops && port_ops->quirkproc) 827 if (drive->dev_flags & IDE_DFLAG_PRESENT) {
824 port_ops->quirkproc(drive); 828 if (port_ops && port_ops->quirkproc)
829 port_ops->quirkproc(drive);
830 }
825 } 831 }
826 832
827 for (unit = 0; unit < MAX_DRIVES; ++unit) { 833 for (unit = 0; unit < MAX_DRIVES; ++unit) {
828 ide_drive_t *drive = &hwif->drives[unit]; 834 ide_drive_t *drive = &hwif->drives[unit];
829 835
830 if (drive->present) { 836 if (drive->dev_flags & IDE_DFLAG_PRESENT) {
831 ide_set_max_pio(drive); 837 ide_set_max_pio(drive);
832 838
833 drive->nice1 = 1; 839 drive->dev_flags |= IDE_DFLAG_NICE1;
834 840
835 if (hwif->dma_ops) 841 if (hwif->dma_ops)
836 ide_set_dma(drive); 842 ide_set_dma(drive);
@@ -840,10 +846,11 @@ static void ide_port_tune_devices(ide_hwif_t *hwif)
840 for (unit = 0; unit < MAX_DRIVES; ++unit) { 846 for (unit = 0; unit < MAX_DRIVES; ++unit) {
841 ide_drive_t *drive = &hwif->drives[unit]; 847 ide_drive_t *drive = &hwif->drives[unit];
842 848
843 if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) 849 if ((hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) ||
844 drive->no_io_32bit = 1; 850 drive->id[ATA_ID_DWORD_IO])
851 drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT;
845 else 852 else
846 drive->no_io_32bit = drive->id[ATA_ID_DWORD_IO] ? 1 : 0; 853 drive->dev_flags &= ~IDE_DFLAG_NO_IO_32BIT;
847 } 854 }
848} 855}
849 856
@@ -957,7 +964,7 @@ static void ide_port_setup_devices(ide_hwif_t *hwif)
957 for (i = 0; i < MAX_DRIVES; i++) { 964 for (i = 0; i < MAX_DRIVES; i++) {
958 ide_drive_t *drive = &hwif->drives[i]; 965 ide_drive_t *drive = &hwif->drives[i];
959 966
960 if (!drive->present) 967 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
961 continue; 968 continue;
962 969
963 if (ide_init_queue(drive)) { 970 if (ide_init_queue(drive)) {
@@ -1151,12 +1158,13 @@ static struct kobject *ata_probe(dev_t dev, int *part, void *data)
1151 ide_hwif_t *hwif = data; 1158 ide_hwif_t *hwif = data;
1152 int unit = *part >> PARTN_BITS; 1159 int unit = *part >> PARTN_BITS;
1153 ide_drive_t *drive = &hwif->drives[unit]; 1160 ide_drive_t *drive = &hwif->drives[unit];
1154 if (!drive->present) 1161
1162 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
1155 return NULL; 1163 return NULL;
1156 1164
1157 if (drive->media == ide_disk) 1165 if (drive->media == ide_disk)
1158 request_module("ide-disk"); 1166 request_module("ide-disk");
1159 if (drive->scsi) 1167 if (drive->dev_flags & IDE_DFLAG_SCSI)
1160 request_module("ide-scsi"); 1168 request_module("ide-scsi");
1161 if (drive->media == ide_cdrom || drive->media == ide_optical) 1169 if (drive->media == ide_cdrom || drive->media == ide_optical)
1162 request_module("ide-cd"); 1170 request_module("ide-cd");
@@ -1246,7 +1254,7 @@ static void drive_release_dev (struct device *dev)
1246 ide_remove_drive_from_hwgroup(drive); 1254 ide_remove_drive_from_hwgroup(drive);
1247 kfree(drive->id); 1255 kfree(drive->id);
1248 drive->id = NULL; 1256 drive->id = NULL;
1249 drive->present = 0; 1257 drive->dev_flags &= ~IDE_DFLAG_PRESENT;
1250 /* Messed up locking ... */ 1258 /* Messed up locking ... */
1251 spin_unlock_irq(&ide_lock); 1259 spin_unlock_irq(&ide_lock);
1252 blk_cleanup_queue(drive->queue); 1260 blk_cleanup_queue(drive->queue);
@@ -1325,7 +1333,7 @@ static void hwif_register_devices(ide_hwif_t *hwif)
1325 struct device *dev = &drive->gendev; 1333 struct device *dev = &drive->gendev;
1326 int ret; 1334 int ret;
1327 1335
1328 if (!drive->present) 1336 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
1329 continue; 1337 continue;
1330 1338
1331 snprintf(dev->bus_id, BUS_ID_SIZE, "%u.%u", hwif->index, i); 1339 snprintf(dev->bus_id, BUS_ID_SIZE, "%u.%u", hwif->index, i);
@@ -1352,9 +1360,9 @@ static void ide_port_init_devices(ide_hwif_t *hwif)
1352 if (hwif->host_flags & IDE_HFLAG_IO_32BIT) 1360 if (hwif->host_flags & IDE_HFLAG_IO_32BIT)
1353 drive->io_32bit = 1; 1361 drive->io_32bit = 1;
1354 if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS) 1362 if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS)
1355 drive->unmask = 1; 1363 drive->dev_flags |= IDE_DFLAG_UNMASK;
1356 if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) 1364 if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS)
1357 drive->no_unmask = 1; 1365 drive->dev_flags |= IDE_DFLAG_NO_UNMASK;
1358 1366
1359 if (port_ops && port_ops->init_dev) 1367 if (port_ops && port_ops->init_dev)
1360 port_ops->init_dev(drive); 1368 port_ops->init_dev(drive);