diff mbox

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

Message ID 87pq5vzyry.fsf@octavius.laptop.org (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Chris Ball Sept. 9, 2012, 3 a.m. UTC
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(+)

Comments

Guennadi Liakhovetski Sept. 9, 2012, 9:21 p.m. UTC | #1
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/
--
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 mbox

Patch

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);
 }