aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-lib.c')
-rw-r--r--drivers/ide/ide-lib.c105
1 files changed, 55 insertions, 50 deletions
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 9fc4cfb2a27..9f6e33d8a8b 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -43,7 +43,6 @@ const char *ide_xfer_verbose(u8 mode)
43 43
44 return s; 44 return s;
45} 45}
46
47EXPORT_SYMBOL(ide_xfer_verbose); 46EXPORT_SYMBOL(ide_xfer_verbose);
48 47
49/** 48/**
@@ -87,7 +86,7 @@ static u8 ide_rate_filter(ide_drive_t *drive, u8 speed)
87 * This is used by most chipset support modules when "auto-tuning". 86 * This is used by most chipset support modules when "auto-tuning".
88 */ 87 */
89 88
90u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode) 89u8 ide_get_best_pio_mode(ide_drive_t *drive, u8 mode_wanted, u8 max_mode)
91{ 90{
92 u16 *id = drive->id; 91 u16 *id = drive->id;
93 int pio_mode = -1, overridden = 0; 92 int pio_mode = -1, overridden = 0;
@@ -131,7 +130,6 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode)
131 130
132 return pio_mode; 131 return pio_mode;
133} 132}
134
135EXPORT_SYMBOL_GPL(ide_get_best_pio_mode); 133EXPORT_SYMBOL_GPL(ide_get_best_pio_mode);
136 134
137/* req_pio == "255" for auto-tune */ 135/* req_pio == "255" for auto-tune */
@@ -162,7 +160,6 @@ void ide_set_pio(ide_drive_t *drive, u8 req_pio)
162 160
163 (void)ide_set_pio_mode(drive, XFER_PIO_0 + pio); 161 (void)ide_set_pio_mode(drive, XFER_PIO_0 + pio);
164} 162}
165
166EXPORT_SYMBOL_GPL(ide_set_pio); 163EXPORT_SYMBOL_GPL(ide_set_pio);
167 164
168/** 165/**
@@ -173,7 +170,7 @@ EXPORT_SYMBOL_GPL(ide_set_pio);
173 * Enable or disable bounce buffering for the device. Drives move 170 * Enable or disable bounce buffering for the device. Drives move
174 * between PIO and DMA and that changes the rules we need. 171 * between PIO and DMA and that changes the rules we need.
175 */ 172 */
176 173
177void ide_toggle_bounce(ide_drive_t *drive, int on) 174void ide_toggle_bounce(ide_drive_t *drive, int on)
178{ 175{
179 u64 addr = BLK_BOUNCE_HIGH; /* dma64_addr_t */ 176 u64 addr = BLK_BOUNCE_HIGH; /* dma64_addr_t */
@@ -243,14 +240,13 @@ int ide_set_dma_mode(ide_drive_t *drive, const u8 mode)
243 return ide_config_drive_speed(drive, mode); 240 return ide_config_drive_speed(drive, mode);
244 } 241 }
245} 242}
246
247EXPORT_SYMBOL_GPL(ide_set_dma_mode); 243EXPORT_SYMBOL_GPL(ide_set_dma_mode);
248 244
249/** 245/**
250 * ide_set_xfer_rate - set transfer rate 246 * ide_set_xfer_rate - set transfer rate
251 * @drive: drive to set 247 * @drive: drive to set
252 * @rate: speed to attempt to set 248 * @rate: speed to attempt to set
253 * 249 *
254 * General helper for setting the speed of an IDE device. This 250 * General helper for setting the speed of an IDE device. This
255 * function knows about user enforced limits from the configuration 251 * function knows about user enforced limits from the configuration
256 * which ->set_pio_mode/->set_dma_mode does not. 252 * which ->set_pio_mode/->set_dma_mode does not.
@@ -277,21 +273,16 @@ int ide_set_xfer_rate(ide_drive_t *drive, u8 rate)
277 273
278static void ide_dump_opcode(ide_drive_t *drive) 274static void ide_dump_opcode(ide_drive_t *drive)
279{ 275{
280 struct request *rq; 276 struct request *rq = drive->hwif->hwgroup->rq;
281 ide_task_t *task = NULL; 277 ide_task_t *task = NULL;
282 278
283 spin_lock(&ide_lock);
284 rq = NULL;
285 if (HWGROUP(drive))
286 rq = HWGROUP(drive)->rq;
287 spin_unlock(&ide_lock);
288 if (!rq) 279 if (!rq)
289 return; 280 return;
290 281
291 if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) 282 if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE)
292 task = rq->special; 283 task = rq->special;
293 284
294 printk("ide: failed opcode was: "); 285 printk(KERN_ERR "ide: failed opcode was: ");
295 if (task == NULL) 286 if (task == NULL)
296 printk(KERN_CONT "unknown\n"); 287 printk(KERN_CONT "unknown\n");
297 else 288 else
@@ -329,44 +320,55 @@ static void ide_dump_sector(ide_drive_t *drive)
329 drive->hwif->tp_ops->tf_read(drive, &task); 320 drive->hwif->tp_ops->tf_read(drive, &task);
330 321
331 if (lba48 || (tf->device & ATA_LBA)) 322 if (lba48 || (tf->device & ATA_LBA))
332 printk(", LBAsect=%llu", 323 printk(KERN_CONT ", LBAsect=%llu",
333 (unsigned long long)ide_get_lba_addr(tf, lba48)); 324 (unsigned long long)ide_get_lba_addr(tf, lba48));
334 else 325 else
335 printk(", CHS=%d/%d/%d", (tf->lbah << 8) + tf->lbam, 326 printk(KERN_CONT ", CHS=%d/%d/%d", (tf->lbah << 8) + tf->lbam,
336 tf->device & 0xf, tf->lbal); 327 tf->device & 0xf, tf->lbal);
337} 328}
338 329
339static void ide_dump_ata_error(ide_drive_t *drive, u8 err) 330static void ide_dump_ata_error(ide_drive_t *drive, u8 err)
340{ 331{
341 printk("{ "); 332 printk(KERN_ERR "{ ");
342 if (err & ATA_ABORTED) printk("DriveStatusError "); 333 if (err & ATA_ABORTED)
334 printk(KERN_CONT "DriveStatusError ");
343 if (err & ATA_ICRC) 335 if (err & ATA_ICRC)
344 printk((err & ATA_ABORTED) ? "BadCRC " : "BadSector "); 336 printk(KERN_CONT "%s",
345 if (err & ATA_UNC) printk("UncorrectableError "); 337 (err & ATA_ABORTED) ? "BadCRC " : "BadSector ");
346 if (err & ATA_IDNF) printk("SectorIdNotFound "); 338 if (err & ATA_UNC)
347 if (err & ATA_TRK0NF) printk("TrackZeroNotFound "); 339 printk(KERN_CONT "UncorrectableError ");
348 if (err & ATA_AMNF) printk("AddrMarkNotFound "); 340 if (err & ATA_IDNF)
349 printk("}"); 341 printk(KERN_CONT "SectorIdNotFound ");
342 if (err & ATA_TRK0NF)
343 printk(KERN_CONT "TrackZeroNotFound ");
344 if (err & ATA_AMNF)
345 printk(KERN_CONT "AddrMarkNotFound ");
346 printk(KERN_CONT "}");
350 if ((err & (ATA_BBK | ATA_ABORTED)) == ATA_BBK || 347 if ((err & (ATA_BBK | ATA_ABORTED)) == ATA_BBK ||
351 (err & (ATA_UNC | ATA_IDNF | ATA_AMNF))) { 348 (err & (ATA_UNC | ATA_IDNF | ATA_AMNF))) {
352 ide_dump_sector(drive); 349 ide_dump_sector(drive);
353 if (HWGROUP(drive) && HWGROUP(drive)->rq) 350 if (HWGROUP(drive) && HWGROUP(drive)->rq)
354 printk(", sector=%llu", 351 printk(KERN_CONT ", sector=%llu",
355 (unsigned long long)HWGROUP(drive)->rq->sector); 352 (unsigned long long)HWGROUP(drive)->rq->sector);
356 } 353 }
357 printk("\n"); 354 printk(KERN_CONT "\n");
358} 355}
359 356
360static void ide_dump_atapi_error(ide_drive_t *drive, u8 err) 357static void ide_dump_atapi_error(ide_drive_t *drive, u8 err)
361{ 358{
362 printk("{ "); 359 printk(KERN_ERR "{ ");
363 if (err & ATAPI_ILI) printk("IllegalLengthIndication "); 360 if (err & ATAPI_ILI)
364 if (err & ATAPI_EOM) printk("EndOfMedia "); 361 printk(KERN_CONT "IllegalLengthIndication ");
365 if (err & ATA_ABORTED) printk("AbortedCommand "); 362 if (err & ATAPI_EOM)
366 if (err & ATA_MCR) printk("MediaChangeRequested "); 363 printk(KERN_CONT "EndOfMedia ");
367 if (err & ATAPI_LFS) printk("LastFailedSense=0x%02x ", 364 if (err & ATA_ABORTED)
368 (err & ATAPI_LFS) >> 4); 365 printk(KERN_CONT "AbortedCommand ");
369 printk("}\n"); 366 if (err & ATA_MCR)
367 printk(KERN_CONT "MediaChangeRequested ");
368 if (err & ATAPI_LFS)
369 printk(KERN_CONT "LastFailedSense=0x%02x ",
370 (err & ATAPI_LFS) >> 4);
371 printk(KERN_CONT "}\n");
370} 372}
371 373
372/** 374/**
@@ -382,34 +384,37 @@ static void ide_dump_atapi_error(ide_drive_t *drive, u8 err)
382 384
383u8 ide_dump_status(ide_drive_t *drive, const char *msg, u8 stat) 385u8 ide_dump_status(ide_drive_t *drive, const char *msg, u8 stat)
384{ 386{
385 unsigned long flags;
386 u8 err = 0; 387 u8 err = 0;
387 388
388 local_irq_save(flags); 389 printk(KERN_ERR "%s: %s: status=0x%02x { ", drive->name, msg, stat);
389 printk("%s: %s: status=0x%02x { ", drive->name, msg, stat);
390 if (stat & ATA_BUSY) 390 if (stat & ATA_BUSY)
391 printk("Busy "); 391 printk(KERN_CONT "Busy ");
392 else { 392 else {
393 if (stat & ATA_DRDY) printk("DriveReady "); 393 if (stat & ATA_DRDY)
394 if (stat & ATA_DF) printk("DeviceFault "); 394 printk(KERN_CONT "DriveReady ");
395 if (stat & ATA_DSC) printk("SeekComplete "); 395 if (stat & ATA_DF)
396 if (stat & ATA_DRQ) printk("DataRequest "); 396 printk(KERN_CONT "DeviceFault ");
397 if (stat & ATA_CORR) printk("CorrectedError "); 397 if (stat & ATA_DSC)
398 if (stat & ATA_IDX) printk("Index "); 398 printk(KERN_CONT "SeekComplete ");
399 if (stat & ATA_ERR) printk("Error "); 399 if (stat & ATA_DRQ)
400 printk(KERN_CONT "DataRequest ");
401 if (stat & ATA_CORR)
402 printk(KERN_CONT "CorrectedError ");
403 if (stat & ATA_IDX)
404 printk(KERN_CONT "Index ");
405 if (stat & ATA_ERR)
406 printk(KERN_CONT "Error ");
400 } 407 }
401 printk("}\n"); 408 printk(KERN_CONT "}\n");
402 if ((stat & (ATA_BUSY | ATA_ERR)) == ATA_ERR) { 409 if ((stat & (ATA_BUSY | ATA_ERR)) == ATA_ERR) {
403 err = ide_read_error(drive); 410 err = ide_read_error(drive);
404 printk("%s: %s: error=0x%02x ", drive->name, msg, err); 411 printk(KERN_ERR "%s: %s: error=0x%02x ", drive->name, msg, err);
405 if (drive->media == ide_disk) 412 if (drive->media == ide_disk)
406 ide_dump_ata_error(drive, err); 413 ide_dump_ata_error(drive, err);
407 else 414 else
408 ide_dump_atapi_error(drive, err); 415 ide_dump_atapi_error(drive, err);
409 } 416 }
410 ide_dump_opcode(drive); 417 ide_dump_opcode(drive);
411 local_irq_restore(flags);
412 return err; 418 return err;
413} 419}
414
415EXPORT_SYMBOL(ide_dump_status); 420EXPORT_SYMBOL(ide_dump_status);