]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
libata: factor out ata_eh_schedule_probe()
authorTejun Heo <htejun@gmail.com>
Tue, 27 Nov 2007 10:28:54 +0000 (19:28 +0900)
committerJeff Garzik <jeff@garzik.org>
Wed, 23 Jan 2008 10:24:10 +0000 (05:24 -0500)
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>
drivers/ata/libata-eh.c

index 1d7faab64810afe1524a5884104ac5d6c8d74286..b16c81a24ba356f5c5e1d8e3f363a524b6dc51e0 100644 (file)
@@ -2375,6 +2375,22 @@ static int ata_eh_skip_recovery(struct ata_link *link)
        return 1;
 }
 
+static int ata_eh_schedule_probe(struct ata_device *dev)
+{
+       struct ata_eh_context *ehc = &dev->link->eh_context;
+
+       if (!(ehc->i.probe_mask & (1 << dev->devno)) ||
+           (ehc->did_probe_mask & (1 << dev->devno)))
+               return 0;
+
+       ata_eh_detach_dev(dev);
+       ata_dev_init(dev);
+       ehc->did_probe_mask |= (1 << dev->devno);
+       ehc->i.action |= ATA_EH_SOFTRESET;
+
+       return 1;
+}
+
 static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)
 {
        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)
                if (ata_link_offline(dev->link))
                        ata_eh_detach_dev(dev);
 
-               /* probe if requested */
-               if ((ehc->i.probe_mask & (1 << dev->devno)) &&
-                   !(ehc->did_probe_mask & (1 << dev->devno))) {
-                       ata_eh_detach_dev(dev);
-                       ata_dev_init(dev);
-
+               /* schedule probe if necessary */
+               if (ata_eh_schedule_probe(dev))
                        ehc->tries[dev->devno] = ATA_EH_DEV_TRIES;
-                       ehc->did_probe_mask |= (1 << dev->devno);
-                       ehc->i.action |= ATA_EH_SOFTRESET;
-               }
 
                return 1;
        } else {
@@ -2492,14 +2501,9 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
                        if (dev->flags & ATA_DFLAG_DETACH)
                                ata_eh_detach_dev(dev);
 
-                       if (!ata_dev_enabled(dev) &&
-                           ((ehc->i.probe_mask & (1 << dev->devno)) &&
-                            !(ehc->did_probe_mask & (1 << dev->devno)))) {
-                               ata_eh_detach_dev(dev);
-                               ata_dev_init(dev);
-                               ehc->did_probe_mask |= (1 << dev->devno);
-                               ehc->i.action |= ATA_EH_SOFTRESET;
-                       }
+                       /* schedule probe if necessary */
+                       if (!ata_dev_enabled(dev))
+                               ata_eh_schedule_probe(dev);
                }
        }