X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=drivers%2Fide%2Fide-probe.c;h=56fb0b84342959d9a51e116ff3b0686d47998251;hb=8ac98ce17cf318f6ceb1eb88053917001f5ca60a;hp=34b1fb65bc79e3c5d396721b74859715474642d7;hpb=fc8a327db6c46de783b1a4276d846841b9abc24c;p=deliverable%2Flinux.git diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 34b1fb65bc79..56fb0b843429 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -171,11 +172,12 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) ide_fixstring(id->fw_rev, sizeof(id->fw_rev), bswap); ide_fixstring(id->serial_no, sizeof(id->serial_no), bswap); + /* we depend on this a lot! */ + id->model[sizeof(id->model)-1] = '\0'; + if (strstr(id->model, "E X A B Y T E N E S T")) goto err_misc; - /* we depend on this a lot! */ - id->model[sizeof(id->model)-1] = '\0'; printk("%s: %s, ", drive->name, id->model); drive->present = 1; drive->dead = 0; @@ -717,7 +719,7 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave); * This routine only knows how to look for drive units 0 and 1 * on an interface, so any setting of MAX_DRIVES > 2 won't work here. */ -static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) +static void probe_hwif(ide_hwif_t *hwif) { unsigned long flags; unsigned int irqd; @@ -819,8 +821,8 @@ static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) return; } - if (fixup) - fixup(hwif); + if (hwif->fixup) + hwif->fixup(hwif); for (unit = 0; unit < MAX_DRIVES; ++unit) { ide_drive_t *drive = &hwif->drives[unit]; @@ -835,16 +837,7 @@ static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) drive->nice1 = 1; - /* - * MAJOR HACK BARF :-/ - * - * FIXME: chipsets own this cruft! - */ - /* - * Move here to prevent module loading clashing. - */ - // drive->autodma = hwif->autodma; - if (hwif->ide_dma_check) { + if (hwif->ide_dma_on) { /* * Force DMAing for the beginning of the check. * Some chipsets appear to do interesting @@ -852,10 +845,7 @@ static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) * PARANOIA!!! */ hwif->dma_off_quietly(drive); -#ifdef CONFIG_IDEDMA_ONLYDISK - if (drive->media == ide_disk) -#endif - ide_set_dma(drive); + ide_set_dma(drive); } } } @@ -871,10 +861,11 @@ static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) } static int hwif_init(ide_hwif_t *hwif); +static void hwif_register_devices(ide_hwif_t *hwif); -int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) +static int probe_hwif_init(ide_hwif_t *hwif) { - probe_hwif(hwif, fixup); + probe_hwif(hwif); if (!hwif_init(hwif)) { printk(KERN_INFO "%s: failed to initialize IDE interface\n", @@ -882,34 +873,12 @@ int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif) return -1; } - if (hwif->present) { - u16 unit = 0; - int ret; + if (hwif->present) + hwif_register_devices(hwif); - for (unit = 0; unit < MAX_DRIVES; ++unit) { - ide_drive_t *drive = &hwif->drives[unit]; - /* For now don't attach absent drives, we may - want them on default or a new "empty" class - for hotplug reprobing ? */ - if (drive->present) { - ret = device_register(&drive->gendev); - if (ret < 0) - printk(KERN_WARNING "IDE: %s: " - "device_register error: %d\n", - __FUNCTION__, ret); - } - } - } return 0; } -int probe_hwif_init(ide_hwif_t *hwif) -{ - return probe_hwif_init_with_fixup(hwif, NULL); -} - -EXPORT_SYMBOL(probe_hwif_init); - #if MAX_HWIFS > 1 /* * save_match() is used to simplify logic in init_irq() below. @@ -963,7 +932,8 @@ static int ide_init_queue(ide_drive_t *drive) blk_queue_segment_boundary(q, 0xffff); if (!hwif->rqsize) { - if (hwif->no_lba48 || hwif->no_lba48_dma) + if ((hwif->host_flags & IDE_HFLAG_NO_LBA48) || + (hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA)) hwif->rqsize = 256; else hwif->rqsize = 65536; @@ -1349,12 +1319,14 @@ static int hwif_init(ide_hwif_t *hwif) if (!hwif->sg_max_nents) hwif->sg_max_nents = PRD_ENTRIES; - hwif->sg_table = kzalloc(sizeof(struct scatterlist)*hwif->sg_max_nents, + hwif->sg_table = kmalloc(sizeof(struct scatterlist)*hwif->sg_max_nents, GFP_KERNEL); if (!hwif->sg_table) { printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name); goto out; } + + sg_init_table(hwif->sg_table, hwif->sg_max_nents); if (init_irq(hwif) == 0) goto done; @@ -1390,6 +1362,24 @@ out: return 0; } +static void hwif_register_devices(ide_hwif_t *hwif) +{ + unsigned int i; + + for (i = 0; i < MAX_DRIVES; i++) { + ide_drive_t *drive = &hwif->drives[i]; + + if (drive->present) { + int ret = device_register(&drive->gendev); + + if (ret < 0) + printk(KERN_WARNING "IDE: %s: " + "device_register error: %d\n", + __FUNCTION__, ret); + } + } +} + int ideprobe_init (void) { unsigned int index; @@ -1401,27 +1391,18 @@ int ideprobe_init (void) for (index = 0; index < MAX_HWIFS; ++index) if (probe[index]) - probe_hwif(&ide_hwifs[index], NULL); + probe_hwif(&ide_hwifs[index]); for (index = 0; index < MAX_HWIFS; ++index) if (probe[index]) hwif_init(&ide_hwifs[index]); for (index = 0; index < MAX_HWIFS; ++index) { if (probe[index]) { ide_hwif_t *hwif = &ide_hwifs[index]; - int unit; if (!hwif->present) continue; if (hwif->chipset == ide_unknown || hwif->chipset == ide_forced) hwif->chipset = ide_generic; - for (unit = 0; unit < MAX_DRIVES; ++unit) - if (hwif->drives[unit].present) { - int ret = device_register( - &hwif->drives[unit].gendev); - if (ret < 0) - printk(KERN_WARNING "IDE: %s: " - "device_register error: %d\n", - __FUNCTION__, ret); - } + hwif_register_devices(hwif); } } for (index = 0; index < MAX_HWIFS; ++index) @@ -1431,3 +1412,22 @@ int ideprobe_init (void) } EXPORT_SYMBOL_GPL(ideprobe_init); + +int ide_device_add(u8 idx[4]) +{ + int i, rc = 0; + + for (i = 0; i < 4; i++) { + if (idx[i] != 0xff) + rc |= probe_hwif_init(&ide_hwifs[idx[i]]); + } + + for (i = 0; i < 4; i++) { + if (idx[i] != 0xff) + ide_proc_register_port(&ide_hwifs[idx[i]]); + } + + return rc; +} + +EXPORT_SYMBOL_GPL(ide_device_add);