public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 1/2] omap_hsmmc: Check wp and cd GPIO for valid GPIO first
@ 2013-03-20 18:46 Tom Rini
  2013-03-20 18:46 ` [U-Boot] [PATCH v2 2/2] omap_hsmmc: Use -EINVAL not -1 for errors Tom Rini
  2013-03-21  8:07 ` [U-Boot] [PATCH v2 1/2] omap_hsmmc: Check wp and cd GPIO for valid GPIO first Nikita Kiryanov
  0 siblings, 2 replies; 4+ messages in thread
From: Tom Rini @ 2013-03-20 18:46 UTC (permalink / raw)
  To: u-boot

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(-)

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)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v2 2/2] omap_hsmmc: Use -EINVAL not -1 for errors
  2013-03-20 18:46 [U-Boot] [PATCH v2 1/2] omap_hsmmc: Check wp and cd GPIO for valid GPIO first Tom Rini
@ 2013-03-20 18:46 ` Tom Rini
  2013-03-21  8:07 ` [U-Boot] [PATCH v2 1/2] omap_hsmmc: Check wp and cd GPIO for valid GPIO first Nikita Kiryanov
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2013-03-20 18:46 UTC (permalink / raw)
  To: u-boot

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

---
Changes in v2:
- New patch, use -EINVAL in the driver
---
 drivers/mmc/omap_hsmmc.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index 8a5dce5..3055ac5 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -59,13 +59,13 @@ static struct omap_hsmmc_data hsmmc_dev_data[3];
 static int omap_mmc_setup_gpio_in(int gpio, const char *label)
 {
 	if (!gpio_is_valid(gpio))
-		return -1;
+		return -EINVAL;
 
 	if (gpio_request(gpio, label) < 0)
-		return -1;
+		return -EINVAL;
 
 	if (gpio_direction_input(gpio) < 0)
-		return -1;
+		return -EINVAL;
 
 	return gpio;
 }
@@ -77,7 +77,7 @@ static int omap_mmc_getcd(struct mmc *mmc)
 	if (gpio_is_valid(cd_gpio))
 		return gpio_get_value(cd_gpio);
 	else
-		return -1;
+		return -EINVAL;
 }
 
 static int omap_mmc_getwp(struct mmc *mmc)
@@ -87,12 +87,12 @@ static int omap_mmc_getwp(struct mmc *mmc)
 	if (gpio_is_valid(wp_gpio))
 		return gpio_get_value(wp_gpio);
 	else
-		return -1;
+		return -EINVAL;
 }
 #else
 static inline int omap_mmc_setup_gpio_in(int gpio, const char *label)
 {
-	return -1;
+	return -EINVAL;
 }
 
 #define omap_mmc_getcd NULL
@@ -401,7 +401,7 @@ static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
 		mmc_reset_controller_fsm(mmc_base, SYSCTL_SRC);
 		return TIMEOUT;
 	} else if ((mmc_stat & ERRI_MASK) != 0)
-		return -1;
+		return -EINVAL;
 
 	if (mmc_stat & CC_MASK) {
 		writel(CC_MASK, &mmc_base->stat);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v2 1/2] omap_hsmmc: Check wp and cd GPIO for valid GPIO first
  2013-03-20 18:46 [U-Boot] [PATCH v2 1/2] omap_hsmmc: Check wp and cd GPIO for valid GPIO first Tom Rini
  2013-03-20 18:46 ` [U-Boot] [PATCH v2 2/2] omap_hsmmc: Use -EINVAL not -1 for errors Tom Rini
@ 2013-03-21  8:07 ` Nikita Kiryanov
  2013-03-21  9:38   ` Nikita Kiryanov
  1 sibling, 1 reply; 4+ messages in thread
From: Nikita Kiryanov @ 2013-03-21  8:07 UTC (permalink / raw)
  To: u-boot

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>

-- 
Regards,
Nikita.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v2 1/2] omap_hsmmc: Check wp and cd GPIO for valid GPIO first
  2013-03-21  8:07 ` [U-Boot] [PATCH v2 1/2] omap_hsmmc: Check wp and cd GPIO for valid GPIO first Nikita Kiryanov
@ 2013-03-21  9:38   ` Nikita Kiryanov
  0 siblings, 0 replies; 4+ messages in thread
From: Nikita Kiryanov @ 2013-03-21  9:38 UTC (permalink / raw)
  To: u-boot

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>

-- 
Regards,
Nikita.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-03-21  9:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-20 18:46 [U-Boot] [PATCH v2 1/2] omap_hsmmc: Check wp and cd GPIO for valid GPIO first Tom Rini
2013-03-20 18:46 ` [U-Boot] [PATCH v2 2/2] omap_hsmmc: Use -EINVAL not -1 for errors Tom Rini
2013-03-21  8:07 ` [U-Boot] [PATCH v2 1/2] omap_hsmmc: Check wp and cd GPIO for valid GPIO first Nikita Kiryanov
2013-03-21  9:38   ` Nikita Kiryanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox