* [PATCH] mmc: slot-gpio: Fix missing assignment to ctx->ro_gpio
@ 2012-09-09 3:00 Chris Ball
2012-09-09 21:21 ` Guennadi Liakhovetski
0 siblings, 1 reply; 4+ messages in thread
From: Chris Ball @ 2012-09-09 3:00 UTC (permalink / raw)
To: linux-mmc; +Cc: Guennadi Liakhovetski
mmc_gpio_request_ro() doesn't store the requested gpio in ctx->ro_gpio.
As a result, subsequent calls to mmc_gpio_get_ro() will always fail
with -ENOSYS because the gpio number isn't available to that function.
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
---
drivers/mmc/core/slot-gpio.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index 0582429..4f9b366 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -99,6 +99,7 @@ int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio)
return ret;
ctx = host->slot.handler_priv;
+ ctx->ro_gpio = gpio;
return gpio_request_one(gpio, GPIOF_DIR_IN, ctx->ro_label);
}
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: slot-gpio: Fix missing assignment to ctx->ro_gpio
2012-09-09 3:00 [PATCH] mmc: slot-gpio: Fix missing assignment to ctx->ro_gpio Chris Ball
@ 2012-09-09 21:21 ` Guennadi Liakhovetski
2012-09-10 2:56 ` [PATCH v2] " Chris Ball
0 siblings, 1 reply; 4+ messages in thread
From: Guennadi Liakhovetski @ 2012-09-09 21:21 UTC (permalink / raw)
To: Chris Ball; +Cc: linux-mmc
Hi Chris
On Sat, 8 Sep 2012, Chris Ball wrote:
> mmc_gpio_request_ro() doesn't store the requested gpio in ctx->ro_gpio.
> As a result, subsequent calls to mmc_gpio_get_ro() will always fail
> with -ENOSYS because the gpio number isn't available to that function.
>
> Cc: stable <stable@vger.kernel.org>
> Signed-off-by: Chris Ball <cjb@laptop.org>
> ---
> drivers/mmc/core/slot-gpio.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
> index 0582429..4f9b366 100644
> --- a/drivers/mmc/core/slot-gpio.c
> +++ b/drivers/mmc/core/slot-gpio.c
> @@ -99,6 +99,7 @@ int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio)
> return ret;
>
> ctx = host->slot.handler_priv;
> + ctx->ro_gpio = gpio;
Huh, I wonder how this got lost. But, please, let's do it a bit
differently. If gpio_request_one() fails, ctx->ro_gpio shouldn't contain a
valid GPIO number. So, I think, it should be
+ ret = gpio_request_one(gpio, GPIOF_DIR_IN, ctx->ro_label);
+ if (ret < 0)
+ return ret;
+
+ ctx->ro_gpio = gpio;
+
+ return 0;
Agree?
Thanks
Guennadi
>
> return gpio_request_one(gpio, GPIOF_DIR_IN, ctx->ro_label);
> }
> --
> Chris Ball <cjb@laptop.org> <http://printf.net/>
> One Laptop Per Child
>
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] mmc: slot-gpio: Fix missing assignment to ctx->ro_gpio
2012-09-09 21:21 ` Guennadi Liakhovetski
@ 2012-09-10 2:56 ` Chris Ball
2012-09-10 21:37 ` Guennadi Liakhovetski
0 siblings, 1 reply; 4+ messages in thread
From: Chris Ball @ 2012-09-10 2:56 UTC (permalink / raw)
To: Guennadi Liakhovetski; +Cc: linux-mmc
mmc_gpio_request_ro() doesn't store the requested gpio in ctx->ro_gpio.
As a result, subsequent calls to mmc_gpio_get_ro() will always fail
with -ENOSYS because the gpio number isn't available to that function.
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
---
v2, addressing Guennadi's review comments:
- If gpio_request_one() fails, ctx->ro_gpio shouldn't contain a
valid GPIO number.
drivers/mmc/core/slot-gpio.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index 0582429..08c6b3d 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -100,7 +100,13 @@ int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio)
ctx = host->slot.handler_priv;
- return gpio_request_one(gpio, GPIOF_DIR_IN, ctx->ro_label);
+ ret = gpio_request_one(gpio, GPIOF_DIR_IN, ctx->ro_label);
+ if (ret < 0)
+ return ret;
+
+ ctx->ro_gpio = gpio;
+
+ return 0;
}
EXPORT_SYMBOL(mmc_gpio_request_ro);
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] mmc: slot-gpio: Fix missing assignment to ctx->ro_gpio
2012-09-10 2:56 ` [PATCH v2] " Chris Ball
@ 2012-09-10 21:37 ` Guennadi Liakhovetski
0 siblings, 0 replies; 4+ messages in thread
From: Guennadi Liakhovetski @ 2012-09-10 21:37 UTC (permalink / raw)
To: Chris Ball; +Cc: linux-mmc
On Sun, 9 Sep 2012, Chris Ball wrote:
> mmc_gpio_request_ro() doesn't store the requested gpio in ctx->ro_gpio.
> As a result, subsequent calls to mmc_gpio_get_ro() will always fail
> with -ENOSYS because the gpio number isn't available to that function.
>
> Cc: stable <stable@vger.kernel.org>
> Signed-off-by: Chris Ball <cjb@laptop.org>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Thanks
Guennadi
> ---
> v2, addressing Guennadi's review comments:
> - If gpio_request_one() fails, ctx->ro_gpio shouldn't contain a
> valid GPIO number.
>
> drivers/mmc/core/slot-gpio.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
> index 0582429..08c6b3d 100644
> --- a/drivers/mmc/core/slot-gpio.c
> +++ b/drivers/mmc/core/slot-gpio.c
> @@ -100,7 +100,13 @@ int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio)
>
> ctx = host->slot.handler_priv;
>
> - return gpio_request_one(gpio, GPIOF_DIR_IN, ctx->ro_label);
> + ret = gpio_request_one(gpio, GPIOF_DIR_IN, ctx->ro_label);
> + if (ret < 0)
> + return ret;
> +
> + ctx->ro_gpio = gpio;
> +
> + return 0;
> }
> EXPORT_SYMBOL(mmc_gpio_request_ro);
>
> --
> Chris Ball <cjb@laptop.org> <http://printf.net/>
> One Laptop Per Child
>
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-09-10 21:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-09 3:00 [PATCH] mmc: slot-gpio: Fix missing assignment to ctx->ro_gpio Chris Ball
2012-09-09 21:21 ` Guennadi Liakhovetski
2012-09-10 2:56 ` [PATCH v2] " Chris Ball
2012-09-10 21:37 ` Guennadi Liakhovetski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox