The code isn't specific to a glue layer, move it to a common location.

Signed-off-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
---
 drivers/usb/host/isp1760-core.c | 15 +++++++++++++++
 drivers/usb/host/isp1760-if.c   | 20 +++-----------------
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/host/isp1760-core.c b/drivers/usb/host/isp1760-core.c
index 28f8290..bd538dd 100644
--- a/drivers/usb/host/isp1760-core.c
+++ b/drivers/usb/host/isp1760-core.c
@@ -39,6 +39,18 @@ int isp1760_register(struct resource *mem, int irq, unsigned 
long irqflags,
        if (!isp)
                return -ENOMEM;
 
+       if (gpio_is_valid(rst_gpio)) {
+               ret = gpio_request(rst_gpio, dev_name(dev));
+               if (!ret) {
+                       if (devflags & ISP1760_FLAG_RESET_ACTIVE_HIGH)
+                               gpio_direction_output(rst_gpio, 0);
+                       else
+                               gpio_direction_output(rst_gpio, 1);
+               } else {
+                       rst_gpio = ret;
+               }
+       }
+
        isp->rst_gpio = rst_gpio;
 
        isp->mem_start = mem->start;
@@ -64,6 +76,9 @@ error:
        if (isp->regs)
                iounmap(isp->regs);
 
+       if (gpio_is_valid(isp->rst_gpio))
+               gpio_free(isp->rst_gpio);
+
        kfree(isp);
 
        return ret;
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index 16db1be..ad7de39 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -83,30 +83,16 @@ static int of_isp1760_probe(struct platform_device *dev)
                devflags |= ISP1760_FLAG_DREQ_POL_HIGH;
 
        rst_gpio = of_get_gpio_flags(dp, 0, &gpio_flags);
-       if (gpio_is_valid(rst_gpio)) {
-               ret = gpio_request(rst_gpio, dev_name(&dev->dev));
-               if (!ret) {
-                       if (!(gpio_flags & OF_GPIO_ACTIVE_LOW)) {
-                               devflags |= ISP1760_FLAG_RESET_ACTIVE_HIGH;
-                               gpio_direction_output(rst_gpio, 0);
-                       } else {
-                               gpio_direction_output(rst_gpio, 1);
-                       }
-               } else {
-                       rst_gpio = ret;
-               }
-       }
+       if (gpio_is_valid(rst_gpio) && !(gpio_flags & OF_GPIO_ACTIVE_LOW))
+               devflags |= ISP1760_FLAG_RESET_ACTIVE_HIGH;
 
        ret = isp1760_register(&memory, virq, IRQF_SHARED,
                               rst_gpio, &dev->dev, devflags);
        if (ret < 0)
-               goto free_gpio;
+               goto release_reg;
 
        return ret;
 
-free_gpio:
-       if (gpio_is_valid(rst_gpio))
-               gpio_free(rst_gpio);
 release_reg:
        release_mem_region(memory.start, res_len);
        return ret;
-- 
2.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to