blob: 6ee866fcc5dd035655cc8649101e8b3df1e578ea [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Bartlomiej Zolnierkiewicz59bca8c2008-02-01 23:09:33 +01002 * Copyright (C) 1994-1998 Linus Torvalds & authors (see below)
Pavel Machekfc410692008-07-23 19:56:02 +02003 * Copyright (C) 2003-2005, 2007 Bartlomiej Zolnierkiewicz
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 */
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 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 * ...
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 */
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#include <linux/module.h>
48#include <linux/types.h>
49#include <linux/string.h>
50#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#include <linux/interrupt.h>
52#include <linux/major.h>
53#include <linux/errno.h>
54#include <linux/genhd.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#include <linux/init.h>
56#include <linux/pci.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#include <linux/ide.h>
Bartlomiej Zolnierkiewicz3ceca722008-10-10 22:39:27 +020058#include <linux/hdreg.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#include <linux/completion.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070060#include <linux/device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
Bartlomiej Zolnierkiewiczf74c9142008-04-18 00:46:23 +020062struct class *ide_port_class;
63
Bartlomiej Zolnierkiewicz08da5912008-07-24 22:53:15 +020064/**
65 * ide_device_get - get an additional reference to a ide_drive_t
66 * @drive: device to get a reference to
67 *
68 * Gets a reference to the ide_drive_t and increments the use count of the
69 * underlying LLDD module.
70 */
71int ide_device_get(ide_drive_t *drive)
72{
73 struct device *host_dev;
74 struct module *module;
75
76 if (!get_device(&drive->gendev))
77 return -ENXIO;
78
79 host_dev = drive->hwif->host->dev[0];
80 module = host_dev ? host_dev->driver->owner : NULL;
81
82 if (module && !try_module_get(module)) {
83 put_device(&drive->gendev);
84 return -ENXIO;
85 }
86
87 return 0;
88}
89EXPORT_SYMBOL_GPL(ide_device_get);
90
91/**
92 * ide_device_put - release a reference to a ide_drive_t
93 * @drive: device to release a reference on
94 *
95 * Release a reference to the ide_drive_t and decrements the use count of
96 * the underlying LLDD module.
97 */
98void ide_device_put(ide_drive_t *drive)
99{
100#ifdef CONFIG_MODULE_UNLOAD
101 struct device *host_dev = drive->hwif->host->dev[0];
102 struct module *module = host_dev ? host_dev->driver->owner : NULL;
103
Markus Elfring1746fbe2014-11-21 20:22:32 +0100104 module_put(module);
Bartlomiej Zolnierkiewicz08da5912008-07-24 22:53:15 +0200105#endif
106 put_device(&drive->gendev);
107}
108EXPORT_SYMBOL_GPL(ide_device_put);
109
Bartlomiej Zolnierkiewicz8604aff2005-05-26 14:55:34 +0200110static int ide_bus_match(struct device *dev, struct device_driver *drv)
111{
112 return 1;
113}
114
Kay Sievers7eff2e72007-08-14 15:15:12 +0200115static int ide_uevent(struct device *dev, struct kobj_uevent_env *env)
Kay Sievers263756e2005-12-12 18:03:44 +0100116{
117 ide_drive_t *drive = to_ide_device(dev);
Kay Sievers263756e2005-12-12 18:03:44 +0100118
Bartlomiej Zolnierkiewiczebdab072009-01-02 16:12:48 +0100119 add_uevent_var(env, "MEDIA=%s", ide_media_string(drive));
Kay Sievers7eff2e72007-08-14 15:15:12 +0200120 add_uevent_var(env, "DRIVENAME=%s", drive->name);
Bartlomiej Zolnierkiewiczebdab072009-01-02 16:12:48 +0100121 add_uevent_var(env, "MODALIAS=ide:m-%s", ide_media_string(drive));
Kay Sievers263756e2005-12-12 18:03:44 +0100122 return 0;
123}
124
Russell King4031bbe2006-01-06 11:41:00 +0000125static int generic_ide_probe(struct device *dev)
126{
127 ide_drive_t *drive = to_ide_device(dev);
Bartlomiej Zolnierkiewicz7f3c8682009-01-06 17:20:53 +0100128 struct ide_driver *drv = to_ide_driver(dev->driver);
Russell King4031bbe2006-01-06 11:41:00 +0000129
130 return drv->probe ? drv->probe(drive) : -ENODEV;
131}
132
133static int generic_ide_remove(struct device *dev)
134{
135 ide_drive_t *drive = to_ide_device(dev);
Bartlomiej Zolnierkiewicz7f3c8682009-01-06 17:20:53 +0100136 struct ide_driver *drv = to_ide_driver(dev->driver);
Russell King4031bbe2006-01-06 11:41:00 +0000137
138 if (drv->remove)
139 drv->remove(drive);
140
141 return 0;
142}
143
144static void generic_ide_shutdown(struct device *dev)
145{
146 ide_drive_t *drive = to_ide_device(dev);
Bartlomiej Zolnierkiewicz7f3c8682009-01-06 17:20:53 +0100147 struct ide_driver *drv = to_ide_driver(dev->driver);
Russell King4031bbe2006-01-06 11:41:00 +0000148
149 if (dev->driver && drv->shutdown)
150 drv->shutdown(drive);
151}
152
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153struct bus_type ide_bus_type = {
154 .name = "ide",
Bartlomiej Zolnierkiewicz8604aff2005-05-26 14:55:34 +0200155 .match = ide_bus_match,
Kay Sievers263756e2005-12-12 18:03:44 +0100156 .uevent = ide_uevent,
Russell King4031bbe2006-01-06 11:41:00 +0000157 .probe = generic_ide_probe,
158 .remove = generic_ide_remove,
159 .shutdown = generic_ide_shutdown,
Greg Kroah-Hartmanfb3fed72013-10-07 18:27:35 -0700160 .dev_groups = ide_dev_groups,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 .suspend = generic_ide_suspend,
162 .resume = generic_ide_resume,
163};
164
Bartlomiej Zolnierkiewicz8604aff2005-05-26 14:55:34 +0200165EXPORT_SYMBOL_GPL(ide_bus_type);
166
Bartlomiej Zolnierkiewiczebae41a2008-04-27 15:38:29 +0200167int ide_vlb_clk;
168EXPORT_SYMBOL_GPL(ide_vlb_clk);
169
170module_param_named(vlb_clock, ide_vlb_clk, int, 0);
171MODULE_PARM_DESC(vlb_clock, "VLB clock frequency (in MHz)");
172
173int ide_pci_clk;
174EXPORT_SYMBOL_GPL(ide_pci_clk);
175
176module_param_named(pci_clock, ide_pci_clk, int, 0);
177MODULE_PARM_DESC(pci_clock, "PCI bus clock frequency (in MHz)");
178
Rusty Russell1a8bff52010-08-11 23:04:38 -0600179static int ide_set_dev_param_mask(const char *s, const struct kernel_param *kp)
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200180{
Dan Carpenter0860bf92015-11-13 17:34:01 +0300181 unsigned int a, b, i, j = 1;
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200182 unsigned int *dev_param_mask = (unsigned int *)kp->arg;
183
David Fries0af80c02009-02-25 20:28:21 +0100184 /* controller . device (0 or 1) [ : 1 (set) | 0 (clear) ] */
Dan Carpenter0860bf92015-11-13 17:34:01 +0300185 if (sscanf(s, "%u.%u:%u", &a, &b, &j) != 3 &&
186 sscanf(s, "%u.%u", &a, &b) != 2)
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200187 return -EINVAL;
188
189 i = a * MAX_DRIVES + b;
190
Dan Carpenter0860bf92015-11-13 17:34:01 +0300191 if (i >= MAX_HWIFS * MAX_DRIVES || j > 1)
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200192 return -EINVAL;
193
194 if (j)
195 *dev_param_mask |= (1 << i);
196 else
David Fries0af80c02009-02-25 20:28:21 +0100197 *dev_param_mask &= ~(1 << i);
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200198
199 return 0;
200}
201
Luis R. Rodriguez9c278472015-05-27 11:09:38 +0930202static const struct kernel_param_ops param_ops_ide_dev_mask = {
Rusty Russell1a8bff52010-08-11 23:04:38 -0600203 .set = ide_set_dev_param_mask
204};
205
206#define param_check_ide_dev_mask(name, p) param_check_uint(name, p)
207
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200208static unsigned int ide_nodma;
209
Rusty Russell1a8bff52010-08-11 23:04:38 -0600210module_param_named(nodma, ide_nodma, ide_dev_mask, 0);
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200211MODULE_PARM_DESC(nodma, "disallow DMA for a device");
212
213static unsigned int ide_noflush;
214
Rusty Russell1a8bff52010-08-11 23:04:38 -0600215module_param_named(noflush, ide_noflush, ide_dev_mask, 0);
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200216MODULE_PARM_DESC(noflush, "disable flush requests for a device");
217
Bartlomiej Zolnierkiewicz075affc2009-06-07 13:52:52 +0200218static unsigned int ide_nohpa;
219
Rusty Russell1a8bff52010-08-11 23:04:38 -0600220module_param_named(nohpa, ide_nohpa, ide_dev_mask, 0);
Bartlomiej Zolnierkiewicz075affc2009-06-07 13:52:52 +0200221MODULE_PARM_DESC(nohpa, "disable Host Protected Area for a device");
222
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200223static unsigned int ide_noprobe;
224
Rusty Russell1a8bff52010-08-11 23:04:38 -0600225module_param_named(noprobe, ide_noprobe, ide_dev_mask, 0);
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200226MODULE_PARM_DESC(noprobe, "skip probing for a device");
227
228static unsigned int ide_nowerr;
229
Rusty Russell1a8bff52010-08-11 23:04:38 -0600230module_param_named(nowerr, ide_nowerr, ide_dev_mask, 0);
Bartlomiej Zolnierkiewicz3a7d2482008-10-10 22:39:21 +0200231MODULE_PARM_DESC(nowerr, "ignore the ATA_DF bit for a device");
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200232
Bartlomiej Zolnierkiewicz4706a7e2008-04-27 15:38:30 +0200233static unsigned int ide_cdroms;
234
Rusty Russell1a8bff52010-08-11 23:04:38 -0600235module_param_named(cdrom, ide_cdroms, ide_dev_mask, 0);
Bartlomiej Zolnierkiewicz4706a7e2008-04-27 15:38:30 +0200236MODULE_PARM_DESC(cdrom, "force device as a CD-ROM");
237
238struct chs_geom {
239 unsigned int cyl;
240 u8 head;
241 u8 sect;
242};
243
244static unsigned int ide_disks;
245static struct chs_geom ide_disks_chs[MAX_HWIFS * MAX_DRIVES];
246
Kees Cooke4dca7b2017-10-17 19:04:42 -0700247static int ide_set_disk_chs(const char *str, const struct kernel_param *kp)
Bartlomiej Zolnierkiewicz4706a7e2008-04-27 15:38:30 +0200248{
Dan Carpenter0860bf92015-11-13 17:34:01 +0300249 unsigned int a, b, c = 0, h = 0, s = 0, i, j = 1;
Bartlomiej Zolnierkiewicz4706a7e2008-04-27 15:38:30 +0200250
David Fries0af80c02009-02-25 20:28:21 +0100251 /* controller . device (0 or 1) : Cylinders , Heads , Sectors */
252 /* controller . device (0 or 1) : 1 (use CHS) | 0 (ignore CHS) */
Dan Carpenter0860bf92015-11-13 17:34:01 +0300253 if (sscanf(str, "%u.%u:%u,%u,%u", &a, &b, &c, &h, &s) != 5 &&
254 sscanf(str, "%u.%u:%u", &a, &b, &j) != 3)
Bartlomiej Zolnierkiewicz4706a7e2008-04-27 15:38:30 +0200255 return -EINVAL;
256
257 i = a * MAX_DRIVES + b;
258
Dan Carpenter0860bf92015-11-13 17:34:01 +0300259 if (i >= MAX_HWIFS * MAX_DRIVES || j > 1)
Bartlomiej Zolnierkiewicz4706a7e2008-04-27 15:38:30 +0200260 return -EINVAL;
261
262 if (c > INT_MAX || h > 255 || s > 255)
263 return -EINVAL;
264
265 if (j)
266 ide_disks |= (1 << i);
267 else
David Fries0af80c02009-02-25 20:28:21 +0100268 ide_disks &= ~(1 << i);
Bartlomiej Zolnierkiewicz4706a7e2008-04-27 15:38:30 +0200269
270 ide_disks_chs[i].cyl = c;
271 ide_disks_chs[i].head = h;
272 ide_disks_chs[i].sect = s;
273
274 return 0;
275}
276
277module_param_call(chs, ide_set_disk_chs, NULL, NULL, 0);
278MODULE_PARM_DESC(chs, "force device as a disk (using CHS)");
279
Bartlomiej Zolnierkiewicz123995b2008-10-13 21:39:40 +0200280static void ide_dev_apply_params(ide_drive_t *drive, u8 unit)
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200281{
Bartlomiej Zolnierkiewicz123995b2008-10-13 21:39:40 +0200282 int i = drive->hwif->index * MAX_DRIVES + unit;
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200283
284 if (ide_nodma & (1 << i)) {
285 printk(KERN_INFO "ide: disallowing DMA for %s\n", drive->name);
Bartlomiej Zolnierkiewicz97100fc2008-10-13 21:39:36 +0200286 drive->dev_flags |= IDE_DFLAG_NODMA;
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200287 }
288 if (ide_noflush & (1 << i)) {
289 printk(KERN_INFO "ide: disabling flush requests for %s\n",
290 drive->name);
Bartlomiej Zolnierkiewicz97100fc2008-10-13 21:39:36 +0200291 drive->dev_flags |= IDE_DFLAG_NOFLUSH;
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200292 }
Bartlomiej Zolnierkiewicz075affc2009-06-07 13:52:52 +0200293 if (ide_nohpa & (1 << i)) {
294 printk(KERN_INFO "ide: disabling Host Protected Area for %s\n",
295 drive->name);
296 drive->dev_flags |= IDE_DFLAG_NOHPA;
297 }
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200298 if (ide_noprobe & (1 << i)) {
299 printk(KERN_INFO "ide: skipping probe for %s\n", drive->name);
Bartlomiej Zolnierkiewicz97100fc2008-10-13 21:39:36 +0200300 drive->dev_flags |= IDE_DFLAG_NOPROBE;
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200301 }
302 if (ide_nowerr & (1 << i)) {
Bartlomiej Zolnierkiewicz3a7d2482008-10-10 22:39:21 +0200303 printk(KERN_INFO "ide: ignoring the ATA_DF bit for %s\n",
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200304 drive->name);
305 drive->bad_wstat = BAD_R_STAT;
306 }
Bartlomiej Zolnierkiewicz4706a7e2008-04-27 15:38:30 +0200307 if (ide_cdroms & (1 << i)) {
308 printk(KERN_INFO "ide: forcing %s as a CD-ROM\n", drive->name);
Bartlomiej Zolnierkiewicz97100fc2008-10-13 21:39:36 +0200309 drive->dev_flags |= IDE_DFLAG_PRESENT;
Bartlomiej Zolnierkiewicz4706a7e2008-04-27 15:38:30 +0200310 drive->media = ide_cdrom;
311 /* an ATAPI device ignores DRDY */
312 drive->ready_stat = 0;
313 }
314 if (ide_disks & (1 << i)) {
315 drive->cyl = drive->bios_cyl = ide_disks_chs[i].cyl;
316 drive->head = drive->bios_head = ide_disks_chs[i].head;
317 drive->sect = drive->bios_sect = ide_disks_chs[i].sect;
Bartlomiej Zolnierkiewicz97100fc2008-10-13 21:39:36 +0200318
Bartlomiej Zolnierkiewicz4706a7e2008-04-27 15:38:30 +0200319 printk(KERN_INFO "ide: forcing %s as a disk (%d/%d/%d)\n",
320 drive->name,
321 drive->cyl, drive->head, drive->sect);
Bartlomiej Zolnierkiewicz97100fc2008-10-13 21:39:36 +0200322
323 drive->dev_flags |= IDE_DFLAG_FORCED_GEOM | IDE_DFLAG_PRESENT;
Bartlomiej Zolnierkiewicz4706a7e2008-04-27 15:38:30 +0200324 drive->media = ide_disk;
Bartlomiej Zolnierkiewicz3a7d2482008-10-10 22:39:21 +0200325 drive->ready_stat = ATA_DRDY;
Bartlomiej Zolnierkiewicz4706a7e2008-04-27 15:38:30 +0200326 }
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200327}
328
Bartlomiej Zolnierkiewicz9fd91d92008-04-27 15:38:23 +0200329static unsigned int ide_ignore_cable;
330
Kees Cooke4dca7b2017-10-17 19:04:42 -0700331static int ide_set_ignore_cable(const char *s, const struct kernel_param *kp)
Bartlomiej Zolnierkiewicz9fd91d92008-04-27 15:38:23 +0200332{
333 int i, j = 1;
334
David Fries0af80c02009-02-25 20:28:21 +0100335 /* controller (ignore) */
336 /* controller : 1 (ignore) | 0 (use) */
Bartlomiej Zolnierkiewicz9fd91d92008-04-27 15:38:23 +0200337 if (sscanf(s, "%d:%d", &i, &j) != 2 && sscanf(s, "%d", &i) != 1)
338 return -EINVAL;
339
340 if (i >= MAX_HWIFS || j < 0 || j > 1)
341 return -EINVAL;
342
343 if (j)
344 ide_ignore_cable |= (1 << i);
345 else
David Fries0af80c02009-02-25 20:28:21 +0100346 ide_ignore_cable &= ~(1 << i);
Bartlomiej Zolnierkiewicz9fd91d92008-04-27 15:38:23 +0200347
348 return 0;
349}
350
351module_param_call(ignore_cable, ide_set_ignore_cable, NULL, NULL, 0);
352MODULE_PARM_DESC(ignore_cable, "ignore cable detection");
353
354void ide_port_apply_params(ide_hwif_t *hwif)
355{
Bartlomiej Zolnierkiewicz2bd24a12009-01-06 17:20:56 +0100356 ide_drive_t *drive;
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200357 int i;
358
Bartlomiej Zolnierkiewicz9fd91d92008-04-27 15:38:23 +0200359 if (ide_ignore_cable & (1 << hwif->index)) {
360 printk(KERN_INFO "ide: ignoring cable detection for %s\n",
361 hwif->name);
362 hwif->cbl = ATA_CBL_PATA40_SHORT;
363 }
Bartlomiej Zolnierkiewicz6e875432008-04-27 15:38:30 +0200364
Bartlomiej Zolnierkiewicz2bd24a12009-01-06 17:20:56 +0100365 ide_port_for_each_dev(i, drive, hwif)
366 ide_dev_apply_params(drive, i);
Bartlomiej Zolnierkiewicz9fd91d92008-04-27 15:38:23 +0200367}
368
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369/*
370 * This is gets invoked once during initialization, to set *everything* up
371 */
372static int __init ide_init(void)
373{
Randy Dunlap349ae232006-10-03 01:14:23 -0700374 int ret;
375
Bartlomiej Zolnierkiewiczeba8ff92008-02-11 00:32:13 +0100376 printk(KERN_INFO "Uniform Multi-Platform E-IDE driver\n");
Bartlomiej Zolnierkiewicz537f06c2008-02-01 23:09:35 +0100377
Randy Dunlap349ae232006-10-03 01:14:23 -0700378 ret = bus_register(&ide_bus_type);
379 if (ret < 0) {
380 printk(KERN_WARNING "IDE: bus_register error: %d\n", ret);
381 return ret;
382 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383
Bartlomiej Zolnierkiewiczf74c9142008-04-18 00:46:23 +0200384 ide_port_class = class_create(THIS_MODULE, "ide_port");
385 if (IS_ERR(ide_port_class)) {
386 ret = PTR_ERR(ide_port_class);
387 goto out_port_class;
388 }
Bartlomiej Zolnierkiewiczf74c9142008-04-18 00:46:23 +0200389
Bartlomiej Zolnierkiewicz8b803bd2009-03-24 23:22:41 +0100390 ide_acpi_init();
391
Bartlomiej Zolnierkiewicz5cbf79c2007-05-10 00:01:11 +0200392 proc_ide_create();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 return 0;
Bartlomiej Zolnierkiewiczf74c9142008-04-18 00:46:23 +0200395
396out_port_class:
397 bus_unregister(&ide_bus_type);
398
399 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400}
401
Bartlomiej Zolnierkiewicz931ee0d2008-07-15 21:21:47 +0200402static void __exit ide_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 proc_ide_destroy();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405
Bartlomiej Zolnierkiewiczf74c9142008-04-18 00:46:23 +0200406 class_destroy(ide_port_class);
407
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 bus_unregister(&ide_bus_type);
409}
410
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411module_init(ide_init);
Bartlomiej Zolnierkiewicz931ee0d2008-07-15 21:21:47 +0200412module_exit(ide_exit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413
Bartlomiej Zolnierkiewicz931ee0d2008-07-15 21:21:47 +0200414MODULE_LICENSE("GPL");