aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-11-27 05:28:54 -0500
committerJeff Garzik <jeff@garzik.org>2008-01-23 05:24:10 -0500
commit02c05a27e884c9655dae5b1c8bc0cd89c060c43d (patch)
tree94fb174047e12e60706f3930e5af601b6544d76c /drivers/ata
parent405e66b38797875e80669eaf72d313dbb76533c3 (diff)
libata: factor out ata_eh_schedule_probe()
Factor out ata_eh_schedule_probe() from ata_eh_handle_dev_fail() and ata_eh_recover(). This is to improve maintainability and make future changes easier. In the previous revision, ata_dev_enabled() test was accidentally dropped while factoring out. This problem was spotted by Bartlomiej. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/libata-eh.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 1d7faab64810..b16c81a24ba3 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2375,6 +2375,22 @@ static int ata_eh_skip_recovery(struct ata_link *link)
2375 return 1; 2375 return 1;
2376} 2376}
2377 2377
2378static int ata_eh_schedule_probe(struct ata_device *dev)
2379{
2380 struct ata_eh_context *ehc = &dev->link->eh_context;
2381
2382 if (!(ehc->i.probe_mask & (1 << dev->devno)) ||
2383 (ehc->did_probe_mask & (1 << dev->devno)))
2384 return 0;
2385
2386 ata_eh_detach_dev(dev);
2387 ata_dev_init(dev);
2388 ehc->did_probe_mask |= (1 << dev->devno);
2389 ehc->i.action |= ATA_EH_SOFTRESET;
2390
2391 return 1;
2392}
2393
2378static int ata_eh_handle_dev_fail(struct ata_device *dev, int err) 2394static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)
2379{ 2395{
2380 struct ata_eh_context *ehc = &dev->link->eh_context; 2396 struct ata_eh_context *ehc = &dev->link->eh_context;
@@ -2406,16 +2422,9 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)
2406 if (ata_link_offline(dev->link)) 2422 if (ata_link_offline(dev->link))
2407 ata_eh_detach_dev(dev); 2423 ata_eh_detach_dev(dev);
2408 2424
2409 /* probe if requested */ 2425 /* schedule probe if necessary */
2410 if ((ehc->i.probe_mask & (1 << dev->devno)) && 2426 if (ata_eh_schedule_probe(dev))
2411 !(ehc->did_probe_mask & (1 << dev->devno))) {
2412 ata_eh_detach_dev(dev);
2413 ata_dev_init(dev);
2414
2415 ehc->tries[dev->devno] = ATA_EH_DEV_TRIES; 2427 ehc->tries[dev->devno] = ATA_EH_DEV_TRIES;
2416 ehc->did_probe_mask |= (1 << dev->devno);
2417 ehc->i.action |= ATA_EH_SOFTRESET;
2418 }
2419 2428
2420 return 1; 2429 return 1;
2421 } else { 2430 } else {
@@ -2492,14 +2501,9 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2492 if (dev->flags & ATA_DFLAG_DETACH) 2501 if (dev->flags & ATA_DFLAG_DETACH)
2493 ata_eh_detach_dev(dev); 2502 ata_eh_detach_dev(dev);
2494 2503
2495 if (!ata_dev_enabled(dev) && 2504 /* schedule probe if necessary */
2496 ((ehc->i.probe_mask & (1 << dev->devno)) && 2505 if (!ata_dev_enabled(dev))
2497 !(ehc->did_probe_mask & (1 << dev->devno)))) { 2506 ata_eh_schedule_probe(dev);
2498 ata_eh_detach_dev(dev);
2499 ata_dev_init(dev);
2500 ehc->did_probe_mask |= (1 << dev->devno);
2501 ehc->i.action |= ATA_EH_SOFTRESET;
2502 }
2503 } 2507 }
2504 } 2508 }
2505 2509