2 * linux/drivers/ide/ide.c Version 7.00beta2 Mar 05 2003
4 * Copyright (C) 1994-1998 Linus Torvalds & authors (see below)
8 * Mostly written by Mark Lord <mlord@pobox.com>
9 * and Gadi Oxman <gadio@netvision.net.il>
10 * and Andre Hedrick <andre@linux-ide.org>
12 * See linux/MAINTAINERS for address of current maintainer.
14 * This is the multiple IDE interface driver, as evolved from hd.c.
15 * It supports up to MAX_HWIFS IDE interfaces, on one or more IRQs
17 * There can be up to two drives per interface, as per the ATA-2 spec.
19 * Primary: ide0, port 0x1f0; major=3; hda is minor=0; hdb is minor=64
20 * Secondary: ide1, port 0x170; major=22; hdc is minor=0; hdd is minor=64
21 * Tertiary: ide2, port 0x???; major=33; hde is minor=0; hdf is minor=64
22 * Quaternary: ide3, port 0x???; major=34; hdg is minor=0; hdh is minor=64
27 * | It traverses the request-list, using interrupts to jump between functions.
28 * | As nearly all functions can be called within interrupts, we may not sleep.
29 * | Special care is recommended. Have Fun!
31 * | modified by Drew Eckhardt to check nr of hd's from the CMOS.
33 * | Thanks to Branko Lankester, lankeste@fwi.uva.nl, who found a bug
34 * | in the early extended-partition checks and added DM partitions.
36 * | Early work on error handling by Mika Liljeberg (liljeber@cs.Helsinki.FI).
38 * | IRQ-unmask, drive-id, multiple-mode, support for ">16 heads",
39 * | and general streamlining by Mark Lord (mlord@pobox.com).
41 * October, 1994 -- Complete line-by-line overhaul for linux 1.1.x, by:
43 * Mark Lord (mlord@pobox.com) (IDE Perf.Pkg)
44 * Delman Lee (delman@ieee.org) ("Mr. atdisk2")
45 * Scott Snyder (snyder@fnald0.fnal.gov) (ATAPI IDE cd-rom)
47 * This was a rewrite of just about everything from hd.c, though some original
48 * code is still sprinkled about. Think of it as a major evolution, with
49 * inspiration from lots of linux users, esp. hamish@zot.apana.org.au
51 * Version 1.0 ALPHA initial code, primary i/f working okay
52 * Version 1.3 BETA dual i/f on shared irq tested & working!
53 * Version 1.4 BETA added auto probing for irq(s)
54 * Version 1.5 BETA added ALPHA (untested) support for IDE cd-roms,
56 * Version 5.50 allow values as small as 20 for idebus=
57 * Version 5.51 force non io_32bit in drive_cmd_intr()
58 * change delay_10ms() to delay_50ms() to fix problems
59 * Version 5.52 fix incorrect invalidation of removable devices
60 * add "hdx=slow" command line option
61 * Version 5.60 start to modularize the driver; the disk and ATAPI
62 * drivers can be compiled as loadable modules.
63 * move IDE probe code to ide-probe.c
64 * move IDE disk code to ide-disk.c
65 * add support for generic IDE device subdrivers
66 * add m68k code from Geert Uytterhoeven
67 * probe all interfaces by default
68 * add ioctl to (re)probe an interface
69 * Version 6.00 use per device request queues
70 * attempt to optimize shared hwgroup performance
71 * add ioctl to manually adjust bandwidth algorithms
72 * add kerneld support for the probe module
73 * fix bug in ide_error()
74 * fix bug in the first ide_get_lock() call for Atari
75 * don't flush leftover data for ATAPI devices
76 * Version 6.01 clear hwgroup->active while the hwgroup sleeps
77 * support HDIO_GETGEO for floppies
78 * Version 6.02 fix ide_ack_intr() call
79 * check partition table on floppies
80 * Version 6.03 handle bad status bit sequencing in ide_wait_stat()
81 * Version 6.10 deleted old entries from this list of updates
82 * replaced triton.c with ide-dma.c generic PCI DMA
83 * added support for BIOS-enabled UltraDMA
84 * rename all "promise" things to "pdc4030"
85 * fix EZ-DRIVE handling on small disks
86 * Version 6.11 fix probe error in ide_scan_devices()
87 * fix ancient "jiffies" polling bugs
88 * mask all hwgroup interrupts on each irq entry
89 * Version 6.12 integrate ioctl and proc interfaces
90 * fix parsing of "idex=" command line parameter
91 * Version 6.13 add support for ide4/ide5 courtesy rjones@orchestream.com
92 * Version 6.14 fixed IRQ sharing among PCI devices
93 * Version 6.15 added SMP awareness to IDE drivers
94 * Version 6.16 fixed various bugs; even more SMP friendly
95 * Version 6.17 fix for newest EZ-Drive problem
96 * Version 6.18 default unpartitioned-disk translation now "BIOS LBA"
97 * Version 6.19 Re-design for a UNIFORM driver for all platforms,
98 * model based on suggestions from Russell King and
100 * Promise DC4030VL now supported.
101 * add support for ide6/ide7
102 * delay_50ms() changed to ide_delay_50ms() and exported.
103 * Version 6.20 Added/Fixed Generic ATA-66 support and hwif detection.
104 * Added hdx=flash to allow for second flash disk
105 * detection w/o the hang loop.
106 * Added support for ide8/ide9
107 * Added idex=ata66 for the quirky chipsets that are
108 * ATA-66 compliant, but have yet to determine a method
109 * of verification of the 80c cable presence.
110 * Specifically Promise's PDC20262 chipset.
111 * Version 6.21 Fixing/Fixed SMP spinlock issue with insight from an old
112 * hat that clarified original low level driver design.
113 * Version 6.30 Added SMP support; fixed multmode issues. -ml
114 * Version 6.31 Debug Share INTR's and request queue streaming
115 * Native ATA-100 support
116 * Prep for Cascades Project
117 * Version 7.00alpha First named revision of ide rearrange
119 * Some additional driver compile-time options are in ./include/linux/ide.h
121 * To do, in likely order of completion:
122 * - modify kernel to obtain BIOS geometry for drives on 2nd/3rd/4th i/f
126 #define REVISION "Revision: 7.00alpha2"
127 #define VERSION "Id: ide.c 7.00a2 20020906"
129 #undef REALLY_SLOW_IO /* most systems can safely undef this */
131 #define _IDE_C /* Tell ide.h it's really us */
133 #include <linux/config.h>
134 #include <linux/module.h>
135 #include <linux/types.h>
136 #include <linux/string.h>
137 #include <linux/kernel.h>
138 #include <linux/timer.h>
139 #include <linux/mm.h>
140 #include <linux/interrupt.h>
141 #include <linux/major.h>
142 #include <linux/errno.h>
143 #include <linux/genhd.h>
144 #include <linux/blkpg.h>
145 #include <linux/slab.h>
146 #include <linux/init.h>
147 #include <linux/pci.h>
148 #include <linux/delay.h>
149 #include <linux/ide.h>
150 #include <linux/devfs_fs_kernel.h>
151 #include <linux/completion.h>
152 #include <linux/reboot.h>
153 #include <linux/cdrom.h>
154 #include <linux/seq_file.h>
155 #include <linux/device.h>
156 #include <linux/bitops.h>
158 #include <asm/byteorder.h>
160 #include <asm/uaccess.h>
164 /* default maximum number of failures */
165 #define IDE_DEFAULT_MAX_FAILURES 1
167 static const u8 ide_hwif_to_major
[] = { IDE0_MAJOR
, IDE1_MAJOR
,
168 IDE2_MAJOR
, IDE3_MAJOR
,
169 IDE4_MAJOR
, IDE5_MAJOR
,
170 IDE6_MAJOR
, IDE7_MAJOR
,
171 IDE8_MAJOR
, IDE9_MAJOR
};
173 static int idebus_parameter
; /* holds the "idebus=" parameter */
174 static int system_bus_speed
; /* holds what we think is VESA/PCI bus speed */
175 static int initializing
; /* set while initializing built-in drivers */
177 DECLARE_MUTEX(ide_cfg_sem
);
178 __cacheline_aligned_in_smp
DEFINE_SPINLOCK(ide_lock
);
180 #ifdef CONFIG_BLK_DEV_IDEPCI
181 static int ide_scan_direction
; /* THIS was formerly 2.2.x pci=reverse */
184 #ifdef CONFIG_IDEDMA_AUTO
190 EXPORT_SYMBOL(noautodma
);
193 * This is declared extern in ide.h, for access by other IDE modules:
195 ide_hwif_t ide_hwifs
[MAX_HWIFS
]; /* master data repository */
197 EXPORT_SYMBOL(ide_hwifs
);
199 static struct list_head ide_drives
= LIST_HEAD_INIT(ide_drives
);
202 * Do not even *think* about calling this!
204 static void init_hwif_data(ide_hwif_t
*hwif
, unsigned int index
)
208 /* bulk initialize hwif & drive info with zeros */
209 memset(hwif
, 0, sizeof(ide_hwif_t
));
211 /* fill in any non-zero initial values */
213 hwif
->major
= ide_hwif_to_major
[index
];
218 hwif
->name
[3] = '0' + index
;
220 hwif
->bus_state
= BUSSTATE_ON
;
222 hwif
->atapi_dma
= 0; /* disable all atapi dma */
223 hwif
->ultra_mask
= 0x80; /* disable all ultra */
224 hwif
->mwdma_mask
= 0x80; /* disable all mwdma */
225 hwif
->swdma_mask
= 0x80; /* disable all swdma */
227 sema_init(&hwif
->gendev_rel_sem
, 0);
229 default_hwif_iops(hwif
);
230 default_hwif_transport(hwif
);
231 for (unit
= 0; unit
< MAX_DRIVES
; ++unit
) {
232 ide_drive_t
*drive
= &hwif
->drives
[unit
];
234 drive
->media
= ide_disk
;
235 drive
->select
.all
= (unit
<<4)|0xa0;
238 drive
->ready_stat
= READY_STAT
;
239 drive
->bad_wstat
= BAD_W_STAT
;
240 drive
->special
.b
.recalibrate
= 1;
241 drive
->special
.b
.set_geometry
= 1;
242 drive
->name
[0] = 'h';
243 drive
->name
[1] = 'd';
244 drive
->name
[2] = 'a' + (index
* MAX_DRIVES
) + unit
;
245 drive
->max_failures
= IDE_DEFAULT_MAX_FAILURES
;
246 drive
->using_dma
= 0;
249 INIT_LIST_HEAD(&drive
->list
);
250 sema_init(&drive
->gendev_rel_sem
, 0);
254 static void init_hwif_default(ide_hwif_t
*hwif
, unsigned int index
)
258 memset(&hw
, 0, sizeof(hw_regs_t
));
260 ide_init_hwif_ports(&hw
, ide_default_io_base(index
), 0, &hwif
->irq
);
262 memcpy(&hwif
->hw
, &hw
, sizeof(hw
));
263 memcpy(hwif
->io_ports
, hw
.io_ports
, sizeof(hw
.io_ports
));
265 hwif
->noprobe
= !hwif
->io_ports
[IDE_DATA_OFFSET
];
266 #ifdef CONFIG_BLK_DEV_HD
267 if (hwif
->io_ports
[IDE_DATA_OFFSET
] == HD_DATA
)
268 hwif
->noprobe
= 1; /* may be overridden by ide_setup() */
272 extern void ide_arm_init(void);
275 * init_ide_data() sets reasonable default values into all fields
276 * of all instances of the hwifs and drives, but only on the first call.
277 * Subsequent calls have no effect (they don't wipe out anything).
279 * This routine is normally called at driver initialization time,
280 * but may also be called MUCH earlier during kernel "command-line"
281 * parameter processing. As such, we cannot depend on any other parts
282 * of the kernel (such as memory allocation) to be functioning yet.
284 * This is too bad, as otherwise we could dynamically allocate the
285 * ide_drive_t structs as needed, rather than always consuming memory
286 * for the max possible number (MAX_HWIFS * MAX_DRIVES) of them.
288 * FIXME: We should stuff the setup data into __init and copy the
289 * relevant hwifs/allocate them properly during boot.
291 #define MAGIC_COOKIE 0x12345678
292 static void __init
init_ide_data (void)
296 static unsigned long magic_cookie
= MAGIC_COOKIE
;
298 if (magic_cookie
!= MAGIC_COOKIE
)
299 return; /* already initialized */
302 /* Initialise all interface structures */
303 for (index
= 0; index
< MAX_HWIFS
; ++index
) {
304 hwif
= &ide_hwifs
[index
];
305 init_hwif_data(hwif
, index
);
306 init_hwif_default(hwif
, index
);
307 #if !defined(CONFIG_PPC32) || !defined(CONFIG_PCI)
308 hwif
->irq
= hwif
->hw
.irq
=
309 ide_init_default_irq(hwif
->io_ports
[IDE_DATA_OFFSET
]);
312 #ifdef CONFIG_IDE_ARM
320 * ide_system_bus_speed - guess bus speed
322 * ide_system_bus_speed() returns what we think is the system VESA/PCI
323 * bus speed (in MHz). This is used for calculating interface PIO timings.
324 * The default is 40 for known PCI systems, 50 otherwise.
325 * The "idebus=xx" parameter can be used to override this value.
326 * The actual value to be used is computed/displayed the first time
327 * through. Drivers should only use this as a last resort.
329 * Returns a guessed speed in MHz.
332 static int ide_system_bus_speed(void)
335 static struct pci_device_id pci_default
[] = {
336 { PCI_DEVICE(PCI_ANY_ID
, PCI_ANY_ID
) },
340 #define pci_default 0
341 #endif /* CONFIG_PCI */
343 if (!system_bus_speed
) {
344 if (idebus_parameter
) {
345 /* user supplied value */
346 system_bus_speed
= idebus_parameter
;
347 } else if (pci_dev_present(pci_default
)) {
348 /* safe default value for PCI */
349 system_bus_speed
= 33;
351 /* safe default value for VESA and PCI */
352 system_bus_speed
= 50;
354 printk(KERN_INFO
"ide: Assuming %dMHz system bus speed "
355 "for PIO modes%s\n", system_bus_speed
,
356 idebus_parameter
? "" : "; override with idebus=xx");
358 return system_bus_speed
;
362 * drives_lock protects the list of drives, drivers_lock the
363 * list of drivers. Currently nobody takes both at once.
366 static DEFINE_SPINLOCK(drives_lock
);
367 static DEFINE_SPINLOCK(drivers_lock
);
368 static LIST_HEAD(drivers
);
370 /* Iterator for the driver list. */
372 static void *m_start(struct seq_file
*m
, loff_t
*pos
)
376 spin_lock(&drivers_lock
);
377 list_for_each(p
, &drivers
)
379 return list_entry(p
, ide_driver_t
, drivers
);
383 static void *m_next(struct seq_file
*m
, void *v
, loff_t
*pos
)
385 struct list_head
*p
= ((ide_driver_t
*)v
)->drivers
.next
;
387 return p
==&drivers
? NULL
: list_entry(p
, ide_driver_t
, drivers
);
390 static void m_stop(struct seq_file
*m
, void *v
)
392 spin_unlock(&drivers_lock
);
395 static int show_driver(struct seq_file
*m
, void *v
)
397 ide_driver_t
*driver
= v
;
398 seq_printf(m
, "%s version %s\n", driver
->name
, driver
->version
);
402 struct seq_operations ide_drivers_op
= {
409 #ifdef CONFIG_PROC_FS
410 struct proc_dir_entry
*proc_ide_root
;
413 static struct resource
* hwif_request_region(ide_hwif_t
*hwif
,
414 unsigned long addr
, int num
)
416 struct resource
*res
= request_region(addr
, num
, hwif
->name
);
419 printk(KERN_ERR
"%s: I/O resource 0x%lX-0x%lX not free.\n",
420 hwif
->name
, addr
, addr
+num
-1);
425 * ide_hwif_request_regions - request resources for IDE
426 * @hwif: interface to use
428 * Requests all the needed resources for an interface.
429 * Right now core IDE code does this work which is deeply wrong.
430 * MMIO leaves it to the controller driver,
431 * PIO will migrate this way over time.
434 int ide_hwif_request_regions(ide_hwif_t
*hwif
)
441 BUG_ON(hwif
->mmio
== 1);
442 addr
= hwif
->io_ports
[IDE_CONTROL_OFFSET
];
443 if (addr
&& !hwif_request_region(hwif
, addr
, 1))
444 goto control_region_busy
;
446 addr
= hwif
->io_ports
[IDE_DATA_OFFSET
];
447 if ((addr
| 7) == hwif
->io_ports
[IDE_STATUS_OFFSET
]) {
448 if (!hwif_request_region(hwif
, addr
, 8))
449 goto data_region_busy
;
453 for (i
= IDE_DATA_OFFSET
; i
<= IDE_STATUS_OFFSET
; i
++) {
454 addr
= hwif
->io_ports
[i
];
455 if (!hwif_request_region(hwif
, addr
, 1)) {
457 release_region(addr
, 1);
458 goto data_region_busy
;
464 addr
= hwif
->io_ports
[IDE_CONTROL_OFFSET
];
466 release_region(addr
, 1);
468 /* If any errors are return, we drop the hwif interface. */
473 * ide_hwif_release_regions - free IDE resources
475 * Note that we only release the standard ports,
476 * and do not even try to handle any extra ports
477 * allocated for weird IDE interface chipsets.
479 * Note also that we don't yet handle mmio resources here. More
480 * importantly our caller should be doing this so we need to
481 * restructure this as a helper function for drivers.
484 void ide_hwif_release_regions(ide_hwif_t
*hwif
)
490 if (hwif
->io_ports
[IDE_CONTROL_OFFSET
])
491 release_region(hwif
->io_ports
[IDE_CONTROL_OFFSET
], 1);
492 if (hwif
->straight8
) {
493 release_region(hwif
->io_ports
[IDE_DATA_OFFSET
], 8);
496 for (i
= IDE_DATA_OFFSET
; i
<= IDE_STATUS_OFFSET
; i
++)
497 if (hwif
->io_ports
[i
])
498 release_region(hwif
->io_ports
[i
], 1);
502 * ide_hwif_restore - restore hwif to template
503 * @hwif: hwif to update
504 * @tmp_hwif: template
506 * Restore hwif to a previous state by copying most settngs
510 static void ide_hwif_restore(ide_hwif_t
*hwif
, ide_hwif_t
*tmp_hwif
)
512 hwif
->hwgroup
= tmp_hwif
->hwgroup
;
514 hwif
->gendev
.parent
= tmp_hwif
->gendev
.parent
;
516 hwif
->proc
= tmp_hwif
->proc
;
518 hwif
->major
= tmp_hwif
->major
;
519 hwif
->straight8
= tmp_hwif
->straight8
;
520 hwif
->bus_state
= tmp_hwif
->bus_state
;
522 hwif
->atapi_dma
= tmp_hwif
->atapi_dma
;
523 hwif
->ultra_mask
= tmp_hwif
->ultra_mask
;
524 hwif
->mwdma_mask
= tmp_hwif
->mwdma_mask
;
525 hwif
->swdma_mask
= tmp_hwif
->swdma_mask
;
527 hwif
->chipset
= tmp_hwif
->chipset
;
528 hwif
->hold
= tmp_hwif
->hold
;
530 #ifdef CONFIG_BLK_DEV_IDEPCI
531 hwif
->pci_dev
= tmp_hwif
->pci_dev
;
532 hwif
->cds
= tmp_hwif
->cds
;
535 hwif
->tuneproc
= tmp_hwif
->tuneproc
;
536 hwif
->speedproc
= tmp_hwif
->speedproc
;
537 hwif
->selectproc
= tmp_hwif
->selectproc
;
538 hwif
->reset_poll
= tmp_hwif
->reset_poll
;
539 hwif
->pre_reset
= tmp_hwif
->pre_reset
;
540 hwif
->resetproc
= tmp_hwif
->resetproc
;
541 hwif
->intrproc
= tmp_hwif
->intrproc
;
542 hwif
->maskproc
= tmp_hwif
->maskproc
;
543 hwif
->quirkproc
= tmp_hwif
->quirkproc
;
544 hwif
->busproc
= tmp_hwif
->busproc
;
546 hwif
->ata_input_data
= tmp_hwif
->ata_input_data
;
547 hwif
->ata_output_data
= tmp_hwif
->ata_output_data
;
548 hwif
->atapi_input_bytes
= tmp_hwif
->atapi_input_bytes
;
549 hwif
->atapi_output_bytes
= tmp_hwif
->atapi_output_bytes
;
551 hwif
->dma_setup
= tmp_hwif
->dma_setup
;
552 hwif
->dma_exec_cmd
= tmp_hwif
->dma_exec_cmd
;
553 hwif
->dma_start
= tmp_hwif
->dma_start
;
554 hwif
->ide_dma_end
= tmp_hwif
->ide_dma_end
;
555 hwif
->ide_dma_check
= tmp_hwif
->ide_dma_check
;
556 hwif
->ide_dma_on
= tmp_hwif
->ide_dma_on
;
557 hwif
->ide_dma_off_quietly
= tmp_hwif
->ide_dma_off_quietly
;
558 hwif
->ide_dma_test_irq
= tmp_hwif
->ide_dma_test_irq
;
559 hwif
->ide_dma_host_on
= tmp_hwif
->ide_dma_host_on
;
560 hwif
->ide_dma_host_off
= tmp_hwif
->ide_dma_host_off
;
561 hwif
->ide_dma_lostirq
= tmp_hwif
->ide_dma_lostirq
;
562 hwif
->ide_dma_timeout
= tmp_hwif
->ide_dma_timeout
;
564 hwif
->OUTB
= tmp_hwif
->OUTB
;
565 hwif
->OUTBSYNC
= tmp_hwif
->OUTBSYNC
;
566 hwif
->OUTW
= tmp_hwif
->OUTW
;
567 hwif
->OUTL
= tmp_hwif
->OUTL
;
568 hwif
->OUTSW
= tmp_hwif
->OUTSW
;
569 hwif
->OUTSL
= tmp_hwif
->OUTSL
;
571 hwif
->INB
= tmp_hwif
->INB
;
572 hwif
->INW
= tmp_hwif
->INW
;
573 hwif
->INL
= tmp_hwif
->INL
;
574 hwif
->INSW
= tmp_hwif
->INSW
;
575 hwif
->INSL
= tmp_hwif
->INSL
;
577 hwif
->sg_max_nents
= tmp_hwif
->sg_max_nents
;
579 hwif
->mmio
= tmp_hwif
->mmio
;
580 hwif
->rqsize
= tmp_hwif
->rqsize
;
581 hwif
->no_lba48
= tmp_hwif
->no_lba48
;
583 #ifndef CONFIG_BLK_DEV_IDECS
584 hwif
->irq
= tmp_hwif
->irq
;
587 hwif
->dma_base
= tmp_hwif
->dma_base
;
588 hwif
->dma_master
= tmp_hwif
->dma_master
;
589 hwif
->dma_command
= tmp_hwif
->dma_command
;
590 hwif
->dma_vendor1
= tmp_hwif
->dma_vendor1
;
591 hwif
->dma_status
= tmp_hwif
->dma_status
;
592 hwif
->dma_vendor3
= tmp_hwif
->dma_vendor3
;
593 hwif
->dma_prdtable
= tmp_hwif
->dma_prdtable
;
595 hwif
->dma_extra
= tmp_hwif
->dma_extra
;
596 hwif
->config_data
= tmp_hwif
->config_data
;
597 hwif
->select_data
= tmp_hwif
->select_data
;
598 hwif
->autodma
= tmp_hwif
->autodma
;
599 hwif
->udma_four
= tmp_hwif
->udma_four
;
600 hwif
->no_dsc
= tmp_hwif
->no_dsc
;
602 hwif
->hwif_data
= tmp_hwif
->hwif_data
;
606 * ide_unregister - free an ide interface
607 * @index: index of interface (will change soon to a pointer)
609 * Perform the final unregister of an IDE interface. At the moment
610 * we don't refcount interfaces so this will also get split up.
613 * The caller must not hold the IDE locks
614 * The drive present/vanishing is not yet properly locked
615 * Take care with the callbacks. These have been split to avoid
616 * deadlocking the IDE layer. The shutdown callback is called
617 * before we take the lock and free resources. It is up to the
618 * caller to be sure there is no pending I/O here, and that
619 * the interfce will not be reopened (present/vanishing locking
620 * isnt yet done btw). After we commit to the final kill we
621 * call the cleanup callback with the ide locks held.
623 * Unregister restores the hwif structures to the default state.
624 * This is raving bonkers.
627 void ide_unregister(unsigned int index
)
630 ide_hwif_t
*hwif
, *g
;
631 static ide_hwif_t tmp_hwif
; /* protected by ide_cfg_sem */
632 ide_hwgroup_t
*hwgroup
;
633 int irq_count
= 0, unit
, i
;
635 BUG_ON(index
>= MAX_HWIFS
);
637 BUG_ON(in_interrupt());
638 BUG_ON(irqs_disabled());
640 spin_lock_irq(&ide_lock
);
641 hwif
= &ide_hwifs
[index
];
644 for (unit
= 0; unit
< MAX_DRIVES
; ++unit
) {
645 drive
= &hwif
->drives
[unit
];
648 if (drive
->usage
|| DRIVER(drive
)->busy
)
654 spin_unlock_irq(&ide_lock
);
656 for (unit
= 0; unit
< MAX_DRIVES
; ++unit
) {
657 drive
= &hwif
->drives
[unit
];
660 DRIVER(drive
)->cleanup(drive
);
663 destroy_proc_ide_interface(hwif
);
665 hwgroup
= hwif
->hwgroup
;
667 * free the irq if we were the only hwif using it
671 if (g
->irq
== hwif
->irq
)
674 } while (g
!= hwgroup
->hwif
);
676 free_irq(hwif
->irq
, hwgroup
);
678 spin_lock_irq(&ide_lock
);
680 * Note that we only release the standard ports,
681 * and do not even try to handle any extra ports
682 * allocated for weird IDE interface chipsets.
684 ide_hwif_release_regions(hwif
);
687 * Remove us from the hwgroup, and free
688 * the hwgroup if we were the only member
690 for (i
= 0; i
< MAX_DRIVES
; ++i
) {
691 drive
= &hwif
->drives
[i
];
692 if (drive
->devfs_name
[0] != '\0') {
693 devfs_remove(drive
->devfs_name
);
694 drive
->devfs_name
[0] = '\0';
698 if (drive
== drive
->next
) {
699 /* special case: last drive from hwgroup. */
700 BUG_ON(hwgroup
->drive
!= drive
);
701 hwgroup
->drive
= NULL
;
705 walk
= hwgroup
->drive
;
706 while (walk
->next
!= drive
)
708 walk
->next
= drive
->next
;
709 if (hwgroup
->drive
== drive
) {
710 hwgroup
->drive
= drive
->next
;
711 hwgroup
->hwif
= HWIF(hwgroup
->drive
);
714 BUG_ON(hwgroup
->drive
== drive
);
715 if (drive
->id
!= NULL
) {
720 /* Messed up locking ... */
721 spin_unlock_irq(&ide_lock
);
722 blk_cleanup_queue(drive
->queue
);
723 device_unregister(&drive
->gendev
);
724 down(&drive
->gendev_rel_sem
);
725 spin_lock_irq(&ide_lock
);
728 if (hwif
->next
== hwif
) {
729 BUG_ON(hwgroup
->hwif
!= hwif
);
732 /* There is another interface in hwgroup.
733 * Unlink us, and set hwgroup->drive and ->hwif to
737 while (g
->next
!= hwif
)
739 g
->next
= hwif
->next
;
740 if (hwgroup
->hwif
== hwif
) {
741 /* Chose a random hwif for hwgroup->hwif.
742 * It's guaranteed that there are no drives
743 * left in the hwgroup.
745 BUG_ON(hwgroup
->drive
!= NULL
);
748 BUG_ON(hwgroup
->hwif
== hwif
);
751 /* More messed up locking ... */
752 spin_unlock_irq(&ide_lock
);
753 device_unregister(&hwif
->gendev
);
754 down(&hwif
->gendev_rel_sem
);
757 * Remove us from the kernel's knowledge
759 blk_unregister_region(MKDEV(hwif
->major
, 0), MAX_DRIVES
<<PARTN_BITS
);
760 kfree(hwif
->sg_table
);
761 unregister_blkdev(hwif
->major
, hwif
->name
);
762 spin_lock_irq(&ide_lock
);
764 if (hwif
->dma_base
) {
765 (void) ide_release_dma(hwif
);
768 hwif
->dma_master
= 0;
769 hwif
->dma_command
= 0;
770 hwif
->dma_vendor1
= 0;
771 hwif
->dma_status
= 0;
772 hwif
->dma_vendor3
= 0;
773 hwif
->dma_prdtable
= 0;
776 /* copy original settings */
779 /* restore hwif data to pristine status */
780 init_hwif_data(hwif
, index
);
781 init_hwif_default(hwif
, index
);
783 ide_hwif_restore(hwif
, &tmp_hwif
);
786 spin_unlock_irq(&ide_lock
);
790 EXPORT_SYMBOL(ide_unregister
);
794 * ide_setup_ports - set up IDE interface ports
795 * @hw: register descriptions
796 * @base: base register
797 * @offsets: table of register offsets
798 * @ctrl: control register
800 * @irq: interrupt lie
802 * Setup hw_regs_t structure described by parameters. You
803 * may set up the hw structure yourself OR use this routine to
804 * do it for you. This is basically a helper
808 void ide_setup_ports ( hw_regs_t
*hw
,
809 unsigned long base
, int *offsets
,
810 unsigned long ctrl
, unsigned long intr
,
811 ide_ack_intr_t
*ack_intr
,
813 * ide_io_ops_t *iops,
819 for (i
= 0; i
< IDE_NR_PORTS
; i
++) {
820 if (offsets
[i
] == -1) {
822 case IDE_CONTROL_OFFSET
:
823 hw
->io_ports
[i
] = ctrl
;
825 #if defined(CONFIG_AMIGA) || defined(CONFIG_MAC)
827 hw
->io_ports
[i
] = intr
;
829 #endif /* (CONFIG_AMIGA) || (CONFIG_MAC) */
835 hw
->io_ports
[i
] = base
+ offsets
[i
];
840 hw
->ack_intr
= ack_intr
;
847 * ide_register_hw_with_fixup - register IDE interface
848 * @hw: hardware registers
849 * @hwifp: pointer to returned hwif
850 * @fixup: fixup function
852 * Register an IDE interface, specifying exactly the registers etc.
853 * Set init=1 iff calling before probes have taken place.
855 * Returns -1 on error.
858 int ide_register_hw_with_fixup(hw_regs_t
*hw
, ide_hwif_t
**hwifp
, void(*fixup
)(ide_hwif_t
*hwif
))
860 int index
, retry
= 1;
864 for (index
= 0; index
< MAX_HWIFS
; ++index
) {
865 hwif
= &ide_hwifs
[index
];
866 if (hwif
->hw
.io_ports
[IDE_DATA_OFFSET
] == hw
->io_ports
[IDE_DATA_OFFSET
])
869 for (index
= 0; index
< MAX_HWIFS
; ++index
) {
870 hwif
= &ide_hwifs
[index
];
873 if ((!hwif
->present
&& !hwif
->mate
&& !initializing
) ||
874 (!hwif
->hw
.io_ports
[IDE_DATA_OFFSET
] && initializing
))
877 for (index
= 0; index
< MAX_HWIFS
; index
++)
878 ide_unregister(index
);
883 ide_unregister(index
);
884 else if (!hwif
->hold
) {
885 init_hwif_data(hwif
, index
);
886 init_hwif_default(hwif
, index
);
890 memcpy(&hwif
->hw
, hw
, sizeof(*hw
));
891 memcpy(hwif
->io_ports
, hwif
->hw
.io_ports
, sizeof(hwif
->hw
.io_ports
));
894 hwif
->chipset
= hw
->chipset
;
897 probe_hwif_init_with_fixup(hwif
, fixup
);
898 create_proc_ide_interfaces();
904 return (initializing
|| hwif
->present
) ? index
: -1;
907 EXPORT_SYMBOL(ide_register_hw_with_fixup
);
909 int ide_register_hw(hw_regs_t
*hw
, ide_hwif_t
**hwifp
)
911 return ide_register_hw_with_fixup(hw
, hwifp
, NULL
);
914 EXPORT_SYMBOL(ide_register_hw
);
917 * Locks for IDE setting functionality
920 DECLARE_MUTEX(ide_setting_sem
);
923 * __ide_add_setting - add an ide setting option
924 * @drive: drive to use
925 * @name: setting name
926 * @rw: true if the function is read write
927 * @read_ioctl: function to call on read
928 * @write_ioctl: function to call on write
929 * @data_type: type of data
930 * @min: range minimum
931 * @max: range maximum
932 * @mul_factor: multiplication scale
933 * @div_factor: divison scale
934 * @data: private data field
936 * @auto_remove: setting auto removal flag
938 * Removes the setting named from the device if it is present.
939 * The function takes the settings_lock to protect against
940 * parallel changes. This function must not be called from IRQ
941 * context. Returns 0 on success or -1 on failure.
943 * BUGS: This code is seriously over-engineered. There is also
944 * magic about how the driver specific features are setup. If
945 * a driver is attached we assume the driver settings are auto
949 static int __ide_add_setting(ide_drive_t
*drive
, const char *name
, int rw
, int read_ioctl
, int write_ioctl
, int data_type
, int min
, int max
, int mul_factor
, int div_factor
, void *data
, ide_procset_t
*set
, int auto_remove
)
951 ide_settings_t
**p
= (ide_settings_t
**) &drive
->settings
, *setting
= NULL
;
953 down(&ide_setting_sem
);
954 while ((*p
) && strcmp((*p
)->name
, name
) < 0)
956 if ((setting
= kmalloc(sizeof(*setting
), GFP_KERNEL
)) == NULL
)
958 memset(setting
, 0, sizeof(*setting
));
959 if ((setting
->name
= kmalloc(strlen(name
) + 1, GFP_KERNEL
)) == NULL
)
961 strcpy(setting
->name
, name
);
963 setting
->read_ioctl
= read_ioctl
;
964 setting
->write_ioctl
= write_ioctl
;
965 setting
->data_type
= data_type
;
968 setting
->mul_factor
= mul_factor
;
969 setting
->div_factor
= div_factor
;
970 setting
->data
= data
;
975 setting
->auto_remove
= 1;
977 up(&ide_setting_sem
);
980 up(&ide_setting_sem
);
986 int ide_add_setting(ide_drive_t
*drive
, const char *name
, int rw
, int read_ioctl
, int write_ioctl
, int data_type
, int min
, int max
, int mul_factor
, int div_factor
, void *data
, ide_procset_t
*set
)
988 return __ide_add_setting(drive
, name
, rw
, read_ioctl
, write_ioctl
, data_type
, min
, max
, mul_factor
, div_factor
, data
, set
, 1);
991 EXPORT_SYMBOL(ide_add_setting
);
994 * __ide_remove_setting - remove an ide setting option
995 * @drive: drive to use
996 * @name: setting name
998 * Removes the setting named from the device if it is present.
999 * The caller must hold the setting semaphore.
1002 static void __ide_remove_setting (ide_drive_t
*drive
, char *name
)
1004 ide_settings_t
**p
, *setting
;
1006 p
= (ide_settings_t
**) &drive
->settings
;
1008 while ((*p
) && strcmp((*p
)->name
, name
))
1010 if ((setting
= (*p
)) == NULL
)
1013 (*p
) = setting
->next
;
1015 kfree(setting
->name
);
1020 * ide_find_setting_by_ioctl - find a drive specific ioctl
1021 * @drive: drive to scan
1022 * @cmd: ioctl command to handle
1024 * Scan's the device setting table for a matching entry and returns
1025 * this or NULL if no entry is found. The caller must hold the
1029 static ide_settings_t
*ide_find_setting_by_ioctl (ide_drive_t
*drive
, int cmd
)
1031 ide_settings_t
*setting
= drive
->settings
;
1034 if (setting
->read_ioctl
== cmd
|| setting
->write_ioctl
== cmd
)
1036 setting
= setting
->next
;
1043 * ide_find_setting_by_name - find a drive specific setting
1044 * @drive: drive to scan
1045 * @name: setting name
1047 * Scan's the device setting table for a matching entry and returns
1048 * this or NULL if no entry is found. The caller must hold the
1052 ide_settings_t
*ide_find_setting_by_name (ide_drive_t
*drive
, char *name
)
1054 ide_settings_t
*setting
= drive
->settings
;
1057 if (strcmp(setting
->name
, name
) == 0)
1059 setting
= setting
->next
;
1065 * auto_remove_settings - remove driver specific settings
1068 * Automatically remove all the driver specific settings for this
1069 * drive. This function may sleep and must not be called from IRQ
1070 * context. The caller must hold ide_setting_sem.
1073 static void auto_remove_settings (ide_drive_t
*drive
)
1075 ide_settings_t
*setting
;
1077 setting
= drive
->settings
;
1079 if (setting
->auto_remove
) {
1080 __ide_remove_setting(drive
, setting
->name
);
1083 setting
= setting
->next
;
1088 * ide_read_setting - read an IDE setting
1089 * @drive: drive to read from
1090 * @setting: drive setting
1092 * Read a drive setting and return the value. The caller
1093 * must hold the ide_setting_sem when making this call.
1095 * BUGS: the data return and error are the same return value
1096 * so an error -EINVAL and true return of the same value cannot
1100 int ide_read_setting (ide_drive_t
*drive
, ide_settings_t
*setting
)
1103 unsigned long flags
;
1105 if ((setting
->rw
& SETTING_READ
)) {
1106 spin_lock_irqsave(&ide_lock
, flags
);
1107 switch(setting
->data_type
) {
1109 val
= *((u8
*) setting
->data
);
1112 val
= *((u16
*) setting
->data
);
1116 val
= *((u32
*) setting
->data
);
1119 spin_unlock_irqrestore(&ide_lock
, flags
);
1125 * ide_spin_wait_hwgroup - wait for group
1126 * @drive: drive in the group
1128 * Wait for an IDE device group to go non busy and then return
1129 * holding the ide_lock which guards the hwgroup->busy status
1130 * and right to use it.
1133 int ide_spin_wait_hwgroup (ide_drive_t
*drive
)
1135 ide_hwgroup_t
*hwgroup
= HWGROUP(drive
);
1136 unsigned long timeout
= jiffies
+ (3 * HZ
);
1138 spin_lock_irq(&ide_lock
);
1140 while (hwgroup
->busy
) {
1141 unsigned long lflags
;
1142 spin_unlock_irq(&ide_lock
);
1143 local_irq_set(lflags
);
1144 if (time_after(jiffies
, timeout
)) {
1145 local_irq_restore(lflags
);
1146 printk(KERN_ERR
"%s: channel busy\n", drive
->name
);
1149 local_irq_restore(lflags
);
1150 spin_lock_irq(&ide_lock
);
1155 EXPORT_SYMBOL(ide_spin_wait_hwgroup
);
1158 * ide_write_setting - read an IDE setting
1159 * @drive: drive to read from
1160 * @setting: drive setting
1163 * Write a drive setting if it is possible. The caller
1164 * must hold the ide_setting_sem when making this call.
1166 * BUGS: the data return and error are the same return value
1167 * so an error -EINVAL and true return of the same value cannot
1170 * FIXME: This should be changed to enqueue a special request
1171 * to the driver to change settings, and then wait on a sema for completion.
1172 * The current scheme of polling is kludgy, though safe enough.
1175 int ide_write_setting (ide_drive_t
*drive
, ide_settings_t
*setting
, int val
)
1180 if (!capable(CAP_SYS_ADMIN
))
1182 if (!(setting
->rw
& SETTING_WRITE
))
1184 if (val
< setting
->min
|| val
> setting
->max
)
1187 return setting
->set(drive
, val
);
1188 if (ide_spin_wait_hwgroup(drive
))
1190 switch (setting
->data_type
) {
1192 *((u8
*) setting
->data
) = val
;
1195 *((u16
*) setting
->data
) = val
;
1198 *((u32
*) setting
->data
) = val
;
1201 p
= (u32
*) setting
->data
;
1202 for (i
= 0; i
< 1 << PARTN_BITS
; i
++, p
++)
1206 spin_unlock_irq(&ide_lock
);
1210 static int set_io_32bit(ide_drive_t
*drive
, int arg
)
1212 drive
->io_32bit
= arg
;
1213 #ifdef CONFIG_BLK_DEV_DTC2278
1214 if (HWIF(drive
)->chipset
== ide_dtc2278
)
1215 HWIF(drive
)->drives
[!drive
->select
.b
.unit
].io_32bit
= arg
;
1216 #endif /* CONFIG_BLK_DEV_DTC2278 */
1220 static int set_using_dma (ide_drive_t
*drive
, int arg
)
1222 #ifdef CONFIG_BLK_DEV_IDEDMA
1223 if (!drive
->id
|| !(drive
->id
->capability
& 1))
1225 if (HWIF(drive
)->ide_dma_check
== NULL
)
1228 if (HWIF(drive
)->ide_dma_check(drive
)) return -EIO
;
1229 if (HWIF(drive
)->ide_dma_on(drive
)) return -EIO
;
1231 if (__ide_dma_off(drive
))
1240 static int set_pio_mode (ide_drive_t
*drive
, int arg
)
1244 if (!HWIF(drive
)->tuneproc
)
1246 if (drive
->special
.b
.set_tune
)
1248 ide_init_drive_cmd(&rq
);
1249 drive
->tune_req
= (u8
) arg
;
1250 drive
->special
.b
.set_tune
= 1;
1251 (void) ide_do_drive_cmd(drive
, &rq
, ide_wait
);
1255 static int set_xfer_rate (ide_drive_t
*drive
, int arg
)
1257 int err
= ide_wait_cmd(drive
,
1258 WIN_SETFEATURES
, (u8
) arg
,
1259 SETFEATURES_XFER
, 0, NULL
);
1262 ide_set_xfer_rate(drive
, (u8
) arg
);
1263 ide_driveid_update(drive
);
1269 * ide_add_generic_settings - generic ide settings
1270 * @drive: drive being configured
1272 * Add the generic parts of the system settings to the /proc files and
1273 * ioctls for this IDE device. The caller must not be holding the
1277 void ide_add_generic_settings (ide_drive_t
*drive
)
1280 * drive setting name read/write access read ioctl write ioctl data type min max mul_factor div_factor data pointer set function
1282 __ide_add_setting(drive
, "io_32bit", drive
->no_io_32bit
? SETTING_READ
: SETTING_RW
, HDIO_GET_32BIT
, HDIO_SET_32BIT
, TYPE_BYTE
, 0, 1 + (SUPPORT_VLB_SYNC
<< 1), 1, 1, &drive
->io_32bit
, set_io_32bit
, 0);
1283 __ide_add_setting(drive
, "keepsettings", SETTING_RW
, HDIO_GET_KEEPSETTINGS
, HDIO_SET_KEEPSETTINGS
, TYPE_BYTE
, 0, 1, 1, 1, &drive
->keep_settings
, NULL
, 0);
1284 __ide_add_setting(drive
, "nice1", SETTING_RW
, -1, -1, TYPE_BYTE
, 0, 1, 1, 1, &drive
->nice1
, NULL
, 0);
1285 __ide_add_setting(drive
, "pio_mode", SETTING_WRITE
, -1, HDIO_SET_PIO_MODE
, TYPE_BYTE
, 0, 255, 1, 1, NULL
, set_pio_mode
, 0);
1286 __ide_add_setting(drive
, "unmaskirq", drive
->no_unmask
? SETTING_READ
: SETTING_RW
, HDIO_GET_UNMASKINTR
, HDIO_SET_UNMASKINTR
, TYPE_BYTE
, 0, 1, 1, 1, &drive
->unmask
, NULL
, 0);
1287 __ide_add_setting(drive
, "using_dma", SETTING_RW
, HDIO_GET_DMA
, HDIO_SET_DMA
, TYPE_BYTE
, 0, 1, 1, 1, &drive
->using_dma
, set_using_dma
, 0);
1288 __ide_add_setting(drive
, "init_speed", SETTING_RW
, -1, -1, TYPE_BYTE
, 0, 70, 1, 1, &drive
->init_speed
, NULL
, 0);
1289 __ide_add_setting(drive
, "current_speed", SETTING_RW
, -1, -1, TYPE_BYTE
, 0, 70, 1, 1, &drive
->current_speed
, set_xfer_rate
, 0);
1290 __ide_add_setting(drive
, "number", SETTING_RW
, -1, -1, TYPE_BYTE
, 0, 3, 1, 1, &drive
->dn
, NULL
, 0);
1294 * system_bus_clock - clock guess
1296 * External version of the bus clock guess used by very old IDE drivers
1297 * for things like VLB timings. Should not be used.
1300 int system_bus_clock (void)
1302 return((int) ((!system_bus_speed
) ? ide_system_bus_speed() : system_bus_speed
));
1305 EXPORT_SYMBOL(system_bus_clock
);
1308 * Locking is badly broken here - since way back. That sucker is
1309 * root-only, but that's not an excuse... The real question is what
1310 * exclusion rules do we want here.
1312 int ide_replace_subdriver (ide_drive_t
*drive
, const char *driver
)
1314 if (!drive
->present
|| drive
->usage
|| drive
->dead
)
1316 if (DRIVER(drive
)->cleanup(drive
))
1318 strlcpy(drive
->driver_req
, driver
, sizeof(drive
->driver_req
));
1319 if (ata_attach(drive
)) {
1320 spin_lock(&drives_lock
);
1321 list_del_init(&drive
->list
);
1322 spin_unlock(&drives_lock
);
1323 drive
->driver_req
[0] = 0;
1326 drive
->driver_req
[0] = 0;
1328 if (drive
->driver
&& !strcmp(drive
->driver
->name
, driver
))
1335 * ata_attach - attach an ATA/ATAPI device
1336 * @drive: drive to attach
1338 * Takes a drive that is as yet not assigned to any midlayer IDE
1339 * driver (or is assigned to the default driver) and figures out
1340 * which driver would like to own it. If nobody claims the drive
1341 * then it is automatically attached to the default driver used for
1342 * unclaimed objects.
1344 * A return of zero indicates attachment to a driver, of one
1345 * attachment to the default driver.
1347 * Takes drivers_lock.
1350 int ata_attach(ide_drive_t
*drive
)
1352 struct list_head
*p
;
1353 spin_lock(&drivers_lock
);
1354 list_for_each(p
, &drivers
) {
1355 ide_driver_t
*driver
= list_entry(p
, ide_driver_t
, drivers
);
1356 if (!try_module_get(driver
->owner
))
1358 spin_unlock(&drivers_lock
);
1359 if (driver
->attach(drive
) == 0) {
1360 module_put(driver
->owner
);
1361 drive
->gendev
.driver
= &driver
->gen_driver
;
1364 spin_lock(&drivers_lock
);
1365 module_put(driver
->owner
);
1367 drive
->gendev
.driver
= NULL
;
1368 spin_unlock(&drivers_lock
);
1369 if (ide_register_subdriver(drive
, NULL
))
1370 panic("ide: default attach failed");
1374 static int generic_ide_suspend(struct device
*dev
, pm_message_t state
)
1376 ide_drive_t
*drive
= dev
->driver_data
;
1378 struct request_pm_state rqpm
;
1381 memset(&rq
, 0, sizeof(rq
));
1382 memset(&rqpm
, 0, sizeof(rqpm
));
1383 memset(&args
, 0, sizeof(args
));
1384 rq
.flags
= REQ_PM_SUSPEND
;
1387 rqpm
.pm_step
= ide_pm_state_start_suspend
;
1388 rqpm
.pm_state
= state
;
1390 return ide_do_drive_cmd(drive
, &rq
, ide_wait
);
1393 static int generic_ide_resume(struct device
*dev
)
1395 ide_drive_t
*drive
= dev
->driver_data
;
1397 struct request_pm_state rqpm
;
1400 memset(&rq
, 0, sizeof(rq
));
1401 memset(&rqpm
, 0, sizeof(rqpm
));
1402 memset(&args
, 0, sizeof(args
));
1403 rq
.flags
= REQ_PM_RESUME
;
1406 rqpm
.pm_step
= ide_pm_state_start_resume
;
1409 return ide_do_drive_cmd(drive
, &rq
, ide_head_wait
);
1412 int generic_ide_ioctl(ide_drive_t
*drive
, struct file
*file
, struct block_device
*bdev
,
1413 unsigned int cmd
, unsigned long arg
)
1415 ide_settings_t
*setting
;
1418 void __user
*p
= (void __user
*)arg
;
1420 down(&ide_setting_sem
);
1421 if ((setting
= ide_find_setting_by_ioctl(drive
, cmd
)) != NULL
) {
1422 if (cmd
== setting
->read_ioctl
) {
1423 err
= ide_read_setting(drive
, setting
);
1424 up(&ide_setting_sem
);
1425 return err
>= 0 ? put_user(err
, (long __user
*)arg
) : err
;
1427 if (bdev
!= bdev
->bd_contains
)
1430 err
= ide_write_setting(drive
, setting
, arg
);
1431 up(&ide_setting_sem
);
1435 up(&ide_setting_sem
);
1440 struct hd_geometry geom
;
1441 if (!p
|| (drive
->media
!= ide_disk
&& drive
->media
!= ide_floppy
)) return -EINVAL
;
1442 geom
.heads
= drive
->bios_head
;
1443 geom
.sectors
= drive
->bios_sect
;
1444 geom
.cylinders
= (u16
)drive
->bios_cyl
; /* truncate */
1445 geom
.start
= get_start_sect(bdev
);
1446 if (copy_to_user(p
, &geom
, sizeof(struct hd_geometry
)))
1451 case HDIO_OBSOLETE_IDENTITY
:
1452 case HDIO_GET_IDENTITY
:
1453 if (bdev
!= bdev
->bd_contains
)
1455 if (drive
->id_read
== 0)
1457 if (copy_to_user(p
, drive
->id
, (cmd
== HDIO_GET_IDENTITY
) ? sizeof(*drive
->id
) : 142))
1462 return put_user(drive
->dsc_overlap
<< IDE_NICE_DSC_OVERLAP
|
1463 drive
->atapi_overlap
<< IDE_NICE_ATAPI_OVERLAP
|
1464 drive
->nice0
<< IDE_NICE_0
|
1465 drive
->nice1
<< IDE_NICE_1
|
1466 drive
->nice2
<< IDE_NICE_2
,
1467 (long __user
*) arg
);
1469 #ifdef CONFIG_IDE_TASK_IOCTL
1470 case HDIO_DRIVE_TASKFILE
:
1471 if (!capable(CAP_SYS_ADMIN
) || !capable(CAP_SYS_RAWIO
))
1473 switch(drive
->media
) {
1475 return ide_taskfile_ioctl(drive
, cmd
, arg
);
1479 #endif /* CONFIG_IDE_TASK_IOCTL */
1481 case HDIO_DRIVE_CMD
:
1482 if (!capable(CAP_SYS_RAWIO
))
1484 return ide_cmd_ioctl(drive
, cmd
, arg
);
1486 case HDIO_DRIVE_TASK
:
1487 if (!capable(CAP_SYS_RAWIO
))
1489 return ide_task_ioctl(drive
, cmd
, arg
);
1491 case HDIO_SCAN_HWIF
:
1495 if (!capable(CAP_SYS_RAWIO
)) return -EACCES
;
1496 if (copy_from_user(args
, p
, 3 * sizeof(int)))
1498 memset(&hw
, 0, sizeof(hw
));
1499 ide_init_hwif_ports(&hw
, (unsigned long) args
[0],
1500 (unsigned long) args
[1], NULL
);
1502 if (ide_register_hw(&hw
, NULL
) == -1)
1506 case HDIO_UNREGISTER_HWIF
:
1507 if (!capable(CAP_SYS_RAWIO
)) return -EACCES
;
1508 /* (arg > MAX_HWIFS) checked in function */
1509 ide_unregister(arg
);
1512 if (!capable(CAP_SYS_ADMIN
)) return -EACCES
;
1513 if (arg
!= (arg
& ((1 << IDE_NICE_DSC_OVERLAP
) | (1 << IDE_NICE_1
))))
1515 drive
->dsc_overlap
= (arg
>> IDE_NICE_DSC_OVERLAP
) & 1;
1516 drv
= *(ide_driver_t
**)bdev
->bd_disk
->private_data
;
1517 if (drive
->dsc_overlap
&& !drv
->supports_dsc_overlap
) {
1518 drive
->dsc_overlap
= 0;
1521 drive
->nice1
= (arg
>> IDE_NICE_1
) & 1;
1523 case HDIO_DRIVE_RESET
:
1525 unsigned long flags
;
1526 if (!capable(CAP_SYS_ADMIN
)) return -EACCES
;
1529 * Abort the current command on the
1530 * group if there is one, taking
1531 * care not to allow anything else
1532 * to be queued and to die on the
1533 * spot if we miss one somehow
1536 spin_lock_irqsave(&ide_lock
, flags
);
1538 ide_abort(drive
, "drive reset");
1540 if(HWGROUP(drive
)->handler
)
1543 /* Ensure nothing gets queued after we
1544 drop the lock. Reset will clear the busy */
1546 HWGROUP(drive
)->busy
= 1;
1547 spin_unlock_irqrestore(&ide_lock
, flags
);
1548 (void) ide_do_reset(drive
);
1554 case CDROMCLOSETRAY
:
1555 return scsi_cmd_ioctl(file
, bdev
->bd_disk
, cmd
, p
);
1557 case HDIO_GET_BUSSTATE
:
1558 if (!capable(CAP_SYS_ADMIN
))
1560 if (put_user(HWIF(drive
)->bus_state
, (long __user
*)arg
))
1564 case HDIO_SET_BUSSTATE
:
1565 if (!capable(CAP_SYS_ADMIN
))
1567 if (HWIF(drive
)->busproc
)
1568 return HWIF(drive
)->busproc(drive
, (int)arg
);
1575 EXPORT_SYMBOL(generic_ide_ioctl
);
1578 * stridx() returns the offset of c within s,
1579 * or -1 if c is '\0' or not found within s.
1581 static int __init
stridx (const char *s
, char c
)
1583 char *i
= strchr(s
, c
);
1584 return (i
&& c
) ? i
- s
: -1;
1588 * match_parm() does parsing for ide_setup():
1590 * 1. the first char of s must be '='.
1591 * 2. if the remainder matches one of the supplied keywords,
1592 * the index (1 based) of the keyword is negated and returned.
1593 * 3. if the remainder is a series of no more than max_vals numbers
1594 * separated by commas, the numbers are saved in vals[] and a
1595 * count of how many were saved is returned. Base10 is assumed,
1596 * and base16 is allowed when prefixed with "0x".
1597 * 4. otherwise, zero is returned.
1599 static int __init
match_parm (char *s
, const char *keywords
[], int vals
[], int max_vals
)
1601 static const char *decimal
= "0123456789";
1602 static const char *hex
= "0123456789abcdef";
1607 * Try matching against the supplied keywords,
1608 * and return -(index+1) if we match one
1610 if (keywords
!= NULL
) {
1611 for (i
= 0; *keywords
!= NULL
; ++i
) {
1612 if (!strcmp(s
, *keywords
++))
1617 * Look for a series of no more than "max_vals"
1618 * numeric values separated by commas, in base10,
1619 * or base16 when prefixed with "0x".
1620 * Return a count of how many were found.
1622 for (n
= 0; (i
= stridx(decimal
, *s
)) >= 0;) {
1624 while ((i
= stridx(decimal
, *++s
)) >= 0)
1625 vals
[n
] = (vals
[n
] * 10) + i
;
1626 if (*s
== 'x' && !vals
[n
]) {
1627 while ((i
= stridx(hex
, *++s
)) >= 0)
1628 vals
[n
] = (vals
[n
] * 0x10) + i
;
1630 if (++n
== max_vals
)
1632 if (*s
== ',' || *s
== ';')
1638 return 0; /* zero = nothing matched */
1641 #ifdef CONFIG_BLK_DEV_ALI14XX
1642 static int __initdata probe_ali14xx
;
1643 extern int ali14xx_init(void);
1645 #ifdef CONFIG_BLK_DEV_UMC8672
1646 static int __initdata probe_umc8672
;
1647 extern int umc8672_init(void);
1649 #ifdef CONFIG_BLK_DEV_DTC2278
1650 static int __initdata probe_dtc2278
;
1651 extern int dtc2278_init(void);
1653 #ifdef CONFIG_BLK_DEV_HT6560B
1654 static int __initdata probe_ht6560b
;
1655 extern int ht6560b_init(void);
1657 #ifdef CONFIG_BLK_DEV_QD65XX
1658 static int __initdata probe_qd65xx
;
1659 extern int qd65xx_init(void);
1662 static int __initdata is_chipset_set
[MAX_HWIFS
];
1665 * ide_setup() gets called VERY EARLY during initialization,
1666 * to handle kernel "command line" strings beginning with "hdx=" or "ide".
1668 * Remember to update Documentation/ide.txt if you change something here.
1670 static int __init
ide_setup(char *s
)
1675 unsigned int hw
, unit
;
1676 const char max_drive
= 'a' + ((MAX_HWIFS
* MAX_DRIVES
) - 1);
1677 const char max_hwif
= '0' + (MAX_HWIFS
- 1);
1680 if (strncmp(s
,"hd",2) == 0 && s
[2] == '=') /* hd= is for hd.c */
1681 return 0; /* driver and not us */
1683 if (strncmp(s
,"ide",3) && strncmp(s
,"idebus",6) && strncmp(s
,"hd",2))
1686 printk(KERN_INFO
"ide_setup: %s", s
);
1689 #ifdef CONFIG_BLK_DEV_IDEDOUBLER
1690 if (!strcmp(s
, "ide=doubler")) {
1691 extern int ide_doubler
;
1693 printk(" : Enabled support for IDE doublers\n");
1697 #endif /* CONFIG_BLK_DEV_IDEDOUBLER */
1699 if (!strcmp(s
, "ide=nodma")) {
1700 printk(" : Prevented DMA\n");
1705 #ifdef CONFIG_BLK_DEV_IDEPCI
1706 if (!strcmp(s
, "ide=reverse")) {
1707 ide_scan_direction
= 1;
1708 printk(" : Enabled support for IDE inverse scan order.\n");
1711 #endif /* CONFIG_BLK_DEV_IDEPCI */
1714 * Look for drive options: "hdx="
1716 if (s
[0] == 'h' && s
[1] == 'd' && s
[2] >= 'a' && s
[2] <= max_drive
) {
1717 const char *hd_words
[] = {
1718 "none", "noprobe", "nowerr", "cdrom", "serialize",
1719 "autotune", "noautotune", "minus8", "swapdata", "bswap",
1720 "minus11", "remap", "remap63", "scsi", NULL
};
1722 hw
= unit
/ MAX_DRIVES
;
1723 unit
= unit
% MAX_DRIVES
;
1724 hwif
= &ide_hwifs
[hw
];
1725 drive
= &hwif
->drives
[unit
];
1726 if (strncmp(s
+ 4, "ide-", 4) == 0) {
1727 strlcpy(drive
->driver_req
, s
+ 4, sizeof(drive
->driver_req
));
1730 switch (match_parm(&s
[3], hd_words
, vals
, 3)) {
1731 case -1: /* "none" */
1732 case -2: /* "noprobe" */
1735 case -3: /* "nowerr" */
1736 drive
->bad_wstat
= BAD_R_STAT
;
1739 case -4: /* "cdrom" */
1741 drive
->media
= ide_cdrom
;
1742 /* an ATAPI device ignores DRDY */
1743 drive
->ready_stat
= 0;
1746 case -5: /* "serialize" */
1747 printk(" -- USE \"ide%d=serialize\" INSTEAD", hw
);
1749 case -6: /* "autotune" */
1750 drive
->autotune
= IDE_TUNE_AUTO
;
1751 goto obsolete_option
;
1752 case -7: /* "noautotune" */
1753 drive
->autotune
= IDE_TUNE_NOAUTO
;
1754 goto obsolete_option
;
1755 case -9: /* "swapdata" */
1756 case -10: /* "bswap" */
1759 case -12: /* "remap" */
1760 drive
->remap_0_to_1
= 1;
1762 case -13: /* "remap63" */
1765 case -14: /* "scsi" */
1768 case 3: /* cyl,head,sect */
1769 drive
->media
= ide_disk
;
1770 drive
->ready_stat
= READY_STAT
;
1771 drive
->cyl
= drive
->bios_cyl
= vals
[0];
1772 drive
->head
= drive
->bios_head
= vals
[1];
1773 drive
->sect
= drive
->bios_sect
= vals
[2];
1775 drive
->forced_geom
= 1;
1783 if (s
[0] != 'i' || s
[1] != 'd' || s
[2] != 'e')
1786 * Look for bus speed option: "idebus="
1788 if (s
[3] == 'b' && s
[4] == 'u' && s
[5] == 's') {
1789 if (match_parm(&s
[6], NULL
, vals
, 1) != 1)
1791 if (vals
[0] >= 20 && vals
[0] <= 66) {
1792 idebus_parameter
= vals
[0];
1794 printk(" -- BAD BUS SPEED! Expected value from 20 to 66");
1798 * Look for interface options: "idex="
1800 if (s
[3] >= '0' && s
[3] <= max_hwif
) {
1802 * Be VERY CAREFUL changing this: note hardcoded indexes below
1803 * (-8, -9, -10) are reserved to ease the hardcoding.
1805 static const char *ide_words
[] = {
1806 "noprobe", "serialize", "autotune", "noautotune",
1807 "reset", "dma", "ata66", "minus8", "minus9",
1808 "minus10", "four", "qd65xx", "ht6560b", "cmd640_vlb",
1809 "dtc2278", "umc8672", "ali14xx", NULL
};
1811 hwif
= &ide_hwifs
[hw
];
1812 i
= match_parm(&s
[4], ide_words
, vals
, 3);
1815 * Cryptic check to ensure chipset not already set for hwif.
1816 * Note: we can't depend on hwif->chipset here.
1818 if ((i
>= -18 && i
<= -11) || (i
> 0 && i
<= 3)) {
1819 /* chipset already specified */
1820 if (is_chipset_set
[hw
])
1822 if (i
> -18 && i
<= -11) {
1823 /* these drivers are for "ide0=" only */
1826 /* chipset already specified for 2nd port */
1827 if (is_chipset_set
[hw
+1])
1830 is_chipset_set
[hw
] = 1;
1835 #ifdef CONFIG_BLK_DEV_ALI14XX
1836 case -17: /* "ali14xx" */
1840 #ifdef CONFIG_BLK_DEV_UMC8672
1841 case -16: /* "umc8672" */
1845 #ifdef CONFIG_BLK_DEV_DTC2278
1846 case -15: /* "dtc2278" */
1850 #ifdef CONFIG_BLK_DEV_CMD640
1851 case -14: /* "cmd640_vlb" */
1853 extern int cmd640_vlb
; /* flag for cmd640.c */
1858 #ifdef CONFIG_BLK_DEV_HT6560B
1859 case -13: /* "ht6560b" */
1863 #ifdef CONFIG_BLK_DEV_QD65XX
1864 case -12: /* "qd65xx" */
1868 #ifdef CONFIG_BLK_DEV_4DRIVES
1869 case -11: /* "four" drives on one set of ports */
1871 ide_hwif_t
*mate
= &ide_hwifs
[hw
^1];
1872 mate
->drives
[0].select
.all
^= 0x20;
1873 mate
->drives
[1].select
.all
^= 0x20;
1874 hwif
->chipset
= mate
->chipset
= ide_4drives
;
1875 mate
->irq
= hwif
->irq
;
1876 memcpy(mate
->io_ports
, hwif
->io_ports
, sizeof(hwif
->io_ports
));
1879 #endif /* CONFIG_BLK_DEV_4DRIVES */
1880 case -10: /* minus10 */
1881 case -9: /* minus9 */
1882 case -8: /* minus8 */
1884 case -7: /* ata66 */
1885 #ifdef CONFIG_BLK_DEV_IDEPCI
1886 hwif
->udma_four
= 1;
1887 goto obsolete_option
;
1893 goto obsolete_option
;
1894 case -5: /* "reset" */
1896 goto obsolete_option
;
1897 case -4: /* "noautotune" */
1898 hwif
->drives
[0].autotune
= IDE_TUNE_NOAUTO
;
1899 hwif
->drives
[1].autotune
= IDE_TUNE_NOAUTO
;
1900 goto obsolete_option
;
1901 case -3: /* "autotune" */
1902 hwif
->drives
[0].autotune
= IDE_TUNE_AUTO
;
1903 hwif
->drives
[1].autotune
= IDE_TUNE_AUTO
;
1904 goto obsolete_option
;
1905 case -2: /* "serialize" */
1907 hwif
->mate
= &ide_hwifs
[hw
^1];
1908 hwif
->mate
->mate
= hwif
;
1909 hwif
->serialized
= hwif
->mate
->serialized
= 1;
1910 goto obsolete_option
;
1912 case -1: /* "noprobe" */
1917 vals
[1] = vals
[0] + 0x206; /* default ctl */
1918 case 2: /* base,ctl */
1919 vals
[2] = 0; /* default irq = probe for it */
1920 case 3: /* base,ctl,irq */
1921 hwif
->hw
.irq
= vals
[2];
1922 ide_init_hwif_ports(&hwif
->hw
, (unsigned long) vals
[0], (unsigned long) vals
[1], &hwif
->irq
);
1923 memcpy(hwif
->io_ports
, hwif
->hw
.io_ports
, sizeof(hwif
->io_ports
));
1924 hwif
->irq
= vals
[2];
1926 hwif
->chipset
= ide_forced
;
1927 goto obsolete_option
;
1929 case 0: goto bad_option
;
1931 printk(" -- SUPPORT NOT CONFIGURED IN THIS KERNEL\n");
1936 printk(" -- BAD OPTION\n");
1939 printk(" -- OBSOLETE OPTION, WILL BE REMOVED SOON!\n");
1942 printk("-- NOT SUPPORTED ON ide%d", hw
);
1948 extern void pnpide_init(void);
1949 extern void h8300_ide_init(void);
1952 * probe_for_hwifs() finds/initializes "known" IDE interfaces
1954 static void __init
probe_for_hwifs (void)
1956 #ifdef CONFIG_BLK_DEV_IDEPCI
1957 ide_scan_pcibus(ide_scan_direction
);
1958 #endif /* CONFIG_BLK_DEV_IDEPCI */
1960 #ifdef CONFIG_ETRAX_IDE
1962 extern void init_e100_ide(void);
1965 #endif /* CONFIG_ETRAX_IDE */
1966 #ifdef CONFIG_BLK_DEV_CMD640
1968 extern void ide_probe_for_cmd640x(void);
1969 ide_probe_for_cmd640x();
1971 #endif /* CONFIG_BLK_DEV_CMD640 */
1972 #ifdef CONFIG_BLK_DEV_IDE_PMAC
1974 extern void pmac_ide_probe(void);
1977 #endif /* CONFIG_BLK_DEV_IDE_PMAC */
1978 #ifdef CONFIG_BLK_DEV_GAYLE
1980 extern void gayle_init(void);
1983 #endif /* CONFIG_BLK_DEV_GAYLE */
1984 #ifdef CONFIG_BLK_DEV_FALCON_IDE
1986 extern void falconide_init(void);
1989 #endif /* CONFIG_BLK_DEV_FALCON_IDE */
1990 #ifdef CONFIG_BLK_DEV_MAC_IDE
1992 extern void macide_init(void);
1995 #endif /* CONFIG_BLK_DEV_MAC_IDE */
1996 #ifdef CONFIG_BLK_DEV_Q40IDE
1998 extern void q40ide_init(void);
2001 #endif /* CONFIG_BLK_DEV_Q40IDE */
2002 #ifdef CONFIG_BLK_DEV_BUDDHA
2004 extern void buddha_init(void);
2007 #endif /* CONFIG_BLK_DEV_BUDDHA */
2008 #ifdef CONFIG_BLK_DEV_IDEPNP
2016 int ide_register_subdriver(ide_drive_t
*drive
, ide_driver_t
*driver
)
2018 unsigned long flags
;
2020 spin_lock_irqsave(&ide_lock
, flags
);
2021 if (!drive
->present
|| drive
->driver
!= NULL
||
2022 drive
->usage
|| drive
->dead
) {
2023 spin_unlock_irqrestore(&ide_lock
, flags
);
2026 drive
->driver
= driver
;
2027 spin_unlock_irqrestore(&ide_lock
, flags
);
2028 spin_lock(&drives_lock
);
2029 list_add_tail(&drive
->list
, driver
? &driver
->drives
: &ide_drives
);
2030 spin_unlock(&drives_lock
);
2031 // printk(KERN_INFO "%s: attached %s driver.\n", drive->name, driver->name);
2032 #ifdef CONFIG_PROC_FS
2034 ide_add_proc_entries(drive
->proc
, driver
->proc
, drive
);
2039 EXPORT_SYMBOL(ide_register_subdriver
);
2042 * ide_unregister_subdriver - disconnect drive from driver
2043 * @drive: drive to unplug
2045 * Disconnect a drive from the driver it was attached to and then
2046 * clean up the various proc files and other objects attached to it.
2048 * Takes ide_setting_sem, ide_lock and drives_lock.
2049 * Caller must hold none of the locks.
2051 * No locking versus subdriver unload because we are moving to the
2052 * default driver anyway. Wants double checking.
2055 int ide_unregister_subdriver (ide_drive_t
*drive
)
2057 unsigned long flags
;
2059 down(&ide_setting_sem
);
2060 spin_lock_irqsave(&ide_lock
, flags
);
2061 if (drive
->usage
|| drive
->driver
== NULL
|| DRIVER(drive
)->busy
) {
2062 spin_unlock_irqrestore(&ide_lock
, flags
);
2063 up(&ide_setting_sem
);
2066 #ifdef CONFIG_PROC_FS
2067 ide_remove_proc_entries(drive
->proc
, DRIVER(drive
)->proc
);
2069 auto_remove_settings(drive
);
2070 drive
->driver
= NULL
;
2071 spin_unlock_irqrestore(&ide_lock
, flags
);
2072 up(&ide_setting_sem
);
2073 spin_lock(&drives_lock
);
2074 list_del_init(&drive
->list
);
2075 spin_unlock(&drives_lock
);
2076 /* drive will be added to &ide_drives in ata_attach() */
2080 EXPORT_SYMBOL(ide_unregister_subdriver
);
2082 static int ide_drive_remove(struct device
* dev
)
2084 ide_drive_t
* drive
= container_of(dev
,ide_drive_t
,gendev
);
2085 DRIVER(drive
)->cleanup(drive
);
2090 * ide_register_driver - register IDE device driver
2091 * @driver: the IDE device driver
2093 * Register a new device driver and then scan the devices
2094 * on the IDE bus in case any should be attached to the
2095 * driver we have just registered. If so attach them.
2097 * Takes drivers_lock and drives_lock.
2100 int ide_register_driver(ide_driver_t
*driver
)
2102 struct list_head list
;
2103 struct list_head
*list_loop
;
2104 struct list_head
*tmp_storage
;
2106 spin_lock(&drivers_lock
);
2107 list_add(&driver
->drivers
, &drivers
);
2108 spin_unlock(&drivers_lock
);
2110 INIT_LIST_HEAD(&list
);
2111 spin_lock(&drives_lock
);
2112 list_splice_init(&ide_drives
, &list
);
2113 spin_unlock(&drives_lock
);
2115 list_for_each_safe(list_loop
, tmp_storage
, &list
) {
2116 ide_drive_t
*drive
= container_of(list_loop
, ide_drive_t
, list
);
2117 list_del_init(&drive
->list
);
2121 driver
->gen_driver
.name
= (char *) driver
->name
;
2122 driver
->gen_driver
.bus
= &ide_bus_type
;
2123 driver
->gen_driver
.remove
= ide_drive_remove
;
2124 return driver_register(&driver
->gen_driver
);
2127 EXPORT_SYMBOL(ide_register_driver
);
2130 * ide_unregister_driver - unregister IDE device driver
2131 * @driver: the IDE device driver
2133 * Called when a driver module is being unloaded. We reattach any
2134 * devices to whatever driver claims them next (typically the default
2137 * Takes drivers_lock and called functions will take ide_setting_sem.
2140 void ide_unregister_driver(ide_driver_t
*driver
)
2144 spin_lock(&drivers_lock
);
2145 list_del(&driver
->drivers
);
2146 spin_unlock(&drivers_lock
);
2148 driver_unregister(&driver
->gen_driver
);
2150 while(!list_empty(&driver
->drives
)) {
2151 drive
= list_entry(driver
->drives
.next
, ide_drive_t
, list
);
2152 if (driver
->cleanup(drive
)) {
2153 printk(KERN_ERR
"%s: cleanup_module() called while still busy\n", drive
->name
);
2160 EXPORT_SYMBOL(ide_unregister_driver
);
2166 EXPORT_SYMBOL(ide_lock
);
2168 struct bus_type ide_bus_type
= {
2170 .suspend
= generic_ide_suspend
,
2171 .resume
= generic_ide_resume
,
2175 * This is gets invoked once during initialization, to set *everything* up
2177 static int __init
ide_init(void)
2179 printk(KERN_INFO
"Uniform Multi-Platform E-IDE driver " REVISION
"\n");
2180 devfs_mk_dir("ide");
2181 system_bus_speed
= ide_system_bus_speed();
2183 bus_register(&ide_bus_type
);
2187 #ifdef CONFIG_PROC_FS
2188 proc_ide_root
= proc_mkdir("ide", NULL
);
2191 #ifdef CONFIG_BLK_DEV_ALI14XX
2193 (void)ali14xx_init();
2195 #ifdef CONFIG_BLK_DEV_UMC8672
2197 (void)umc8672_init();
2199 #ifdef CONFIG_BLK_DEV_DTC2278
2201 (void)dtc2278_init();
2203 #ifdef CONFIG_BLK_DEV_HT6560B
2205 (void)ht6560b_init();
2207 #ifdef CONFIG_BLK_DEV_QD65XX
2209 (void)qd65xx_init();
2213 /* Probe for special PCI and other "known" interface chipsets. */
2217 #ifdef CONFIG_PROC_FS
2224 static char *options
= NULL
;
2225 module_param(options
, charp
, 0);
2226 MODULE_LICENSE("GPL");
2228 static void __init
parse_options (char *line
)
2232 if (line
== NULL
|| !*line
)
2234 while ((line
= next
) != NULL
) {
2235 if ((next
= strchr(line
,' ')) != NULL
)
2237 if (!ide_setup(line
))
2238 printk (KERN_INFO
"Unknown option '%s'\n", line
);
2242 int init_module (void)
2244 parse_options(options
);
2248 void cleanup_module (void)
2252 for (index
= 0; index
< MAX_HWIFS
; ++index
)
2253 ide_unregister(index
);
2255 #ifdef CONFIG_PROC_FS
2258 devfs_remove("ide");
2260 bus_unregister(&ide_bus_type
);
2265 __setup("", ide_setup
);
2267 module_init(ide_init
);