mmc: slot-gpio: Fix missing assignment to ctx->ro_gpio
PATCH 1/1 mmc: slot-gpio: Fix missing assignment to ctx->ro_gpio
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.
--- drivers/mmc/core/slot-gpio.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/core/slot-gpio.c +1 -0
@@ -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); }
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Hi Chris
Quoted 15 lines · Chris Ball
mmc_gpio_request_ro()doesn't store the requested gpio inctx->ro_gpio. As a result, subsequent calls tommc_gpio_get_ro()will always fail with-ENOSYSbecause the gpio number isn't available to that function.Cc stable <[email protected]>Signed-off-by Chris Ball <[email protected]>--- drivers/mmc/core/slot-gpio.c | 1 + 1 file changed, 1 insertion(+)drivers/mmc/core/slot-gpio.c +0
-0
drivers/mmc/core/slot-gpio.c int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio) · line 102
Quoted 4 lines
drivers/mmc/core/slot-gpio.c +1
-0@@ -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
Quoted 7 lines
drivers/mmc/core/slot-gpio.c +0
-1return gpio_request_one (gpio,GPIOF_DIR_IN , ctx->ro_label); } --Chris Ball <[email protected]> <http://printf.net/>
One Laptop Per Child
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
PATCH v2 1/1 mmc: slot-gpio: Fix missing assignment to ctx->ro_gpio
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.
---
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(-)
drivers/mmc/core/slot-gpio.c +7 -1
@@ -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);
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Quoted 6 lines · Chris Ball
mmc_gpio_request_ro()doesn't store the requested gpio inctx->ro_gpio. As a result, subsequent calls tommc_gpio_get_ro()will always fail with-ENOSYSbecause the gpio number isn't available to that function.Cc stable <[email protected]>Signed-off-by Chris Ball <[email protected]>
Thanks
Guennadi
Quoted 31 lines
---
v2, addressing Guennadi's review comments:
- Ifgpio_request_one()fails,ctx->ro_gpioshouldn't contain a valid GPIO number.drivers/mmc/core/slot-gpio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/mmc/core/slot-gpio.c +7
-1@@ -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);Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/