ide-lib.c 16 KB

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