public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] mmc: sunxi: Fix misuse of gpio_direction_input()
@ 2014-12-20  3:41 Axel Lin
  2014-12-21 18:53 ` Simon Glass
  0 siblings, 1 reply; 4+ messages in thread
From: Axel Lin @ 2014-12-20  3:41 UTC (permalink / raw)
  To: u-boot

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>
---
Only compile tested, so please test this patch.
Thanks.
 drivers/gpio/sunxi_gpio.c | 2 +-
 drivers/mmc/sunxi_mmc.c   | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c
index 44135e5..2fa50f9 100644
--- a/drivers/gpio/sunxi_gpio.c
+++ b/drivers/gpio/sunxi_gpio.c
@@ -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)
diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
index 231f0a0..0353355 100644
--- a/drivers/mmc/sunxi_mmc.c
+++ b/drivers/mmc/sunxi_mmc.c
@@ -73,8 +73,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;
 }
@@ -373,7 +376,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 = {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] mmc: sunxi: Fix misuse of gpio_direction_input()
  2014-12-20  3:41 [U-Boot] [PATCH] mmc: sunxi: Fix misuse of gpio_direction_input() Axel Lin
@ 2014-12-21 18:53 ` Simon Glass
  2014-12-22 12:59   ` Ian Campbell
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Glass @ 2014-12-21 18:53 UTC (permalink / raw)
  To: u-boot

On 19 December 2014 at 20:41, Axel Lin <axel.lin@ingics.com> wrote:
> 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>
> ---
> Only compile tested, so please test this patch.
> Thanks.
>  drivers/gpio/sunxi_gpio.c | 2 +-
>  drivers/mmc/sunxi_mmc.c   | 7 +++++--
>  2 files changed, 6 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] mmc: sunxi: Fix misuse of gpio_direction_input()
  2014-12-21 18:53 ` Simon Glass
@ 2014-12-22 12:59   ` Ian Campbell
  2014-12-22 14:08     ` Axel Lin
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Campbell @ 2014-12-22 12:59 UTC (permalink / raw)
  To: u-boot

On Sun, 2014-12-21 at 11:53 -0700, Simon Glass wrote:
> On 19 December 2014 at 20:41, Axel Lin <axel.lin@ingics.com> wrote:
> > 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>
> > ---
> > Only compile tested, so please test this patch.
> > Thanks.
> >  drivers/gpio/sunxi_gpio.c | 2 +-
> >  drivers/mmc/sunxi_mmc.c   | 7 +++++--
> >  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>

Thanks, I booted it on my cubietruck and I could still see the mmc, so
I've queued to u-boot-sunxi#next.

I don't think we need to rush this into v2015.01, but do shout if you
think we do.

Ian.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] mmc: sunxi: Fix misuse of gpio_direction_input()
  2014-12-22 12:59   ` Ian Campbell
@ 2014-12-22 14:08     ` Axel Lin
  0 siblings, 0 replies; 4+ messages in thread
From: Axel Lin @ 2014-12-22 14:08 UTC (permalink / raw)
  To: u-boot

2014-12-22 20:59 GMT+08:00 Ian Campbell <ijc@hellion.org.uk>:
> On Sun, 2014-12-21 at 11:53 -0700, Simon Glass wrote:
>> On 19 December 2014 at 20:41, Axel Lin <axel.lin@ingics.com> wrote:
>> > 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>
>> > ---
>> > Only compile tested, so please test this patch.
>> > Thanks.
>> >  drivers/gpio/sunxi_gpio.c | 2 +-
>> >  drivers/mmc/sunxi_mmc.c   | 7 +++++--
>> >  2 files changed, 6 insertions(+), 3 deletions(-)
>>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> Thanks, I booted it on my cubietruck and I could still see the mmc, so
> I've queued to u-boot-sunxi#next.
>
> I don't think we need to rush this into v2015.01, but do shout if you
> think we do.

Hi Ian,
It's fine for v2015.01.

Thanks,
Axel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-12-22 14:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-20  3:41 [U-Boot] [PATCH] mmc: sunxi: Fix misuse of gpio_direction_input() Axel Lin
2014-12-21 18:53 ` Simon Glass
2014-12-22 12:59   ` Ian Campbell
2014-12-22 14:08     ` Axel Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox