ide-lib.c 16 KB

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