Skip to contentSkip to conversation

mmc: slot-gpio: Fix missing assignment to ctx->ro_gpio

PATCH Superseded Chris Ball 2 participants 4 messages Sep 9, 2012 – Sep 10, 2012 MMC, SD and SDIO

lore
Share & tools
lore

Chris Ball

author
#0 lore raw

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
index 0582429..4f9b366 100644
@@ -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
#1 lore raw

Hi Chris

Quoted 15 lines · Chris Ball

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 +0 -0
index 0582429..4f9b366 100644

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 -1
 	return 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/

author
#2 lore raw

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
index 0582429..08c6b3d 100644
@@ -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
Acked-by on v2 1/1
#3 lore raw
Quoted 6 lines · Chris Ball

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.

Thanks
Guennadi

Quoted 31 lines

---
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
index 0582429..08c6b3d 100644
@@ -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/