ide-lib.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. #include <linux/module.h>
  2. #include <linux/types.h>
  3. #include <linux/string.h>
  4. #include <linux/kernel.h>
  5. #include <linux/timer.h>
  6. #include <linux/mm.h>
  7. #include <linux/interrupt.h>
  8. #include <linux/major.h>
  9. #include <linux/errno.h>
  10. #include <linux/genhd.h>
  11. #include <linux/blkpg.h>
  12. #include <linux/slab.h>
  13. #include <linux/pci.h>
  14. #include <linux/delay.h>
  15. #include <linux/hdreg.h>
  16. #include <linux/ide.h>
  17. #include <linux/bitops.h>
  18. #include <asm/byteorder.h>
  19. #include <asm/irq.h>
  20. #include <asm/uaccess.h>
  21. #include <asm/io.h>
  22. /*
  23. * IDE library routines. These are plug in code that most
  24. * drivers can use but occasionally may be weird enough
  25. * to want to do their own thing with
  26. *
  27. * Add common non I/O op stuff here. Make sure it has proper
  28. * kernel-doc function headers or your patch will be rejected
  29. */
  30. /**
  31. * ide_xfer_verbose - return IDE mode names
  32. * @xfer_rate: rate to name
  33. *
  34. * Returns a constant string giving the name of the mode
  35. * requested.
  36. */
  37. char *ide_xfer_verbose (u8 xfer_rate)
  38. {
  39. switch(xfer_rate) {
  40. case XFER_UDMA_7: return("UDMA 7");
  41. case XFER_UDMA_6: return("UDMA 6");
  42. case XFER_UDMA_5: return("UDMA 5");
  43. case XFER_UDMA_4: return("UDMA 4");
  44. case XFER_UDMA_3: return("UDMA 3");
  45. case XFER_UDMA_2: return("UDMA 2");
  46. case XFER_UDMA_1: return("UDMA 1");
  47. case XFER_UDMA_0: return("UDMA 0");
  48. case XFER_MW_DMA_2: return("MW DMA 2");
  49. case XFER_MW_DMA_1: return("MW DMA 1");
  50. case XFER_MW_DMA_0: return("MW DMA 0");
  51. case XFER_SW_DMA_2: return("SW DMA 2");
  52. case XFER_SW_DMA_1: return("SW DMA 1");
  53. case XFER_SW_DMA_0: return("SW DMA 0");
  54. case XFER_PIO_4: return("PIO 4");
  55. case XFER_PIO_3: return("PIO 3");
  56. case XFER_PIO_2: return("PIO 2");
  57. case XFER_PIO_1: return("PIO 1");
  58. case XFER_PIO_0: return("PIO 0");
  59. case XFER_PIO_SLOW: return("PIO SLOW");
  60. default: return("XFER ERROR");
  61. }
  62. }
  63. EXPORT_SYMBOL(ide_xfer_verbose);
  64. /**
  65. * ide_rate_filter - filter transfer mode
  66. * @drive: IDE device
  67. * @speed: desired speed
  68. *
  69. * Given the available transfer modes this function returns
  70. * the best available speed at or below the speed requested.
  71. *
  72. * TODO: check device PIO capabilities
  73. */
  74. static u8 ide_rate_filter(ide_drive_t *drive, u8 speed)
  75. {
  76. ide_hwif_t *hwif = drive->hwif;
  77. u8 mode = ide_find_dma_mode(drive, speed);
  78. if (mode == 0) {
  79. if (hwif->pio_mask)
  80. mode = fls(hwif->pio_mask) - 1 + XFER_PIO_0;
  81. else
  82. mode = XFER_PIO_4;
  83. }
  84. // printk("%s: mode 0x%02x, speed 0x%02x\n", __FUNCTION__, mode, speed);
  85. return min(speed, mode);
  86. }
  87. /*
  88. * Standard (generic) timings for PIO modes, from ATA2 specification.
  89. * These timings are for access to the IDE data port register *only*.
  90. * Some drives may specify a mode, while also specifying a different
  91. * value for cycle_time (from drive identification data).
  92. */
  93. const ide_pio_timings_t ide_pio_timings[6] = {
  94. { 70, 165, 600 }, /* PIO Mode 0 */
  95. { 50, 125, 383 }, /* PIO Mode 1 */
  96. { 30, 100, 240 }, /* PIO Mode 2 */
  97. { 30, 80, 180 }, /* PIO Mode 3 with IORDY */
  98. { 25, 70, 120 }, /* PIO Mode 4 with IORDY */
  99. { 20, 50, 100 } /* PIO Mode 5 with IORDY (nonstandard) */
  100. };
  101. EXPORT_SYMBOL_GPL(ide_pio_timings);
  102. /*
  103. * Shared data/functions for determining best PIO mode for an IDE drive.
  104. * Most of this stuff originally lived in cmd640.c, and changes to the
  105. * ide_pio_blacklist[] table should be made with EXTREME CAUTION to avoid
  106. * breaking the fragile cmd640.c support.
  107. */
  108. /*
  109. * Black list. Some drives incorrectly report their maximal PIO mode,
  110. * at least in respect to CMD640. Here we keep info on some known drives.
  111. */
  112. static struct ide_pio_info {
  113. const char *name;
  114. int pio;
  115. } ide_pio_blacklist [] = {
  116. /* { "Conner Peripherals 1275MB - CFS1275A", 4 }, */
  117. { "Conner Peripherals 540MB - CFS540A", 3 },
  118. { "WDC AC2700", 3 },
  119. { "WDC AC2540", 3 },
  120. { "WDC AC2420", 3 },
  121. { "WDC AC2340", 3 },
  122. { "WDC AC2250", 0 },
  123. { "WDC AC2200", 0 },
  124. { "WDC AC21200", 4 },
  125. { "WDC AC2120", 0 },
  126. { "WDC AC2850", 3 },
  127. { "WDC AC1270", 3 },
  128. { "WDC AC1170", 1 },
  129. { "WDC AC1210", 1 },
  130. { "WDC AC280", 0 },
  131. /* { "WDC AC21000", 4 }, */
  132. { "WDC AC31000", 3 },
  133. { "WDC AC31200", 3 },
  134. /* { "WDC AC31600", 4 }, */
  135. { "Maxtor 7131 AT", 1 },
  136. { "Maxtor 7171 AT", 1 },
  137. { "Maxtor 7213 AT", 1 },
  138. { "Maxtor 7245 AT", 1 },
  139. { "Maxtor 7345 AT", 1 },
  140. { "Maxtor 7546 AT", 3 },
  141. { "Maxtor 7540 AV", 3 },
  142. { "SAMSUNG SHD-3121A", 1 },
  143. { "SAMSUNG SHD-3122A", 1 },
  144. { "SAMSUNG SHD-3172A", 1 },
  145. /* { "ST51080A", 4 },
  146. * { "ST51270A", 4 },
  147. * { "ST31220A", 4 },
  148. * { "ST31640A", 4 },
  149. * { "ST32140A", 4 },
  150. * { "ST3780A", 4 },
  151. */
  152. { "ST5660A", 3 },
  153. { "ST3660A", 3 },
  154. { "ST3630A", 3 },
  155. { "ST3655A", 3 },
  156. { "ST3391A", 3 },
  157. { "ST3390A", 1 },
  158. { "ST3600A", 1 },
  159. { "ST3290A", 0 },
  160. { "ST3144A", 0 },
  161. { "ST3491A", 1 }, /* reports 3, should be 1 or 2 (depending on */
  162. /* drive) according to Seagates FIND-ATA program */
  163. { "QUANTUM ELS127A", 0 },
  164. { "QUANTUM ELS170A", 0 },
  165. { "QUANTUM LPS240A", 0 },
  166. { "QUANTUM LPS210A", 3 },
  167. { "QUANTUM LPS270A", 3 },
  168. { "QUANTUM LPS365A", 3 },
  169. { "QUANTUM LPS540A", 3 },
  170. { "QUANTUM LIGHTNING 540A", 3 },
  171. { "QUANTUM LIGHTNING 730A", 3 },
  172. { "QUANTUM FIREBALL_540", 3 }, /* Older Quantum Fireballs don't work */
  173. { "QUANTUM FIREBALL_640", 3 },
  174. { "QUANTUM FIREBALL_1080", 3 },
  175. { "QUANTUM FIREBALL_1280", 3 },
  176. { NULL, 0 }
  177. };
  178. /**
  179. * ide_scan_pio_blacklist - check for a blacklisted drive
  180. * @model: Drive model string
  181. *
  182. * This routine searches the ide_pio_blacklist for an entry
  183. * matching the start/whole of the supplied model name.
  184. *
  185. * Returns -1 if no match found.
  186. * Otherwise returns the recommended PIO mode from ide_pio_blacklist[].
  187. */
  188. static int ide_scan_pio_blacklist (char *model)
  189. {
  190. struct ide_pio_info *p;
  191. for (p = ide_pio_blacklist; p->name != NULL; p++) {
  192. if (strncmp(p->name, model, strlen(p->name)) == 0)
  193. return p->pio;
  194. }
  195. return -1;
  196. }
  197. unsigned int ide_pio_cycle_time(ide_drive_t *drive, u8 pio)
  198. {
  199. struct hd_driveid *id = drive->id;
  200. int cycle_time = 0;
  201. if (id->field_valid & 2) {
  202. if (id->capability & 8)
  203. cycle_time = id->eide_pio_iordy;
  204. else
  205. cycle_time = id->eide_pio;
  206. }
  207. /* conservative "downgrade" for all pre-ATA2 drives */
  208. if (pio < 3) {
  209. if (cycle_time && cycle_time < ide_pio_timings[pio].cycle_time)
  210. cycle_time = 0; /* use standard timing */
  211. }
  212. return cycle_time ? cycle_time : ide_pio_timings[pio].cycle_time;
  213. }
  214. EXPORT_SYMBOL_GPL(ide_pio_cycle_time);
  215. /**
  216. * ide_get_best_pio_mode - get PIO mode from drive
  217. * @drive: drive to consider
  218. * @mode_wanted: preferred mode
  219. * @max_mode: highest allowed mode
  220. *
  221. * This routine returns the recommended PIO settings for a given drive,
  222. * based on the drive->id information and the ide_pio_blacklist[].
  223. *
  224. * Drive PIO mode is auto-selected if 255 is passed as mode_wanted.
  225. * This is used by most chipset support modules when "auto-tuning".
  226. */
  227. u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode)
  228. {
  229. int pio_mode;
  230. struct hd_driveid* id = drive->id;
  231. int overridden = 0;
  232. if (mode_wanted != 255)
  233. return min_t(u8, mode_wanted, max_mode);
  234. if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_BLACKLIST) == 0 &&
  235. (pio_mode = ide_scan_pio_blacklist(id->model)) != -1) {
  236. printk(KERN_INFO "%s: is on PIO blacklist\n", drive->name);
  237. } else {
  238. pio_mode = id->tPIO;
  239. if (pio_mode > 2) { /* 2 is maximum allowed tPIO value */
  240. pio_mode = 2;
  241. overridden = 1;
  242. }
  243. if (id->field_valid & 2) { /* drive implements ATA2? */
  244. if (id->capability & 8) { /* IORDY supported? */
  245. if (id->eide_pio_modes & 7) {
  246. overridden = 0;
  247. if (id->eide_pio_modes & 4)
  248. pio_mode = 5;
  249. else if (id->eide_pio_modes & 2)
  250. pio_mode = 4;
  251. else
  252. pio_mode = 3;
  253. }
  254. }
  255. }
  256. if (overridden)
  257. printk(KERN_INFO "%s: tPIO > 2, assuming tPIO = 2\n",
  258. drive->name);
  259. /*
  260. * Conservative "downgrade" for all pre-ATA2 drives
  261. */
  262. if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_DOWNGRADE) == 0 &&
  263. pio_mode && pio_mode < 4) {
  264. pio_mode--;
  265. printk(KERN_INFO "%s: applying conservative "
  266. "PIO \"downgrade\"\n", drive->name);
  267. }
  268. }
  269. if (pio_mode > max_mode)
  270. pio_mode = max_mode;
  271. return pio_mode;
  272. }
  273. EXPORT_SYMBOL_GPL(ide_get_best_pio_mode);
  274. /* req_pio == "255" for auto-tune */
  275. void ide_set_pio(ide_drive_t *drive, u8 req_pio)
  276. {
  277. ide_hwif_t *hwif = drive->hwif;
  278. u8 host_pio, pio;
  279. if (hwif->set_pio_mode == NULL)
  280. return;
  281. BUG_ON(hwif->pio_mask == 0x00);
  282. host_pio = fls(hwif->pio_mask) - 1;
  283. pio = ide_get_best_pio_mode(drive, req_pio, host_pio);
  284. /*
  285. * TODO:
  286. * - report device max PIO mode
  287. * - check req_pio != 255 against device max PIO mode
  288. */
  289. printk(KERN_DEBUG "%s: host max PIO%d wanted PIO%d%s selected PIO%d\n",
  290. drive->name, host_pio, req_pio,
  291. req_pio == 255 ? "(auto-tune)" : "", pio);
  292. (void)ide_set_pio_mode(drive, XFER_PIO_0 + pio);
  293. }
  294. EXPORT_SYMBOL_GPL(ide_set_pio);
  295. /**
  296. * ide_toggle_bounce - handle bounce buffering
  297. * @drive: drive to update
  298. * @on: on/off boolean
  299. *
  300. * Enable or disable bounce buffering for the device. Drives move
  301. * between PIO and DMA and that changes the rules we need.
  302. */
  303. void ide_toggle_bounce(ide_drive_t *drive, int on)
  304. {
  305. u64 addr = BLK_BOUNCE_HIGH; /* dma64_addr_t */
  306. if (!PCI_DMA_BUS_IS_PHYS) {
  307. addr = BLK_BOUNCE_ANY;
  308. } else if (on && drive->media == ide_disk) {
  309. if (HWIF(drive)->pci_dev)
  310. addr = HWIF(drive)->pci_dev->dma_mask;
  311. }
  312. if (drive->queue)
  313. blk_queue_bounce_limit(drive->queue, addr);
  314. }
  315. int ide_set_pio_mode(ide_drive_t *drive, const u8 mode)
  316. {
  317. ide_hwif_t *hwif = drive->hwif;
  318. if (hwif->set_pio_mode == NULL)
  319. return -1;
  320. /*
  321. * TODO: temporary hack for some legacy host drivers that didn't
  322. * set transfer mode on the device in ->set_pio_mode method...
  323. */
  324. if (hwif->set_dma_mode == NULL) {
  325. hwif->set_pio_mode(drive, mode - XFER_PIO_0);
  326. return 0;
  327. }
  328. if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) {
  329. if (ide_config_drive_speed(drive, mode))
  330. return -1;
  331. hwif->set_pio_mode(drive, mode - XFER_PIO_0);
  332. return 0;
  333. } else {
  334. hwif->set_pio_mode(drive, mode - XFER_PIO_0);
  335. return ide_config_drive_speed(drive, mode);
  336. }
  337. }
  338. int ide_set_dma_mode(ide_drive_t *drive, const u8 mode)
  339. {
  340. ide_hwif_t *hwif = drive->hwif;
  341. if (hwif->set_dma_mode == NULL)
  342. return -1;
  343. if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) {
  344. if (ide_config_drive_speed(drive, mode))
  345. return -1;
  346. hwif->set_dma_mode(drive, mode);
  347. return 0;
  348. } else {
  349. hwif->set_dma_mode(drive, mode);
  350. return ide_config_drive_speed(drive, mode);
  351. }
  352. }
  353. EXPORT_SYMBOL_GPL(ide_set_dma_mode);
  354. /**
  355. * ide_set_xfer_rate - set transfer rate
  356. * @drive: drive to set
  357. * @rate: speed to attempt to set
  358. *
  359. * General helper for setting the speed of an IDE device. This
  360. * function knows about user enforced limits from the configuration
  361. * which ->set_pio_mode/->set_dma_mode does not.
  362. */
  363. int ide_set_xfer_rate(ide_drive_t *drive, u8 rate)
  364. {
  365. ide_hwif_t *hwif = drive->hwif;
  366. if (hwif->set_dma_mode == NULL)
  367. return -1;
  368. rate = ide_rate_filter(drive, rate);
  369. if (rate >= XFER_PIO_0 && rate <= XFER_PIO_5)
  370. return ide_set_pio_mode(drive, rate);
  371. /*
  372. * TODO: transfer modes 0x00-0x07 passed from the user-space are
  373. * currently handled here which needs fixing (please note that such
  374. * case could happen iff the transfer mode has already been set on
  375. * the device by ide-proc.c::set_xfer_rate()).
  376. */
  377. return ide_set_dma_mode(drive, rate);
  378. }
  379. static void ide_dump_opcode(ide_drive_t *drive)
  380. {
  381. struct request *rq;
  382. u8 opcode = 0;
  383. int found = 0;
  384. spin_lock(&ide_lock);
  385. rq = NULL;
  386. if (HWGROUP(drive))
  387. rq = HWGROUP(drive)->rq;
  388. spin_unlock(&ide_lock);
  389. if (!rq)
  390. return;
  391. if (rq->cmd_type == REQ_TYPE_ATA_CMD ||
  392. rq->cmd_type == REQ_TYPE_ATA_TASK) {
  393. char *args = rq->buffer;
  394. if (args) {
  395. opcode = args[0];
  396. found = 1;
  397. }
  398. } else if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) {
  399. ide_task_t *args = rq->special;
  400. if (args) {
  401. task_struct_t *tf = (task_struct_t *) args->tfRegister;
  402. opcode = tf->command;
  403. found = 1;
  404. }
  405. }
  406. printk("ide: failed opcode was: ");
  407. if (!found)
  408. printk("unknown\n");
  409. else
  410. printk("0x%02x\n", opcode);
  411. }
  412. static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat)
  413. {
  414. ide_hwif_t *hwif = HWIF(drive);
  415. unsigned long flags;
  416. u8 err = 0;
  417. local_irq_save(flags);
  418. printk("%s: %s: status=0x%02x { ", drive->name, msg, stat);
  419. if (stat & BUSY_STAT)
  420. printk("Busy ");
  421. else {
  422. if (stat & READY_STAT) printk("DriveReady ");
  423. if (stat & WRERR_STAT) printk("DeviceFault ");
  424. if (stat & SEEK_STAT) printk("SeekComplete ");
  425. if (stat & DRQ_STAT) printk("DataRequest ");
  426. if (stat & ECC_STAT) printk("CorrectedError ");
  427. if (stat & INDEX_STAT) printk("Index ");
  428. if (stat & ERR_STAT) printk("Error ");
  429. }
  430. printk("}\n");
  431. if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) {
  432. err = hwif->INB(IDE_ERROR_REG);
  433. printk("%s: %s: error=0x%02x { ", drive->name, msg, err);
  434. if (err & ABRT_ERR) printk("DriveStatusError ");
  435. if (err & ICRC_ERR)
  436. printk((err & ABRT_ERR) ? "BadCRC " : "BadSector ");
  437. if (err & ECC_ERR) printk("UncorrectableError ");
  438. if (err & ID_ERR) printk("SectorIdNotFound ");
  439. if (err & TRK0_ERR) printk("TrackZeroNotFound ");
  440. if (err & MARK_ERR) printk("AddrMarkNotFound ");
  441. printk("}");
  442. if ((err & (BBD_ERR | ABRT_ERR)) == BBD_ERR ||
  443. (err & (ECC_ERR|ID_ERR|MARK_ERR))) {
  444. if (drive->addressing == 1) {
  445. __u64 sectors = 0;
  446. u32 low = 0, high = 0;
  447. low = ide_read_24(drive);
  448. hwif->OUTB(drive->ctl|0x80, IDE_CONTROL_REG);
  449. high = ide_read_24(drive);
  450. sectors = ((__u64)high << 24) | low;
  451. printk(", LBAsect=%llu, high=%d, low=%d",
  452. (unsigned long long) sectors,
  453. high, low);
  454. } else {
  455. u8 cur = hwif->INB(IDE_SELECT_REG);
  456. if (cur & 0x40) { /* using LBA? */
  457. printk(", LBAsect=%ld", (unsigned long)
  458. ((cur&0xf)<<24)
  459. |(hwif->INB(IDE_HCYL_REG)<<16)
  460. |(hwif->INB(IDE_LCYL_REG)<<8)
  461. | hwif->INB(IDE_SECTOR_REG));
  462. } else {
  463. printk(", CHS=%d/%d/%d",
  464. (hwif->INB(IDE_HCYL_REG)<<8) +
  465. hwif->INB(IDE_LCYL_REG),
  466. cur & 0xf,
  467. hwif->INB(IDE_SECTOR_REG));
  468. }
  469. }
  470. if (HWGROUP(drive) && HWGROUP(drive)->rq)
  471. printk(", sector=%llu",
  472. (unsigned long long)HWGROUP(drive)->rq->sector);
  473. }
  474. printk("\n");
  475. }
  476. ide_dump_opcode(drive);
  477. local_irq_restore(flags);
  478. return err;
  479. }
  480. /**
  481. * ide_dump_atapi_status - print human readable atapi status
  482. * @drive: drive that status applies to
  483. * @msg: text message to print
  484. * @stat: status byte to decode
  485. *
  486. * Error reporting, in human readable form (luxurious, but a memory hog).
  487. */
  488. static u8 ide_dump_atapi_status(ide_drive_t *drive, const char *msg, u8 stat)
  489. {
  490. unsigned long flags;
  491. atapi_status_t status;
  492. atapi_error_t error;
  493. status.all = stat;
  494. error.all = 0;
  495. local_irq_save(flags);
  496. printk("%s: %s: status=0x%02x { ", drive->name, msg, stat);
  497. if (status.b.bsy)
  498. printk("Busy ");
  499. else {
  500. if (status.b.drdy) printk("DriveReady ");
  501. if (status.b.df) printk("DeviceFault ");
  502. if (status.b.dsc) printk("SeekComplete ");
  503. if (status.b.drq) printk("DataRequest ");
  504. if (status.b.corr) printk("CorrectedError ");
  505. if (status.b.idx) printk("Index ");
  506. if (status.b.check) printk("Error ");
  507. }
  508. printk("}\n");
  509. if (status.b.check && !status.b.bsy) {
  510. error.all = HWIF(drive)->INB(IDE_ERROR_REG);
  511. printk("%s: %s: error=0x%02x { ", drive->name, msg, error.all);
  512. if (error.b.ili) printk("IllegalLengthIndication ");
  513. if (error.b.eom) printk("EndOfMedia ");
  514. if (error.b.abrt) printk("AbortedCommand ");
  515. if (error.b.mcr) printk("MediaChangeRequested ");
  516. if (error.b.sense_key) printk("LastFailedSense=0x%02x ",
  517. error.b.sense_key);
  518. printk("}\n");
  519. }
  520. ide_dump_opcode(drive);
  521. local_irq_restore(flags);
  522. return error.all;
  523. }
  524. /**
  525. * ide_dump_status - translate ATA/ATAPI error
  526. * @drive: drive the error occured on
  527. * @msg: information string
  528. * @stat: status byte
  529. *
  530. * Error reporting, in human readable form (luxurious, but a memory hog).
  531. * Combines the drive name, message and status byte to provide a
  532. * user understandable explanation of the device error.
  533. */
  534. u8 ide_dump_status(ide_drive_t *drive, const char *msg, u8 stat)
  535. {
  536. if (drive->media == ide_disk)
  537. return ide_dump_ata_status(drive, msg, stat);
  538. return ide_dump_atapi_status(drive, msg, stat);
  539. }
  540. EXPORT_SYMBOL(ide_dump_status);