Patchwork [U-Boot,v2,1/2] omap_hsmmc: Check wp and cd GPIO for valid GPIO first

login
register
mail settings
Submitter Tom Rini
Date March 20, 2013, 6:46 p.m.
Message ID <1363805196-11408-1-git-send-email-trini@ti.com>
Download mbox | patch
Permalink /patch/229461/
State Superseded
Delegated to: Tom Rini
Headers show

Comments

Tom Rini - March 20, 2013, 6:46 p.m.
When we cannot check write protect or card change via GPIO (and have
been passed -1 in omap_mmc_init), only even try the gpio_is_valid is
true.  This prevents invalid GPIO messages from being seen on the
console when doing MMC operations

Signed-off-by: Tom Rini <trini@ti.com>

---
Changes in v2:
- Use gpio_is_valid not just a check for >= 0 (Fabio Estevam)
---
 drivers/mmc/omap_hsmmc.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
Nikita Kiryanov - March 21, 2013, 8:07 a.m.
Hi Tom,
a few style comments:

On 03/20/2013 08:46 PM, Tom Rini wrote:
> When we cannot check write protect or card change via GPIO (and have
> been passed -1 in omap_mmc_init), only even try the gpio_is_valid is
> true.

That last part needs rephrasing: "only try if gpio_is_valid() is true".

> This prevents invalid GPIO messages from being seen on the
> console when doing MMC operations
>
> Signed-off-by: Tom Rini <trini@ti.com>
>

[...]

> +	if (gpio_is_valid(cd_gpio))
> +		return gpio_get_value(cd_gpio);
> +	else
> +		return -1;

Also, the "else" word is not necessary in both checks.

Aside from that,
Acked-by: Nikita Kiryanov <nikita@compulab.co.il>
Nikita Kiryanov - March 21, 2013, 9:38 a.m.
Hi Tom,
a few style comments:

On 03/20/2013 08:46 PM, Tom Rini wrote:
> When we cannot check write protect or card change via GPIO (and have
> been passed -1 in omap_mmc_init), only even try the gpio_is_valid is
> true.

That last part needs rephrasing: "only try if gpio_is_valid() is true".

> This prevents invalid GPIO messages from being seen on the
> console when doing MMC operations
>
> Signed-off-by: Tom Rini <trini@ti.com>
>

[...]

> +    if (gpio_is_valid(cd_gpio))
> +        return gpio_get_value(cd_gpio);
> +    else
> +        return -1;

Also, the "else" word is not necessary (in both checks).

Aside from that,
Acked-by: Nikita Kiryanov <nikita@compulab.co.il>

Patch

diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index 67cfcc2..8a5dce5 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -73,13 +73,21 @@  static int omap_mmc_setup_gpio_in(int gpio, const char *label)
 static int omap_mmc_getcd(struct mmc *mmc)
 {
 	int cd_gpio = ((struct omap_hsmmc_data *)mmc->priv)->cd_gpio;
-	return gpio_get_value(cd_gpio);
+
+	if (gpio_is_valid(cd_gpio))
+		return gpio_get_value(cd_gpio);
+	else
+		return -1;
 }
 
 static int omap_mmc_getwp(struct mmc *mmc)
 {
 	int wp_gpio = ((struct omap_hsmmc_data *)mmc->priv)->wp_gpio;
-	return gpio_get_value(wp_gpio);
+
+	if (gpio_is_valid(wp_gpio))
+		return gpio_get_value(wp_gpio);
+	else
+		return -1;
 }
 #else
 static inline int omap_mmc_setup_gpio_in(int gpio, const char *label)