Message ID | 87627mzitr.fsf_-_@octavius.laptop.org (mailing list archive) |
---|---|
State | Accepted, archived |
Headers | show |
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/ -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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);
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(-)