]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
mmc: sunxi: Fix misuse of gpio_direction_input()
authorAxel Lin <axel.lin@ingics.com>
Sat, 20 Dec 2014 03:41:25 +0000 (11:41 +0800)
committerHans de Goede <hdegoede@redhat.com>
Wed, 14 Jan 2015 13:56:36 +0000 (14:56 +0100)
It does not make sense to make gpio_direction_input() return the gpio input
status. The return value of gpio_direction_input() is inconsistent if
CONFIG_DM_GPIO is defined.
And we don't need to call gpio_direction_input() int sunxi_mmc_getcd().
Just init the gpio once in mmc_resource_init() is enough.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
drivers/gpio/sunxi_gpio.c
drivers/mmc/sunxi_mmc.c

index 44135e5bb746b38b987128605d3619050eef9f41..2fa50f9f8d5d46336d65c0d2345de8dee37d0cae 100644 (file)
@@ -75,7 +75,7 @@ int gpio_direction_input(unsigned gpio)
 {
        sunxi_gpio_set_cfgpin(gpio, SUNXI_GPIO_INPUT);
 
-       return sunxi_gpio_input(gpio);
+       return 0;
 }
 
 int gpio_direction_output(unsigned gpio, int value)
index 20d18d018422a2a2b2d99d51b6a6c7284ac7c498..623498187ef0255e6fd5a647819a7bdf4477f8e3 100644 (file)
@@ -72,8 +72,11 @@ static int mmc_resource_init(int sdc_no)
        mmchost->mmc_no = sdc_no;
 
        cd_pin = sunxi_mmc_getcd_gpio(sdc_no);
-       if (cd_pin != -1)
+       if (cd_pin != -1) {
                ret = gpio_request(cd_pin, "mmc_cd");
+               if (!ret)
+                       ret = gpio_direction_input(cd_pin);
+       }
 
        return ret;
 }
@@ -414,7 +417,7 @@ static int sunxi_mmc_getcd(struct mmc *mmc)
        if (cd_pin == -1)
                return 1;
 
-       return !gpio_direction_input(cd_pin);
+       return !gpio_get_value(cd_pin);
 }
 
 static const struct mmc_ops sunxi_mmc_ops = {