aboutsummaryrefslogtreecommitdiffstats
path: root/lib
ModeNameSize
-rw-r--r--.gitignore51logstatsplainblame
-rw-r--r--Kconfig6217logstatsplainblame
-rw-r--r--Kconfig.debug44059logstatsplainblame
-rw-r--r--Kconfig.kgdb2403logstatsplainblame
-rw-r--r--Kconfig.kmemcheck2967logstatsplainblame
-rw-r--r--Makefile3830logstatsplainblame
-rw-r--r--argv_split.c1826logstatsplainblame
-rw-r--r--atomic64.c4218logstatsplainblame
-rw-r--r--atomic64_test.c3562logstatsplainblame
-rw-r--r--audit.c1232logstatsplainblame
-rw-r--r--average.c1916logstatsplainblame
-rw-r--r--bcd.c257logstatsplainblame
-rw-r--r--bch.c36404logstatsplainblame
-rw-r--r--bitmap.c35325logstatsplainblame
-rw-r--r--bitrev.c2157logstatsplainblame
-rw-r--r--bsearch.c1615logstatsplainblame
-rw-r--r--btree.c19611logstatsplainblame
-rw-r--r--bug.c4783logstatsplainblame
-rw-r--r--bust_spinlocks.c636logstatsplainblame
-rw-r--r--check_signature.c599logstatsplainblame
-rw-r--r--checksum.c4946logstatsplainblame
-rw-r--r--cmdline.c3737logstatsplainblame
-rw-r--r--cordic.c2546logstatsplainblame
-rw-r--r--cpu-notifier-error-inject.c1565logstatsplainblame
-rw-r--r--cpu_rmap.c6975logstatsplainblame
-rw-r--r--cpumask.c4667logstatsplainblame
-rw-r--r--crc-ccitt.c3052logstatsplainblame
-rw-r--r--crc-itu-t.c2892logstatsplainblame
-rw-r--r--crc-t10dif.c2965logstatsplainblame
-rw-r--r--crc16.c2838logstatsplainblame
-rw-r--r--crc32.c14868logstatsplainblame
-rw-r--r--crc32defs.h1072logstatsplainblame
-rw-r--r--crc7.c2329logstatsplainblame
-rw-r--r--crc8.c2461logstatsplainblame
-rw-r--r--ctype.c1362logstatsplainblame
-rw-r--r--debug_locks.c1108logstatsplainblame
-rw-r--r--debugobjects.c25921logstatsplainblame
-rw-r--r--dec_and_lock.c782logstatsplainblame
-rw-r--r--decompress.c1373logstatsplainblame
-rw-r--r--decompress_bunzip2.c24002logstatsplainblame
-rw-r--r--decompress_inflate.c3811logstatsplainblame
-rw-r--r--decompress_unlzma.c16160logstatsplainblame
-rw-r--r--decompress_unlzo.c6960logstatsplainblame
-rw-r--r--decompress_unxz.c10892logstatsplainblame
-rw-r--r--devres.c7927logstatsplainblame
-rw-r--r--div64.c3128logstatsplainblame
-rw-r--r--dma-debug.c32635logstatsplainblame
-rw-r--r--dump_stack.c290logstatsplainblame
-rw-r--r--dynamic_debug.c19669logstatsplainblame
-rw-r--r--extable.c2486logstatsplainblame
-rw-r--r--fault-inject.c8069logstatsplainblame
-rw-r--r--find_last_bit.c1139logstatsplainblame
-rw-r--r--find_next_bit.c6535logstatsplainblame
-rw-r--r--flex_array.c11135logstatsplainblame
-rw-r--r--gcd.c291logstatsplainblame
-rw-r--r--gen_crc32table.c2303logstatsplainblame
-rw-r--r--genalloc.c6086logstatsplainblame
-rw-r--r--halfmd4.c2028logstatsplainblame
-rw-r--r--hexdump.c7036logstatsplainblame
-rw-r--r--hweight.c1911logstatsplainblame
-rw-r--r--idr.c22410logstatsplainblame
-rw-r--r--inflate.c39549logstatsplainblame
-rw-r--r--int_sqrt.c533logstatsplainblame
-rw-r--r--iomap.c7565logstatsplainblame
-rw-r--r--iomap_copy.c2198logstatsplainblame
-rw-r--r--iommu-helper.c1006logstatsplainblame
-rw-r--r--ioremap.c2195logstatsplainblame
-rw-r--r--irq_regs.c578logstatsplainblame
-rw-r--r--is_single_threaded.c1363logstatsplainblame
-rw-r--r--kasprintf.c704logstatsplainblame
-rw-r--r--klist.c9566logstatsplainblame
-rw-r--r--kobject.c24696logstatsplainblame
-rw-r--r--kobject_uevent.c10535logstatsplainblame
-rw-r--r--kref.c2667logstatsplainblame
-rw-r--r--kstrtox.c5256logstatsplainblame
-rw-r--r--lcm.c265logstatsplainblame
-rw-r--r--libcrc32c.c2133logstatsplainblame
-rw-r--r--list_debug.c1913logstatsplainblame
-rw-r--r--list_sort.c7193logstatsplainblame
-rw-r--r--locking-selftest-hardirq.h207logstatsplainblame
-rw-r--r--locking-selftest-mutex.h120logstatsplainblame
-rw-r--r--locking-selftest-rlock-hardirq.h74logstatsplainblame
-rw-r--r--locking-selftest-rlock-softirq.h74logstatsplainblame
-rw-r--r--locking-selftest-rlock.h158logstatsplainblame
-rw-r--r--locking-selftest-rsem.h163logstatsplainblame
-rw-r--r--locking-selftest-softirq.h207logstatsplainblame
-rw-r--r--locking-selftest-spin-hardirq.h73logstatsplainblame
-rw-r--r--locking-selftest-spin-softirq.h73logstatsplainblame
-rw-r--r--locking-selftest-spin.h118logstatsplainblame
-rw-r--r--locking-selftest-wlock-hardirq.h74logstatsplainblame
-rw-r--r--locking-selftest-wlock-softirq.h74logstatsplainblame
-rw-r--r--locking-selftest-wlock.h158logstatsplainblame
-rw-r--r--locking-selftest-wsem.h163logstatsplainblame
-rw-r--r--locking-selftest.c29316logstatsplainblame
-rw-r--r--lru_cache.c14933logstatsplainblame
d---------lzo163logstatsplain
-rw-r--r--nlattr.c12528logstatsplainblame
-rw-r--r--parser.c6209logstatsplainblame
-rw-r--r--percpu_counter.c5166logstatsplainblame
-rw-r--r--plist.c4816logstatsplainblame
-rw-r--r--prio_heap.c1477logstatsplainblame
-rw-r--r--prio_tree.c12541logstatsplainblame
-rw-r--r--proportions.c9527logstatsplainblame
-rw-r--r--radix-tree.c37952logstatsplainblame
d---------raid6457logstatsplain
-rw-r--r--random32.c4015logstatsplainblame
-rw-r--r--ratelimit.c1559logstatsplainblame
-rw-r--r--rational.c1524logstatsplainblame
-rw-r--r--rbtree.c10295logstatsplainblame
-rw-r--r--reciprocal_div.c159logstatsplainblame
d---------reed_solomon156logstatsplain
-rw-r--r--rwsem-spinlock.c7103logstatsplainblame
-rw-r--r--rwsem.c8240logstatsplainblame
-rw-r--r--scatterlist.c13082logstatsplainblame
-rw-r--r--sha1.c2469logstatsplainblame
-rw-r--r--show_mem.c1375logstatsplainblame
-rw-r--r--smp_processor_id.c1119logstatsplainblame
-rw-r--r--sort.c2605logstatsplainblame
-rw-r--r--spinlock_debug.c7022logstatsplainblame
-rw-r--r--string.c15214logstatsplainblame
-rw-r--r--string_helpers.c1702logstatsplainblame
-rw-r--r--swiotlb.c26265logstatsplainblame
-rw-r--r--syscall.c2475logstatsplainblame
-rw-r--r--test-kstrtox.c17808logstatsplainblame
-rw-r--r--textsearch.c9800logstatsplainblame
-rw-r--r--timerqueue.c3155logstatsplainblame
-rw-r--r--ts_bm.c5408logstatsplainblame
-rw-r--r--ts_fsm.c10866logstatsplainblame
-rw-r--r--ts_kmp.c4437logstatsplainblame
-rw-r--r--uuid.c1398logstatsplainblame
-rw-r--r--vsprintf.c48291logstatsplainblame
d---------xz433logstatsplain
d---------zlib_deflate189logstatsplain
d---------zlib_inflate414logstatsplain
span>drive->media != ide_disk) && (cmd == WIN_IDENTIFY)) return 4; } #ifdef DEBUG printk("probing for %s: present=%d, media=%d, probetype=%s\n", drive->name, drive->present, drive->media, (cmd == WIN_IDENTIFY) ? "ATA" : "ATAPI"); #endif /* needed for some systems * (e.g. crw9624 as drive0 with disk as slave) */ msleep(50); SELECT_DRIVE(drive); msleep(50); if (hwif->INB(IDE_SELECT_REG) != drive->select.all && !drive->present) { if (drive->select.b.unit != 0) { /* exit with drive0 selected */ SELECT_DRIVE(&hwif->drives[0]); /* allow BUSY_STAT to assert & clear */ msleep(50); } /* no i/f present: mmm.. this should be a 4 -ml */ return 3; } if (OK_STAT((hwif->INB(IDE_STATUS_REG)), READY_STAT, BUSY_STAT) || drive->present || cmd == WIN_PIDENTIFY) { /* send cmd and wait */ if ((rc = try_to_identify(drive, cmd))) { /* failed: try again */ rc = try_to_identify(drive,cmd); } if (hwif->INB(IDE_STATUS_REG) == (BUSY_STAT|READY_STAT)) return 4; if ((rc == 1 && cmd == WIN_PIDENTIFY) && ((drive->autotune == IDE_TUNE_DEFAULT) || (drive->autotune == IDE_TUNE_AUTO))) { unsigned long timeout; printk("%s: no response (status = 0x%02x), " "resetting drive\n", drive->name, hwif->INB(IDE_STATUS_REG)); msleep(50); hwif->OUTB(drive->select.all, IDE_SELECT_REG); msleep(50); hwif->OUTB(WIN_SRST, IDE_COMMAND_REG); timeout = jiffies; while (((hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && time_before(jiffies, timeout + WAIT_WORSTCASE)) msleep(50); rc = try_to_identify(drive, cmd); } if (rc == 1) printk("%s: no response (status = 0x%02x)\n", drive->name, hwif->INB(IDE_STATUS_REG)); /* ensure drive irq is clear */ (void) hwif->INB(IDE_STATUS_REG); } else { /* not present or maybe ATAPI */ rc = 3; } if (drive->select.b.unit != 0) { /* exit with drive0 selected */ SELECT_DRIVE(&hwif->drives[0]); msleep(50); /* ensure drive irq is clear */ (void) hwif->INB(IDE_STATUS_REG); } return rc; } /* * */ static void enable_nest (ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); unsigned long timeout; printk("%s: enabling %s -- ", hwif->name, drive->id->model); SELECT_DRIVE(drive); msleep(50); hwif->OUTB(EXABYTE_ENABLE_NEST, IDE_COMMAND_REG); timeout = jiffies + WAIT_WORSTCASE; do { if (time_after(jiffies, timeout)) { printk("failed (timeout)\n"); return; } msleep(50); } while ((hwif->INB(IDE_STATUS_REG)) & BUSY_STAT); msleep(50); if (!OK_STAT((hwif->INB(IDE_STATUS_REG)), 0, BAD_STAT)) { printk("failed (status = 0x%02x)\n", hwif->INB(IDE_STATUS_REG)); } else { printk("success\n"); } /* if !(success||timed-out) */ if (do_probe(drive, WIN_IDENTIFY) >= 2) { /* look for ATAPI device */ (void) do_probe(drive, WIN_PIDENTIFY); } } /** * probe_for_drives - upper level drive probe * @drive: drive to probe for * * probe_for_drive() tests for existence of a given drive using do_probe() * and presents things to the user as needed. * * Returns: 0 no device was found * 1 device was found (note: drive->present might * still be 0) */ static inline u8 probe_for_drive (ide_drive_t *drive) { /* * In order to keep things simple we have an id * block for all drives at all times. If the device * is pre ATA or refuses ATA/ATAPI identify we * will add faked data to this. * * Also note that 0 everywhere means "can't do X" */ drive->id = kzalloc(SECTOR_WORDS *4, GFP_KERNEL); drive->id_read = 0; if(drive->id == NULL) { printk(KERN_ERR "ide: out of memory for id data.\n"); return 0; } strcpy(drive->id->model, "UNKNOWN"); /* skip probing? */ if (!drive->noprobe) { /* if !(success||timed-out) */ if (do_probe(drive, WIN_IDENTIFY) >= 2) { /* look for ATAPI device */ (void) do_probe(drive, WIN_PIDENTIFY); } if (!drive->present) /* drive not found */ return 0; if (strstr(drive->id->model, "E X A B Y T E N E S T")) enable_nest(drive); /* identification failed? */ if (!drive->id_read) { if (drive->media == ide_disk) { printk(KERN_INFO "%s: non-IDE drive, CHS=%d/%d/%d\n", drive->name, drive->cyl, drive->head, drive->sect); } else if (drive->media == ide_cdrom) { printk(KERN_INFO "%s: ATAPI cdrom (?)\n", drive->name); } else { /* nuke it */ printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name); drive->present = 0; } } /* drive was found */ } if(!drive->present) return 0; /* The drive wasn't being helpful. Add generic info only */ if (drive->id_read == 0) { generic_id(drive); return 1; } if (drive->media == ide_disk) { ide_disk_init_chs(drive); ide_disk_init_mult_count(drive); } return drive->present; } static void hwif_release_dev (struct device *dev) { ide_hwif_t *hwif = container_of(dev, ide_hwif_t, gendev); complete(&hwif->gendev_rel_comp); } static void hwif_register (ide_hwif_t *hwif) { int ret; /* register with global device tree */ strlcpy(hwif->gendev.bus_id,hwif->name,BUS_ID_SIZE); hwif->gendev.driver_data = hwif; if (hwif->gendev.parent == NULL) { if (hwif->pci_dev) hwif->gendev.parent = &hwif->pci_dev->dev; else /* Would like to do = &device_legacy */ hwif->gendev.parent = NULL; } hwif->gendev.release = hwif_release_dev; ret = device_register(&hwif->gendev); if (ret < 0) printk(KERN_WARNING "IDE: %s: device_register error: %d\n", __FUNCTION__, ret); } static int wait_hwif_ready(ide_hwif_t *hwif) { int rc; printk(KERN_DEBUG "Probing IDE interface %s...\n", hwif->name); /* Let HW settle down a bit from whatever init state we * come from */ mdelay(2); /* Wait for BSY bit to go away, spec timeout is 30 seconds, * I know of at least one disk who takes 31 seconds, I use 35 * here to be safe */ rc = ide_wait_not_busy(hwif, 35000); if (rc) return rc; /* Now make sure both master & slave are ready */ SELECT_DRIVE(&hwif->drives[0]); hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]); mdelay(2); rc = ide_wait_not_busy(hwif, 35000); if (rc) return rc; SELECT_DRIVE(&hwif->drives[1]); hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]); mdelay(2); rc = ide_wait_not_busy(hwif, 35000); /* Exit function with master reselected (let's be sane) */ SELECT_DRIVE(&hwif->drives[0]); return rc; } /** * ide_undecoded_slave - look for bad CF adapters * @hwif: interface * * Analyse the drives on the interface and attempt to decide if we * have the same drive viewed twice. This occurs with crap CF adapters * and PCMCIA sometimes. */ void ide_undecoded_slave(ide_hwif_t *hwif) { ide_drive_t *drive0 = &hwif->drives[0]; ide_drive_t *drive1 = &hwif->drives[1]; if (drive0->present == 0 || drive1->present == 0) return; /* If the models don't match they are not the same product */ if (strcmp(drive0->id->model, drive1->id->model)) return; /* Serial numbers do not match */ if (strncmp(drive0->id->serial_no, drive1->id->serial_no, 20)) return; /* No serial number, thankfully very rare for CF */ if (drive0->id->serial_no[0] == 0) return; /* Appears to be an IDE flash adapter with decode bugs */ printk(KERN_WARNING "ide-probe: ignoring undecoded slave\n"); drive1->present = 0; } 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)) { unsigned long flags; unsigned int irqd; int unit; if (hwif->noprobe) return; if ((hwif->chipset != ide_4drives || !hwif->mate || !hwif->mate->present) && (ide_hwif_request_regions(hwif))) { u16 msgout = 0; for (unit = 0; unit < MAX_DRIVES; ++unit) { ide_drive_t *drive = &hwif->drives[unit]; if (drive->present) { drive->present = 0; printk(KERN_ERR "%s: ERROR, PORTS ALREADY IN USE\n", drive->name); msgout = 1; } } if (!msgout) printk(KERN_ERR "%s: ports already in use, skipping probe\n", hwif->name); return; } /* * We must always disable IRQ, as probe_for_drive will assert IRQ, but * we'll install our IRQ driver much later... */ irqd = hwif->irq; if (irqd) disable_irq(hwif->irq); local_irq_set(flags); /* This is needed on some PPCs and a bunch of BIOS-less embedded * platforms. Typical cases are: * * - The firmware hard reset the disk before booting the kernel, * the drive is still doing it's poweron-reset sequence, that * can take up to 30 seconds * - The firmware does nothing (or no firmware), the device is * still in POST state (same as above actually). * - Some CD/DVD/Writer combo drives tend to drive the bus during * their reset sequence even when they are non-selected slave * devices, thus preventing discovery of the main HD * * Doing this wait-for-busy should not harm any existing configuration * (at least things won't be worse than what current code does, that * is blindly go & talk to the drive) and fix some issues like the * above. * * BenH. */ if (wait_hwif_ready(hwif) == -EBUSY) printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); /* * Need to probe slave device first to make it release PDIAG-. */ for (unit = MAX_DRIVES - 1; unit >= 0; unit--) { ide_drive_t *drive = &hwif->drives[unit]; drive->dn = (hwif->channel ? 2 : 0) + unit; (void) probe_for_drive(drive); if (drive->present && !hwif->present) { hwif->present = 1; if (hwif->chipset != ide_4drives || !hwif->mate || !hwif->mate->present) { hwif_register(hwif); } } } if (hwif->io_ports[IDE_CONTROL_OFFSET] && hwif->reset) { unsigned long timeout = jiffies + WAIT_WORSTCASE; u8 stat; printk(KERN_WARNING "%s: reset\n", hwif->name); hwif->OUTB(12, hwif->io_ports[IDE_CONTROL_OFFSET]); udelay(10); hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]); do { msleep(50); stat = hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]); } while ((stat & BUSY_STAT) && time_after(timeout, jiffies)); } local_irq_restore(flags); /* * Use cached IRQ number. It might be (and is...) changed by probe * code above */ if (irqd) enable_irq(irqd); if (!hwif->present) { ide_hwif_release_regions(hwif); return; } if (fixup) fixup(hwif); for (unit = 0; unit < MAX_DRIVES; ++unit) { ide_drive_t *drive = &hwif->drives[unit]; if (drive->present) { if (drive->autotune == IDE_TUNE_AUTO) ide_set_max_pio(drive); if (drive->autotune != IDE_TUNE_DEFAULT && drive->autotune != IDE_TUNE_AUTO) continue; 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) { /* * Force DMAing for the beginning of the check. * Some chipsets appear to do interesting * things, if not checked and cleared. * PARANOIA!!! */ hwif->dma_off_quietly(drive); #ifdef CONFIG_IDEDMA_ONLYDISK if (drive->media == ide_disk) #endif ide_set_dma(drive); } } } for (unit = 0; unit < MAX_DRIVES; ++unit) { ide_drive_t *drive = &hwif->drives[unit]; if (hwif->no_io_32bit) drive->no_io_32bit = 1; else drive->no_io_32bit = drive->id->dword_io ? 1 : 0; } } static int hwif_init(ide_hwif_t *hwif); int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) { probe_hwif(hwif, fixup); if (!hwif_init(hwif)) { printk(KERN_INFO "%s: failed to initialize IDE interface\n", hwif->name); return -1; } if (hwif->present) { u16 unit = 0; int ret; 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. * * A loophole here is that we may not know about a particular * hwif's irq until after that hwif is actually probed/initialized.. * This could be a problem for the case where an hwif is on a * dual interface that requires serialization (eg. cmd640) and another * hwif using one of the same irqs is initialized beforehand. * * This routine detects and reports such situations, but does not fix them. */ static void save_match(ide_hwif_t *hwif, ide_hwif_t *new, ide_hwif_t **match) { ide_hwif_t *m = *match; if (m && m->hwgroup && m->hwgroup != new->hwgroup) { if (!new->hwgroup) return; printk("%s: potential irq problem with %s and %s\n", hwif->name, new->name, m->name); } if (!m || m->irq != hwif->irq) /* don't undo a prior perfect match */ *match = new; } #endif /* MAX_HWIFS > 1 */ /* * init request queue */ static int ide_init_queue(ide_drive_t *drive) { struct request_queue *q; ide_hwif_t *hwif = HWIF(drive); int max_sectors = 256; int max_sg_entries = PRD_ENTRIES; /* * Our default set up assumes the normal IDE case, * that is 64K segmenting, standard PRD setup * and LBA28. Some drivers then impose their own * limits and LBA48 we could raise it but as yet * do not. */ q = blk_init_queue_node(do_ide_request, &ide_lock, hwif_to_node(hwif)); if (!q) return 1; q->queuedata = drive; blk_queue_segment_boundary(q, 0xffff); if (!hwif->rqsize) { if (hwif->no_lba48 || hwif->no_lba48_dma) hwif->rqsize = 256; else hwif->rqsize = 65536; } if (hwif->rqsize < max_sectors) max_sectors = hwif->rqsize; blk_queue_max_sectors(q, max_sectors); #ifdef CONFIG_PCI /* When we have an IOMMU, we may have a problem where pci_map_sg() * creates segments that don't completely match our boundary * requirements and thus need to be broken up again. Because it * doesn't align properly either, we may actually have to break up * to more segments than what was we got in the first place, a max * worst case is twice as many. * This will be fixed once we teach pci_map_sg() about our boundary * requirements, hopefully soon. *FIXME* */ if (!PCI_DMA_BUS_IS_PHYS) max_sg_entries >>= 1; #endif /* CONFIG_PCI */ blk_queue_max_hw_segments(q, max_sg_entries); blk_queue_max_phys_segments(q, max_sg_entries); /* assign drive queue */ drive->queue = q; /* needs drive->queue to be set */ ide_toggle_bounce(drive, 1); return 0; } /* * This routine sets up the irq for an ide interface, and creates a new * hwgroup for the irq/hwif if none was previously assigned. * * Much of the code is for correctly detecting/handling irq sharing * and irq serialization situations. This is somewhat complex because * it handles static as well as dynamic (PCMCIA) IDE interfaces. * * The IRQF_DISABLED in sa_flags means ide_intr() is always entered with * interrupts completely disabled. This can be bad for interrupt latency, * but anything else has led to problems on some machines. We re-enable * interrupts as much as we can safely do in most places. */ static int init_irq (ide_hwif_t *hwif) { unsigned int index; ide_hwgroup_t *hwgroup; ide_hwif_t *match = NULL; BUG_ON(in_interrupt()); BUG_ON(irqs_disabled()); BUG_ON(hwif == NULL); mutex_lock(&ide_cfg_mtx); hwif->hwgroup = NULL; #if MAX_HWIFS > 1 /* * Group up with any other hwifs that share our irq(s). */ for (index = 0; index < MAX_HWIFS; index++) { ide_hwif_t *h = &ide_hwifs[index]; if (h->hwgroup) { /* scan only initialized hwif's */ if (hwif->irq == h->irq) { hwif->sharing_irq = h->sharing_irq = 1; if (hwif->chipset != ide_pci || h->chipset != ide_pci) { save_match(hwif, h, &match); } } if (hwif->serialized) { if (hwif->mate && hwif->mate->irq == h->irq) save_match(hwif, h, &match); } if (h->serialized) { if (h->mate && hwif->irq == h->mate->irq) save_match(hwif, h, &match); } } } #endif /* MAX_HWIFS > 1 */ /* * If we are still without a hwgroup, then form a new one */ if (match) { hwgroup = match->hwgroup; hwif->hwgroup = hwgroup; /* * Link us into the hwgroup. * This must be done early, do ensure that unexpected_intr * can find the hwif and prevent irq storms. * No drives are attached to the new hwif, choose_drive * can't do anything stupid (yet). * Add ourself as the 2nd entry to the hwgroup->hwif * linked list, the first entry is the hwif that owns * hwgroup->handler - do not change that. */ spin_lock_irq(&ide_lock); hwif->next = hwgroup->hwif->next; hwgroup->hwif->next = hwif; spin_unlock_irq(&ide_lock); } else { hwgroup = kmalloc_node(sizeof(ide_hwgroup_t), GFP_KERNEL | __GFP_ZERO, hwif_to_node(hwif->drives[0].hwif)); if (!hwgroup) goto out_up; hwif->hwgroup = hwgroup; hwgroup->hwif = hwif->next = hwif; hwgroup->rq = NULL; hwgroup->handler = NULL; hwgroup->drive = NULL; hwgroup->busy = 0; init_timer(&hwgroup->timer); hwgroup->timer.function = &ide_timer_expiry; hwgroup->timer.data = (unsigned long) hwgroup; } /* * Allocate the irq, if not already obtained for another hwif */ if (!match || match->irq != hwif->irq) { int sa = IRQF_DISABLED; #if defined(__mc68000__) || defined(CONFIG_APUS) sa = IRQF_SHARED; #endif /* __mc68000__ || CONFIG_APUS */ if (IDE_CHIPSET_IS_PCI(hwif->chipset)) { sa = IRQF_SHARED; #ifndef CONFIG_IDEPCI_SHARE_IRQ sa |= IRQF_DISABLED; #endif /* CONFIG_IDEPCI_SHARE_IRQ */ } if (hwif->io_ports[IDE_CONTROL_OFFSET]) /* clear nIEN */ hwif->OUTB(0x08, hwif->io_ports[IDE_CONTROL_OFFSET]); if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) goto out_unlink; } /* * For any present drive: * - allocate the block device queue * - link drive into the hwgroup */ for (index = 0; index < MAX_DRIVES; ++index) { ide_drive_t *drive = &hwif->drives[index]; if (!drive->present) continue; if (ide_init_queue(drive)) { printk(KERN_ERR "ide: failed to init %s\n",drive->name); continue; } spin_lock_irq(&ide_lock); if (!hwgroup->drive) { /* first drive for hwgroup. */ drive->next = drive; hwgroup->drive = drive; hwgroup->hwif = HWIF(hwgroup->drive); } else { drive->next = hwgroup->drive->next; hwgroup->drive->next = drive; } spin_unlock_irq(&ide_lock); } #if !defined(__mc68000__) && !defined(CONFIG_APUS) printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, hwif->io_ports[IDE_DATA_OFFSET], hwif->io_ports[IDE_DATA_OFFSET]+7, hwif->io_ports[IDE_CONTROL_OFFSET], hwif->irq); #else printk("%s at 0x%08lx on irq %d", hwif->name, hwif->io_ports[IDE_DATA_OFFSET], hwif->irq); #endif /* __mc68000__ && CONFIG_APUS */ if (match) printk(" (%sed with %s)", hwif->sharing_irq ? "shar" : "serializ", match->name); printk("\n"); mutex_unlock(&ide_cfg_mtx); return 0; out_unlink: spin_lock_irq(&ide_lock); if (hwif->next == hwif) { BUG_ON(match); BUG_ON(hwgroup->hwif != hwif); kfree(hwgroup); } else { ide_hwif_t *g; g = hwgroup->hwif; while (g->next != hwif) g = g->next; g->next = hwif->next; if (hwgroup->hwif == hwif) { /* Impossible. */ printk(KERN_ERR "Duh. Uninitialized hwif listed as active hwif.\n"); hwgroup->hwif = g; } BUG_ON(hwgroup->hwif == hwif); } spin_unlock_irq(&ide_lock); out_up: mutex_unlock(&ide_cfg_mtx); return 1; } static int ata_lock(dev_t dev, void *data) { /* FIXME: we want to pin hwif down */ return 0; } static struct kobject *ata_probe(dev_t dev, int *part, void *data) { ide_hwif_t *hwif = data; int unit = *part >> PARTN_BITS; ide_drive_t *drive = &hwif->drives[unit]; if (!drive->present) return NULL; if (drive->media == ide_disk) request_module("ide-disk"); if (drive->scsi) request_module("ide-scsi"); if (drive->media == ide_cdrom || drive->media == ide_optical) request_module("ide-cd"); if (drive->media == ide_tape) request_module("ide-tape"); if (drive->media == ide_floppy) request_module("ide-floppy"); return NULL; } static struct kobject *exact_match(dev_t dev, int *part, void *data) { struct gendisk *p = data; *part &= (1 << PARTN_BITS) - 1; return &p->kobj; } static int exact_lock(dev_t dev, void *data) { struct gendisk *p = data; if (!get_disk(p)) return -1; return 0; } void ide_register_region(struct gendisk *disk) { blk_register_region(MKDEV(disk->major, disk->first_minor), disk->minors, NULL, exact_match, exact_lock, disk); } EXPORT_SYMBOL_GPL(ide_register_region); void ide_unregister_region(struct gendisk *disk) { blk_unregister_region(MKDEV(disk->major, disk->first_minor), disk->minors); } EXPORT_SYMBOL_GPL(ide_unregister_region); void ide_init_disk(struct gendisk *disk, ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; unsigned int unit = (drive->select.all >> 4) & 1; disk->major = hwif->major; disk->first_minor = unit << PARTN_BITS; sprintf(disk->disk_name, "hd%c", 'a' + hwif->index * MAX_DRIVES + unit); disk->queue = drive->queue; } EXPORT_SYMBOL_GPL(ide_init_disk); static void ide_remove_drive_from_hwgroup(ide_drive_t *drive) { ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; if (drive == drive->next) { /* special case: last drive from hwgroup. */ BUG_ON(hwgroup->drive != drive); hwgroup->drive = NULL; } else { ide_drive_t *walk; walk = hwgroup->drive; while (walk->next != drive) walk = walk->next; walk->next = drive->next; if (hwgroup->drive == drive) { hwgroup->drive = drive->next; hwgroup->hwif = hwgroup->drive->hwif; } } BUG_ON(hwgroup->drive == drive); } static void drive_release_dev (struct device *dev) { ide_drive_t *drive = container_of(dev, ide_drive_t, gendev); spin_lock_irq(&ide_lock); ide_remove_drive_from_hwgroup(drive); kfree(drive->id); drive->id = NULL; drive->present = 0; /* Messed up locking ... */ spin_unlock_irq(&ide_lock); blk_cleanup_queue(drive->queue); spin_lock_irq(&ide_lock); drive->queue = NULL; spin_unlock_irq(&ide_lock); complete(&drive->gendev_rel_comp); } /* * init_gendisk() (as opposed to ide_geninit) is called for each major device, * after probing for drives, to allocate partition tables and other data * structures needed for the routines in genhd.c. ide_geninit() gets called * somewhat later, during the partition check. */ static void init_gendisk (ide_hwif_t *hwif) { unsigned int unit; for (unit = 0; unit < MAX_DRIVES; ++unit) { ide_drive_t * drive = &hwif->drives[unit]; ide_add_generic_settings(drive); snprintf(drive->gendev.bus_id,BUS_ID_SIZE,"%u.%u", hwif->index,unit); drive->gendev.parent = &hwif->gendev; drive->gendev.bus = &ide_bus_type; drive->gendev.driver_data = drive; drive->gendev.release = drive_release_dev; } blk_register_region(MKDEV(hwif->major, 0), MAX_DRIVES << PARTN_BITS, THIS_MODULE, ata_probe, ata_lock, hwif); } static int hwif_init(ide_hwif_t *hwif) { int old_irq; /* Return success if no device is connected */ if (!hwif->present) return 1; if (!hwif->irq) { if (!(hwif->irq = ide_default_irq(hwif->io_ports[IDE_DATA_OFFSET]))) { printk("%s: DISABLED, NO IRQ\n", hwif->name); return (hwif->present = 0); } } #ifdef CONFIG_BLK_DEV_HD if (hwif->irq == HD_IRQ && hwif->io_ports[IDE_DATA_OFFSET] != HD_DATA) { printk("%s: CANNOT SHARE IRQ WITH OLD " "HARDDISK DRIVER (hd.c)\n", hwif->name); return (hwif->present = 0); } #endif /* CONFIG_BLK_DEV_HD */