ide.c 16 KB

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