linux-mips
[Top] [All Lists]

[PATCH 5/8] bcm63xx: request gpio before using it in bcm63xx_pcmcia.

To: linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH 5/8] bcm63xx: request gpio before using it in bcm63xx_pcmcia.
From: Maxime Bizon <mbizon@freebox.fr>
Date: Wed, 3 Jun 2009 16:02:24 +0200
Cc: Florian Fainelli <florian@openwrt.org>, Maxime Bizon <mbizon@freebox.fr>
In-reply-to: <1244037747-27144-1-git-send-email-mbizon@freebox.fr>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1244037747-27144-1-git-send-email-mbizon@freebox.fr>
Sender: linux-mips-bounce@linux-mips.org
Make sure the gpio is requested and its direction set to input before
using it.

Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
---
 drivers/pcmcia/bcm63xx_pcmcia.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/drivers/pcmcia/bcm63xx_pcmcia.c b/drivers/pcmcia/bcm63xx_pcmcia.c
index 3a0b7fc..6c7f20c 100644
--- a/drivers/pcmcia/bcm63xx_pcmcia.c
+++ b/drivers/pcmcia/bcm63xx_pcmcia.c
@@ -409,9 +409,18 @@ static int bcm63xx_drv_pcmcia_probe(struct platform_device 
*pdev)
        val |= 3 << PCMCIA_C2_HOLD_SHIFT;
        pcmcia_writel(skt, val, PCMCIA_C2_REG);
 
+       /* request and setup ready gpio */
+       ret = gpio_request(skt->pd->ready_gpio, "bcm63xx_pcmcia");
+       if (ret < 0)
+               goto err;
+
+       ret = gpio_direction_input(skt->pd->ready_gpio);
+       if (ret < 0)
+               goto err_gpio;
+
        ret = pcmcia_register_socket(sock);
        if (ret)
-               goto err;
+               goto err_gpio;
 
        /* start polling socket */
        mod_timer(&skt->timer,
@@ -420,6 +429,9 @@ static int bcm63xx_drv_pcmcia_probe(struct platform_device 
*pdev)
        platform_set_drvdata(pdev, skt);
        return 0;
 
+err_gpio:
+       gpio_free(skt->pd->ready_gpio);
+
 err:
        if (skt->io_base)
                iounmap(skt->io_base);
@@ -442,6 +454,7 @@ static int bcm63xx_drv_pcmcia_remove(struct platform_device 
*pdev)
        iounmap(skt->io_base);
        res = skt->reg_res;
        release_mem_region(res->start, res->end - res->start + 1);
+       gpio_free(skt->pd->ready_gpio);
        kfree(skt);
        return 0;
 }
-- 
1.6.0.4


<Prev in Thread] Current Thread [Next in Thread>