aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-probe.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-05 20:57:51 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-05 20:57:51 -0500
commitc47137a99c597330b69057158b26061a360c0e09 (patch)
treeaacd4cb968b8d7bdebdcbcce19f110469a977243 /drivers/ide/ide-probe.c
parent29dd59755a849cc6475faa6a75f3b804e23a6fc2 (diff)
ide: add ide_read_[alt]status() inline helpers
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r--drivers/ide/ide-probe.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 9c07bdb68d1a..fd0ef8268950 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -264,8 +264,7 @@ err_misc:
264static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) 264static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
265{ 265{
266 ide_hwif_t *hwif = HWIF(drive); 266 ide_hwif_t *hwif = HWIF(drive);
267 int rc; 267 int use_altstatus = 0, rc;
268 unsigned long hd_status;
269 unsigned long timeout; 268 unsigned long timeout;
270 u8 s = 0, a = 0; 269 u8 s = 0, a = 0;
271 270
@@ -273,19 +272,17 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
273 msleep(50); 272 msleep(50);
274 273
275 if (IDE_CONTROL_REG) { 274 if (IDE_CONTROL_REG) {
276 a = hwif->INB(IDE_ALTSTATUS_REG); 275 a = ide_read_altstatus(drive);
277 s = hwif->INB(IDE_STATUS_REG); 276 s = ide_read_status(drive);
278 if ((a ^ s) & ~INDEX_STAT) { 277 if ((a ^ s) & ~INDEX_STAT)
279 printk(KERN_INFO "%s: probing with STATUS(0x%02x) instead of "
280 "ALTSTATUS(0x%02x)\n", drive->name, s, a);
281 /* ancient Seagate drives, broken interfaces */ 278 /* ancient Seagate drives, broken interfaces */
282 hd_status = IDE_STATUS_REG; 279 printk(KERN_INFO "%s: probing with STATUS(0x%02x) "
283 } else { 280 "instead of ALTSTATUS(0x%02x)\n",
281 drive->name, s, a);
282 else
284 /* use non-intrusive polling */ 283 /* use non-intrusive polling */
285 hd_status = IDE_ALTSTATUS_REG; 284 use_altstatus = 1;
286 } 285 }
287 } else
288 hd_status = IDE_STATUS_REG;
289 286
290 /* set features register for atapi 287 /* set features register for atapi
291 * identify command to be sure of reply 288 * identify command to be sure of reply
@@ -306,11 +303,15 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
306 } 303 }
307 /* give drive a breather */ 304 /* give drive a breather */
308 msleep(50); 305 msleep(50);
309 } while ((hwif->INB(hd_status)) & BUSY_STAT); 306 s = use_altstatus ? ide_read_altstatus(drive)
307 : ide_read_status(drive);
308 } while (s & BUSY_STAT);
310 309
311 /* wait for IRQ and DRQ_STAT */ 310 /* wait for IRQ and DRQ_STAT */
312 msleep(50); 311 msleep(50);
313 if (OK_STAT((hwif->INB(IDE_STATUS_REG)), DRQ_STAT, BAD_R_STAT)) { 312 s = ide_read_status(drive);
313
314 if (OK_STAT(s, DRQ_STAT, BAD_R_STAT)) {
314 unsigned long flags; 315 unsigned long flags;
315 316
316 /* local CPU only; some systems need this */ 317 /* local CPU only; some systems need this */
@@ -320,7 +321,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
320 /* drive responded with ID */ 321 /* drive responded with ID */
321 rc = 0; 322 rc = 0;
322 /* clear drive IRQ */ 323 /* clear drive IRQ */
323 (void) hwif->INB(IDE_STATUS_REG); 324 (void)ide_read_status(drive);
324 local_irq_restore(flags); 325 local_irq_restore(flags);
325 } else { 326 } else {
326 /* drive refused ID */ 327 /* drive refused ID */
@@ -367,7 +368,7 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd)
367 368
368 ide_set_irq(drive, 0); 369 ide_set_irq(drive, 0);
369 /* clear drive IRQ */ 370 /* clear drive IRQ */
370 (void) hwif->INB(IDE_STATUS_REG); 371 (void)ide_read_status(drive);
371 udelay(5); 372 udelay(5);
372 irq = probe_irq_off(cookie); 373 irq = probe_irq_off(cookie);
373 if (!hwif->irq) { 374 if (!hwif->irq) {
@@ -455,7 +456,9 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
455 return 3; 456 return 3;
456 } 457 }
457 458
458 if (OK_STAT((hwif->INB(IDE_STATUS_REG)), READY_STAT, BUSY_STAT) || 459 stat = ide_read_status(drive);
460
461 if (OK_STAT(stat, READY_STAT, BUSY_STAT) ||
459 drive->present || cmd == WIN_PIDENTIFY) { 462 drive->present || cmd == WIN_PIDENTIFY) {
460 /* send cmd and wait */ 463 /* send cmd and wait */
461 if ((rc = try_to_identify(drive, cmd))) { 464 if ((rc = try_to_identify(drive, cmd))) {
@@ -463,7 +466,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
463 rc = try_to_identify(drive,cmd); 466 rc = try_to_identify(drive,cmd);
464 } 467 }
465 468
466 stat = hwif->INB(IDE_STATUS_REG); 469 stat = ide_read_status(drive);
467 470
468 if (stat == (BUSY_STAT | READY_STAT)) 471 if (stat == (BUSY_STAT | READY_STAT))
469 return 4; 472 return 4;
@@ -482,7 +485,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
482 } 485 }
483 486
484 /* ensure drive IRQ is clear */ 487 /* ensure drive IRQ is clear */
485 stat = hwif->INB(IDE_STATUS_REG); 488 stat = ide_read_status(drive);
486 489
487 if (rc == 1) 490 if (rc == 1)
488 printk(KERN_ERR "%s: no response (status = 0x%02x)\n", 491 printk(KERN_ERR "%s: no response (status = 0x%02x)\n",
@@ -496,7 +499,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
496 SELECT_DRIVE(&hwif->drives[0]); 499 SELECT_DRIVE(&hwif->drives[0]);
497 msleep(50); 500 msleep(50);
498 /* ensure drive irq is clear */ 501 /* ensure drive irq is clear */
499 (void) hwif->INB(IDE_STATUS_REG); 502 (void)ide_read_status(drive);
500 } 503 }
501 return rc; 504 return rc;
502} 505}
@@ -521,7 +524,7 @@ static void enable_nest (ide_drive_t *drive)
521 524
522 msleep(50); 525 msleep(50);
523 526
524 stat = hwif->INB(IDE_STATUS_REG); 527 stat = ide_read_status(drive);
525 528
526 if (!OK_STAT(stat, 0, BAD_STAT)) 529 if (!OK_STAT(stat, 0, BAD_STAT))
527 printk(KERN_CONT "failed (status = 0x%02x)\n", stat); 530 printk(KERN_CONT "failed (status = 0x%02x)\n", stat);