Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
59bca8cc | 2 | * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) |
fc410698 | 3 | * Copyright (C) 2003-2005, 2007 Bartlomiej Zolnierkiewicz |
1da177e4 LT |
4 | */ |
5 | ||
6 | /* | |
7 | * Mostly written by Mark Lord <mlord@pobox.com> | |
8 | * and Gadi Oxman <gadio@netvision.net.il> | |
9 | * and Andre Hedrick <andre@linux-ide.org> | |
10 | * | |
11 | * See linux/MAINTAINERS for address of current maintainer. | |
12 | * | |
13 | * This is the multiple IDE interface driver, as evolved from hd.c. | |
14 | * It supports up to MAX_HWIFS IDE interfaces, on one or more IRQs | |
15 | * (usually 14 & 15). | |
16 | * There can be up to two drives per interface, as per the ATA-2 spec. | |
17 | * | |
1da177e4 LT |
18 | * ... |
19 | * | |
20 | * From hd.c: | |
21 | * | | |
22 | * | It traverses the request-list, using interrupts to jump between functions. | |
23 | * | As nearly all functions can be called within interrupts, we may not sleep. | |
24 | * | Special care is recommended. Have Fun! | |
25 | * | | |
26 | * | modified by Drew Eckhardt to check nr of hd's from the CMOS. | |
27 | * | | |
28 | * | Thanks to Branko Lankester, lankeste@fwi.uva.nl, who found a bug | |
29 | * | in the early extended-partition checks and added DM partitions. | |
30 | * | | |
31 | * | Early work on error handling by Mika Liljeberg (liljeber@cs.Helsinki.FI). | |
32 | * | | |
33 | * | IRQ-unmask, drive-id, multiple-mode, support for ">16 heads", | |
34 | * | and general streamlining by Mark Lord (mlord@pobox.com). | |
35 | * | |
36 | * October, 1994 -- Complete line-by-line overhaul for linux 1.1.x, by: | |
37 | * | |
38 | * Mark Lord (mlord@pobox.com) (IDE Perf.Pkg) | |
39 | * Delman Lee (delman@ieee.org) ("Mr. atdisk2") | |
40 | * Scott Snyder (snyder@fnald0.fnal.gov) (ATAPI IDE cd-rom) | |
41 | * | |
42 | * This was a rewrite of just about everything from hd.c, though some original | |
43 | * code is still sprinkled about. Think of it as a major evolution, with | |
44 | * inspiration from lots of linux users, esp. hamish@zot.apana.org.au | |
1da177e4 LT |
45 | */ |
46 | ||
1da177e4 LT |
47 | #include <linux/module.h> |
48 | #include <linux/types.h> | |
49 | #include <linux/string.h> | |
50 | #include <linux/kernel.h> | |
1da177e4 LT |
51 | #include <linux/interrupt.h> |
52 | #include <linux/major.h> | |
53 | #include <linux/errno.h> | |
54 | #include <linux/genhd.h> | |
1da177e4 LT |
55 | #include <linux/slab.h> |
56 | #include <linux/init.h> | |
57 | #include <linux/pci.h> | |
1da177e4 | 58 | #include <linux/ide.h> |
3ceca727 | 59 | #include <linux/hdreg.h> |
1da177e4 | 60 | #include <linux/completion.h> |
1da177e4 | 61 | #include <linux/device.h> |
1da177e4 | 62 | |
f74c9141 BZ |
63 | struct class *ide_port_class; |
64 | ||
1da177e4 LT |
65 | /* |
66 | * Locks for IDE setting functionality | |
67 | */ | |
68 | ||
f9383c42 | 69 | DEFINE_MUTEX(ide_setting_mtx); |
1da177e4 | 70 | |
8185d5aa BZ |
71 | ide_devset_get(io_32bit, io_32bit); |
72 | ||
92f1f8fd | 73 | static int set_io_32bit(ide_drive_t *drive, int arg) |
1da177e4 | 74 | { |
97100fc8 | 75 | if (drive->dev_flags & IDE_DFLAG_NO_IO_32BIT) |
1497943e BZ |
76 | return -EPERM; |
77 | ||
78 | if (arg < 0 || arg > 1 + (SUPPORT_VLB_SYNC << 1)) | |
79 | return -EINVAL; | |
80 | ||
1da177e4 | 81 | drive->io_32bit = arg; |
644a9d76 | 82 | |
1da177e4 LT |
83 | return 0; |
84 | } | |
85 | ||
97100fc8 | 86 | ide_devset_get_flag(ksettings, IDE_DFLAG_KEEP_SETTINGS); |
8185d5aa | 87 | |
92f1f8fd | 88 | static int set_ksettings(ide_drive_t *drive, int arg) |
1497943e BZ |
89 | { |
90 | if (arg < 0 || arg > 1) | |
91 | return -EINVAL; | |
92 | ||
97100fc8 BZ |
93 | if (arg) |
94 | drive->dev_flags |= IDE_DFLAG_KEEP_SETTINGS; | |
95 | else | |
96 | drive->dev_flags &= ~IDE_DFLAG_KEEP_SETTINGS; | |
1497943e BZ |
97 | |
98 | return 0; | |
99 | } | |
100 | ||
97100fc8 | 101 | ide_devset_get_flag(using_dma, IDE_DFLAG_USING_DMA); |
8185d5aa | 102 | |
92f1f8fd | 103 | static int set_using_dma(ide_drive_t *drive, int arg) |
1da177e4 LT |
104 | { |
105 | #ifdef CONFIG_BLK_DEV_IDEDMA | |
87996204 BZ |
106 | int err = -EPERM; |
107 | ||
1497943e BZ |
108 | if (arg < 0 || arg > 1) |
109 | return -EINVAL; | |
110 | ||
48fb2688 | 111 | if (ata_id_has_dma(drive->id) == 0) |
87996204 BZ |
112 | goto out; |
113 | ||
92f1f8fd | 114 | if (drive->hwif->dma_ops == NULL) |
87996204 BZ |
115 | goto out; |
116 | ||
87996204 BZ |
117 | err = 0; |
118 | ||
1da177e4 | 119 | if (arg) { |
23b1bd45 | 120 | if (ide_set_dma(drive)) |
87996204 | 121 | err = -EIO; |
7469aaf6 BZ |
122 | } else |
123 | ide_dma_off(drive); | |
87996204 | 124 | |
87996204 BZ |
125 | out: |
126 | return err; | |
1da177e4 | 127 | #else |
1497943e BZ |
128 | if (arg < 0 || arg > 1) |
129 | return -EINVAL; | |
130 | ||
1da177e4 LT |
131 | return -EPERM; |
132 | #endif | |
133 | } | |
134 | ||
6982daf7 BZ |
135 | /* |
136 | * handle HDIO_SET_PIO_MODE ioctl abusers here, eventually it will go away | |
137 | */ | |
138 | static int set_pio_mode_abuse(ide_hwif_t *hwif, u8 req_pio) | |
139 | { | |
140 | switch (req_pio) { | |
141 | case 202: | |
142 | case 201: | |
143 | case 200: | |
144 | case 102: | |
145 | case 101: | |
146 | case 100: | |
147 | return (hwif->host_flags & IDE_HFLAG_ABUSE_DMA_MODES) ? 1 : 0; | |
148 | case 9: | |
149 | case 8: | |
150 | return (hwif->host_flags & IDE_HFLAG_ABUSE_PREFETCH) ? 1 : 0; | |
151 | case 7: | |
152 | case 6: | |
153 | return (hwif->host_flags & IDE_HFLAG_ABUSE_FAST_DEVSEL) ? 1 : 0; | |
154 | default: | |
155 | return 0; | |
156 | } | |
157 | } | |
158 | ||
92f1f8fd | 159 | static int set_pio_mode(ide_drive_t *drive, int arg) |
1da177e4 | 160 | { |
784506cb | 161 | ide_hwif_t *hwif = drive->hwif; |
ac95beed | 162 | const struct ide_port_ops *port_ops = hwif->port_ops; |
1da177e4 | 163 | |
1497943e BZ |
164 | if (arg < 0 || arg > 255) |
165 | return -EINVAL; | |
166 | ||
ac95beed | 167 | if (port_ops == NULL || port_ops->set_pio_mode == NULL || |
784506cb | 168 | (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) |
1da177e4 | 169 | return -ENOSYS; |
26bcb879 | 170 | |
6982daf7 BZ |
171 | if (set_pio_mode_abuse(drive->hwif, arg)) { |
172 | if (arg == 8 || arg == 9) { | |
173 | unsigned long flags; | |
145b75e9 | 174 | |
6982daf7 | 175 | /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */ |
b65fac32 | 176 | spin_lock_irqsave(&hwif->lock, flags); |
6982daf7 | 177 | port_ops->set_pio_mode(drive, arg); |
b65fac32 | 178 | spin_unlock_irqrestore(&hwif->lock, flags); |
6982daf7 BZ |
179 | } else |
180 | port_ops->set_pio_mode(drive, arg); | |
181 | } else { | |
182 | int keep_dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); | |
145b75e9 | 183 | |
6982daf7 | 184 | ide_set_pio(drive, arg); |
5b114715 | 185 | |
6982daf7 BZ |
186 | if (hwif->host_flags & IDE_HFLAG_SET_PIO_MODE_KEEP_DMA) { |
187 | if (keep_dma) | |
188 | ide_dma_on(drive); | |
189 | } | |
190 | } | |
5b114715 | 191 | |
1da177e4 LT |
192 | return 0; |
193 | } | |
194 | ||
97100fc8 | 195 | ide_devset_get_flag(unmaskirq, IDE_DFLAG_UNMASK); |
8185d5aa | 196 | |
92f1f8fd | 197 | static int set_unmaskirq(ide_drive_t *drive, int arg) |
1497943e | 198 | { |
97100fc8 | 199 | if (drive->dev_flags & IDE_DFLAG_NO_UNMASK) |
1497943e BZ |
200 | return -EPERM; |
201 | ||
202 | if (arg < 0 || arg > 1) | |
203 | return -EINVAL; | |
204 | ||
97100fc8 BZ |
205 | if (arg) |
206 | drive->dev_flags |= IDE_DFLAG_UNMASK; | |
207 | else | |
208 | drive->dev_flags &= ~IDE_DFLAG_UNMASK; | |
1497943e BZ |
209 | |
210 | return 0; | |
211 | } | |
212 | ||
f8790489 BZ |
213 | ide_ext_devset_rw_sync(io_32bit, io_32bit); |
214 | ide_ext_devset_rw_sync(keepsettings, ksettings); | |
215 | ide_ext_devset_rw_sync(unmaskirq, unmaskirq); | |
216 | ide_ext_devset_rw_sync(using_dma, using_dma); | |
6982daf7 | 217 | __IDE_DEVSET(pio_mode, DS_SYNC, NULL, set_pio_mode); |
92f1f8fd | 218 | |
08da591e BZ |
219 | /** |
220 | * ide_device_get - get an additional reference to a ide_drive_t | |
221 | * @drive: device to get a reference to | |
222 | * | |
223 | * Gets a reference to the ide_drive_t and increments the use count of the | |
224 | * underlying LLDD module. | |
225 | */ | |
226 | int ide_device_get(ide_drive_t *drive) | |
227 | { | |
228 | struct device *host_dev; | |
229 | struct module *module; | |
230 | ||
231 | if (!get_device(&drive->gendev)) | |
232 | return -ENXIO; | |
233 | ||
234 | host_dev = drive->hwif->host->dev[0]; | |
235 | module = host_dev ? host_dev->driver->owner : NULL; | |
236 | ||
237 | if (module && !try_module_get(module)) { | |
238 | put_device(&drive->gendev); | |
239 | return -ENXIO; | |
240 | } | |
241 | ||
242 | return 0; | |
243 | } | |
244 | EXPORT_SYMBOL_GPL(ide_device_get); | |
245 | ||
246 | /** | |
247 | * ide_device_put - release a reference to a ide_drive_t | |
248 | * @drive: device to release a reference on | |
249 | * | |
250 | * Release a reference to the ide_drive_t and decrements the use count of | |
251 | * the underlying LLDD module. | |
252 | */ | |
253 | void ide_device_put(ide_drive_t *drive) | |
254 | { | |
255 | #ifdef CONFIG_MODULE_UNLOAD | |
256 | struct device *host_dev = drive->hwif->host->dev[0]; | |
257 | struct module *module = host_dev ? host_dev->driver->owner : NULL; | |
258 | ||
259 | if (module) | |
260 | module_put(module); | |
261 | #endif | |
262 | put_device(&drive->gendev); | |
263 | } | |
264 | EXPORT_SYMBOL_GPL(ide_device_put); | |
265 | ||
8604affd BZ |
266 | static int ide_bus_match(struct device *dev, struct device_driver *drv) |
267 | { | |
268 | return 1; | |
269 | } | |
270 | ||
7eff2e7a | 271 | static int ide_uevent(struct device *dev, struct kobj_uevent_env *env) |
263756ec KS |
272 | { |
273 | ide_drive_t *drive = to_ide_device(dev); | |
7eff2e7a | 274 | |
ebdab07d | 275 | add_uevent_var(env, "MEDIA=%s", ide_media_string(drive)); |
7eff2e7a | 276 | add_uevent_var(env, "DRIVENAME=%s", drive->name); |
ebdab07d | 277 | add_uevent_var(env, "MODALIAS=ide:m-%s", ide_media_string(drive)); |
263756ec KS |
278 | return 0; |
279 | } | |
280 | ||
4031bbe4 RK |
281 | static int generic_ide_probe(struct device *dev) |
282 | { | |
283 | ide_drive_t *drive = to_ide_device(dev); | |
7f3c868b | 284 | struct ide_driver *drv = to_ide_driver(dev->driver); |
4031bbe4 RK |
285 | |
286 | return drv->probe ? drv->probe(drive) : -ENODEV; | |
287 | } | |
288 | ||
289 | static int generic_ide_remove(struct device *dev) | |
290 | { | |
291 | ide_drive_t *drive = to_ide_device(dev); | |
7f3c868b | 292 | struct ide_driver *drv = to_ide_driver(dev->driver); |
4031bbe4 RK |
293 | |
294 | if (drv->remove) | |
295 | drv->remove(drive); | |
296 | ||
297 | return 0; | |
298 | } | |
299 | ||
300 | static void generic_ide_shutdown(struct device *dev) | |
301 | { | |
302 | ide_drive_t *drive = to_ide_device(dev); | |
7f3c868b | 303 | struct ide_driver *drv = to_ide_driver(dev->driver); |
4031bbe4 RK |
304 | |
305 | if (dev->driver && drv->shutdown) | |
306 | drv->shutdown(drive); | |
307 | } | |
308 | ||
1da177e4 LT |
309 | struct bus_type ide_bus_type = { |
310 | .name = "ide", | |
8604affd | 311 | .match = ide_bus_match, |
263756ec | 312 | .uevent = ide_uevent, |
4031bbe4 RK |
313 | .probe = generic_ide_probe, |
314 | .remove = generic_ide_remove, | |
315 | .shutdown = generic_ide_shutdown, | |
263756ec | 316 | .dev_attrs = ide_dev_attrs, |
1da177e4 LT |
317 | .suspend = generic_ide_suspend, |
318 | .resume = generic_ide_resume, | |
319 | }; | |
320 | ||
8604affd BZ |
321 | EXPORT_SYMBOL_GPL(ide_bus_type); |
322 | ||
ebae41a5 BZ |
323 | int ide_vlb_clk; |
324 | EXPORT_SYMBOL_GPL(ide_vlb_clk); | |
325 | ||
326 | module_param_named(vlb_clock, ide_vlb_clk, int, 0); | |
327 | MODULE_PARM_DESC(vlb_clock, "VLB clock frequency (in MHz)"); | |
328 | ||
329 | int ide_pci_clk; | |
330 | EXPORT_SYMBOL_GPL(ide_pci_clk); | |
331 | ||
332 | module_param_named(pci_clock, ide_pci_clk, int, 0); | |
333 | MODULE_PARM_DESC(pci_clock, "PCI bus clock frequency (in MHz)"); | |
334 | ||
6e87543a BZ |
335 | static int ide_set_dev_param_mask(const char *s, struct kernel_param *kp) |
336 | { | |
337 | int a, b, i, j = 1; | |
338 | unsigned int *dev_param_mask = (unsigned int *)kp->arg; | |
339 | ||
340 | if (sscanf(s, "%d.%d:%d", &a, &b, &j) != 3 && | |
341 | sscanf(s, "%d.%d", &a, &b) != 2) | |
342 | return -EINVAL; | |
343 | ||
344 | i = a * MAX_DRIVES + b; | |
345 | ||
346 | if (i >= MAX_HWIFS * MAX_DRIVES || j < 0 || j > 1) | |
347 | return -EINVAL; | |
348 | ||
349 | if (j) | |
350 | *dev_param_mask |= (1 << i); | |
351 | else | |
352 | *dev_param_mask &= (1 << i); | |
353 | ||
354 | return 0; | |
355 | } | |
356 | ||
357 | static unsigned int ide_nodma; | |
358 | ||
359 | module_param_call(nodma, ide_set_dev_param_mask, NULL, &ide_nodma, 0); | |
360 | MODULE_PARM_DESC(nodma, "disallow DMA for a device"); | |
361 | ||
362 | static unsigned int ide_noflush; | |
363 | ||
364 | module_param_call(noflush, ide_set_dev_param_mask, NULL, &ide_noflush, 0); | |
365 | MODULE_PARM_DESC(noflush, "disable flush requests for a device"); | |
366 | ||
367 | static unsigned int ide_noprobe; | |
368 | ||
369 | module_param_call(noprobe, ide_set_dev_param_mask, NULL, &ide_noprobe, 0); | |
370 | MODULE_PARM_DESC(noprobe, "skip probing for a device"); | |
371 | ||
372 | static unsigned int ide_nowerr; | |
373 | ||
374 | module_param_call(nowerr, ide_set_dev_param_mask, NULL, &ide_nowerr, 0); | |
3a7d2484 | 375 | MODULE_PARM_DESC(nowerr, "ignore the ATA_DF bit for a device"); |
6e87543a | 376 | |
4706a7e0 BZ |
377 | static unsigned int ide_cdroms; |
378 | ||
379 | module_param_call(cdrom, ide_set_dev_param_mask, NULL, &ide_cdroms, 0); | |
380 | MODULE_PARM_DESC(cdrom, "force device as a CD-ROM"); | |
381 | ||
382 | struct chs_geom { | |
383 | unsigned int cyl; | |
384 | u8 head; | |
385 | u8 sect; | |
386 | }; | |
387 | ||
388 | static unsigned int ide_disks; | |
389 | static struct chs_geom ide_disks_chs[MAX_HWIFS * MAX_DRIVES]; | |
390 | ||
391 | static int ide_set_disk_chs(const char *str, struct kernel_param *kp) | |
392 | { | |
393 | int a, b, c = 0, h = 0, s = 0, i, j = 1; | |
394 | ||
395 | if (sscanf(str, "%d.%d:%d,%d,%d", &a, &b, &c, &h, &s) != 5 && | |
396 | sscanf(str, "%d.%d:%d", &a, &b, &j) != 3) | |
397 | return -EINVAL; | |
398 | ||
399 | i = a * MAX_DRIVES + b; | |
400 | ||
401 | if (i >= MAX_HWIFS * MAX_DRIVES || j < 0 || j > 1) | |
402 | return -EINVAL; | |
403 | ||
404 | if (c > INT_MAX || h > 255 || s > 255) | |
405 | return -EINVAL; | |
406 | ||
407 | if (j) | |
408 | ide_disks |= (1 << i); | |
409 | else | |
410 | ide_disks &= (1 << i); | |
411 | ||
412 | ide_disks_chs[i].cyl = c; | |
413 | ide_disks_chs[i].head = h; | |
414 | ide_disks_chs[i].sect = s; | |
415 | ||
416 | return 0; | |
417 | } | |
418 | ||
419 | module_param_call(chs, ide_set_disk_chs, NULL, NULL, 0); | |
420 | MODULE_PARM_DESC(chs, "force device as a disk (using CHS)"); | |
421 | ||
123995b9 | 422 | static void ide_dev_apply_params(ide_drive_t *drive, u8 unit) |
6e87543a | 423 | { |
123995b9 | 424 | int i = drive->hwif->index * MAX_DRIVES + unit; |
6e87543a BZ |
425 | |
426 | if (ide_nodma & (1 << i)) { | |
427 | printk(KERN_INFO "ide: disallowing DMA for %s\n", drive->name); | |
97100fc8 | 428 | drive->dev_flags |= IDE_DFLAG_NODMA; |
6e87543a BZ |
429 | } |
430 | if (ide_noflush & (1 << i)) { | |
431 | printk(KERN_INFO "ide: disabling flush requests for %s\n", | |
432 | drive->name); | |
97100fc8 | 433 | drive->dev_flags |= IDE_DFLAG_NOFLUSH; |
6e87543a BZ |
434 | } |
435 | if (ide_noprobe & (1 << i)) { | |
436 | printk(KERN_INFO "ide: skipping probe for %s\n", drive->name); | |
97100fc8 | 437 | drive->dev_flags |= IDE_DFLAG_NOPROBE; |
6e87543a BZ |
438 | } |
439 | if (ide_nowerr & (1 << i)) { | |
3a7d2484 | 440 | printk(KERN_INFO "ide: ignoring the ATA_DF bit for %s\n", |
6e87543a BZ |
441 | drive->name); |
442 | drive->bad_wstat = BAD_R_STAT; | |
443 | } | |
4706a7e0 BZ |
444 | if (ide_cdroms & (1 << i)) { |
445 | printk(KERN_INFO "ide: forcing %s as a CD-ROM\n", drive->name); | |
97100fc8 | 446 | drive->dev_flags |= IDE_DFLAG_PRESENT; |
4706a7e0 BZ |
447 | drive->media = ide_cdrom; |
448 | /* an ATAPI device ignores DRDY */ | |
449 | drive->ready_stat = 0; | |
450 | } | |
451 | if (ide_disks & (1 << i)) { | |
452 | drive->cyl = drive->bios_cyl = ide_disks_chs[i].cyl; | |
453 | drive->head = drive->bios_head = ide_disks_chs[i].head; | |
454 | drive->sect = drive->bios_sect = ide_disks_chs[i].sect; | |
97100fc8 | 455 | |
4706a7e0 BZ |
456 | printk(KERN_INFO "ide: forcing %s as a disk (%d/%d/%d)\n", |
457 | drive->name, | |
458 | drive->cyl, drive->head, drive->sect); | |
97100fc8 BZ |
459 | |
460 | drive->dev_flags |= IDE_DFLAG_FORCED_GEOM | IDE_DFLAG_PRESENT; | |
4706a7e0 | 461 | drive->media = ide_disk; |
3a7d2484 | 462 | drive->ready_stat = ATA_DRDY; |
4706a7e0 | 463 | } |
6e87543a BZ |
464 | } |
465 | ||
9fd91d95 BZ |
466 | static unsigned int ide_ignore_cable; |
467 | ||
468 | static int ide_set_ignore_cable(const char *s, struct kernel_param *kp) | |
469 | { | |
470 | int i, j = 1; | |
471 | ||
472 | if (sscanf(s, "%d:%d", &i, &j) != 2 && sscanf(s, "%d", &i) != 1) | |
473 | return -EINVAL; | |
474 | ||
475 | if (i >= MAX_HWIFS || j < 0 || j > 1) | |
476 | return -EINVAL; | |
477 | ||
478 | if (j) | |
479 | ide_ignore_cable |= (1 << i); | |
480 | else | |
481 | ide_ignore_cable &= (1 << i); | |
482 | ||
483 | return 0; | |
484 | } | |
485 | ||
486 | module_param_call(ignore_cable, ide_set_ignore_cable, NULL, NULL, 0); | |
487 | MODULE_PARM_DESC(ignore_cable, "ignore cable detection"); | |
488 | ||
489 | void ide_port_apply_params(ide_hwif_t *hwif) | |
490 | { | |
2bd24a1c | 491 | ide_drive_t *drive; |
6e87543a BZ |
492 | int i; |
493 | ||
9fd91d95 BZ |
494 | if (ide_ignore_cable & (1 << hwif->index)) { |
495 | printk(KERN_INFO "ide: ignoring cable detection for %s\n", | |
496 | hwif->name); | |
497 | hwif->cbl = ATA_CBL_PATA40_SHORT; | |
498 | } | |
6e87543a | 499 | |
2bd24a1c BZ |
500 | ide_port_for_each_dev(i, drive, hwif) |
501 | ide_dev_apply_params(drive, i); | |
9fd91d95 BZ |
502 | } |
503 | ||
1da177e4 LT |
504 | /* |
505 | * This is gets invoked once during initialization, to set *everything* up | |
506 | */ | |
507 | static int __init ide_init(void) | |
508 | { | |
349ae23f RD |
509 | int ret; |
510 | ||
eba8ff94 | 511 | printk(KERN_INFO "Uniform Multi-Platform E-IDE driver\n"); |
537f06c5 | 512 | |
349ae23f RD |
513 | ret = bus_register(&ide_bus_type); |
514 | if (ret < 0) { | |
515 | printk(KERN_WARNING "IDE: bus_register error: %d\n", ret); | |
516 | return ret; | |
517 | } | |
1da177e4 | 518 | |
f74c9141 BZ |
519 | ide_port_class = class_create(THIS_MODULE, "ide_port"); |
520 | if (IS_ERR(ide_port_class)) { | |
521 | ret = PTR_ERR(ide_port_class); | |
522 | goto out_port_class; | |
523 | } | |
f74c9141 | 524 | |
5cbf79cd | 525 | proc_ide_create(); |
1da177e4 | 526 | |
1da177e4 | 527 | return 0; |
f74c9141 BZ |
528 | |
529 | out_port_class: | |
530 | bus_unregister(&ide_bus_type); | |
531 | ||
532 | return ret; | |
1da177e4 LT |
533 | } |
534 | ||
931ee0dc | 535 | static void __exit ide_exit(void) |
1da177e4 | 536 | { |
1da177e4 | 537 | proc_ide_destroy(); |
1da177e4 | 538 | |
f74c9141 BZ |
539 | class_destroy(ide_port_class); |
540 | ||
1da177e4 LT |
541 | bus_unregister(&ide_bus_type); |
542 | } | |
543 | ||
1da177e4 | 544 | module_init(ide_init); |
931ee0dc | 545 | module_exit(ide_exit); |
1da177e4 | 546 | |
931ee0dc | 547 | MODULE_LICENSE("GPL"); |