public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] mmc: return meaningful error codes from mmc_select_hwpart
@ 2014-05-23 18:47 Stephen Warren
  2014-05-30 21:11 ` Stephen Warren
  2014-06-02  6:18 ` Pantelis Antoniou
  0 siblings, 2 replies; 5+ messages in thread
From: Stephen Warren @ 2014-05-23 18:47 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

Rather than just returning -1 everywhere, try to return something
meaningful from mmc_select_hwpart(). Note that most other MMC functions
don't do this, including functions called from mmc_select_hwpart(), so
I'm not sure how effective this will be. Still, it's one less place with
hard-coded -1.

Suggested-by: Pantelis Antoniou <panto@antoniou-consulting.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 drivers/mmc/mmc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 8b53ead98f80..221a293797e9 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -10,6 +10,7 @@
 #include <config.h>
 #include <common.h>
 #include <command.h>
+#include <errno.h>
 #include <mmc.h>
 #include <part.h>
 #include <malloc.h>
@@ -558,19 +559,19 @@ int mmc_select_hwpart(int dev_num, int hwpart)
 	int ret;
 
 	if (!mmc)
-		return -1;
+		return -ENODEV;
 
 	if (mmc->part_num == hwpart)
 		return 0;
 
 	if (mmc->part_config == MMCPART_NOAVAILABLE) {
 		printf("Card doesn't support part_switch\n");
-		return -1;
+		return -EMEDIUMTYPE;
 	}
 
 	ret = mmc_switch_part(dev_num, hwpart);
 	if (ret)
-		return -1;
+		return ret;
 
 	mmc->part_num = hwpart;
 
-- 
1.8.1.5

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

* [U-Boot] [PATCH] mmc: return meaningful error codes from mmc_select_hwpart
  2014-05-23 18:47 [U-Boot] [PATCH] mmc: return meaningful error codes from mmc_select_hwpart Stephen Warren
@ 2014-05-30 21:11 ` Stephen Warren
  2014-06-02  6:18 ` Pantelis Antoniou
  1 sibling, 0 replies; 5+ messages in thread
From: Stephen Warren @ 2014-05-30 21:11 UTC (permalink / raw)
  To: u-boot

On 05/23/2014 12:47 PM, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> Rather than just returning -1 everywhere, try to return something
> meaningful from mmc_select_hwpart(). Note that most other MMC functions
> don't do this, including functions called from mmc_select_hwpart(), so
> I'm not sure how effective this will be. Still, it's one less place with
> hard-coded -1.

Pantelis, does this look good?

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

* [U-Boot] [PATCH] mmc: return meaningful error codes from mmc_select_hwpart
  2014-05-23 18:47 [U-Boot] [PATCH] mmc: return meaningful error codes from mmc_select_hwpart Stephen Warren
  2014-05-30 21:11 ` Stephen Warren
@ 2014-06-02  6:18 ` Pantelis Antoniou
  2014-06-10 16:00   ` Stephen Warren
  1 sibling, 1 reply; 5+ messages in thread
From: Pantelis Antoniou @ 2014-06-02  6:18 UTC (permalink / raw)
  To: u-boot

Hi Stephen,

On May 23, 2014, at 9:47 PM, Stephen Warren wrote:

> From: Stephen Warren <swarren@nvidia.com>
> 
> Rather than just returning -1 everywhere, try to return something
> meaningful from mmc_select_hwpart(). Note that most other MMC functions
> don't do this, including functions called from mmc_select_hwpart(), so
> I'm not sure how effective this will be. Still, it's one less place with
> hard-coded -1.
> 
> Suggested-by: Pantelis Antoniou <panto@antoniou-consulting.com>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
> drivers/mmc/mmc.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 8b53ead98f80..221a293797e9 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -10,6 +10,7 @@
> #include <config.h>
> #include <common.h>
> #include <command.h>
> +#include <errno.h>
> #include <mmc.h>
> #include <part.h>
> #include <malloc.h>
> @@ -558,19 +559,19 @@ int mmc_select_hwpart(int dev_num, int hwpart)
> 	int ret;
> 
> 	if (!mmc)
> -		return -1;
> +		return -ENODEV;
> 
> 	if (mmc->part_num == hwpart)
> 		return 0;
> 
> 	if (mmc->part_config == MMCPART_NOAVAILABLE) {
> 		printf("Card doesn't support part_switch\n");
> -		return -1;
> +		return -EMEDIUMTYPE;
> 	}
> 
> 	ret = mmc_switch_part(dev_num, hwpart);
> 	if (ret)
> -		return -1;
> +		return ret;
> 
> 	mmc->part_num = hwpart;
> 
> -- 
> 1.8.1.5
> 

This does indeed look good.

Thanks

-- Pantelis

Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>

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

* [U-Boot] [PATCH] mmc: return meaningful error codes from mmc_select_hwpart
  2014-06-02  6:18 ` Pantelis Antoniou
@ 2014-06-10 16:00   ` Stephen Warren
  2014-06-10 16:01     ` Pantelis Antoniou
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Warren @ 2014-06-10 16:00 UTC (permalink / raw)
  To: u-boot

On 06/02/2014 12:18 AM, Pantelis Antoniou wrote:
> On May 23, 2014, at 9:47 PM, Stephen Warren wrote:
>> Rather than just returning -1 everywhere, try to return something
>> meaningful from mmc_select_hwpart(). Note that most other MMC functions
>> don't do this, including functions called from mmc_select_hwpart(), so
>> I'm not sure how effective this will be. Still, it's one less place with
>> hard-coded -1.
...
> This does indeed look good.
...
> Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>

Are you intending to apply this patch, or were you expecting someone
else to?

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

* [U-Boot] [PATCH] mmc: return meaningful error codes from mmc_select_hwpart
  2014-06-10 16:00   ` Stephen Warren
@ 2014-06-10 16:01     ` Pantelis Antoniou
  0 siblings, 0 replies; 5+ messages in thread
From: Pantelis Antoniou @ 2014-06-10 16:01 UTC (permalink / raw)
  To: u-boot


On Jun 10, 2014, at 7:00 PM, Stephen Warren wrote:

> On 06/02/2014 12:18 AM, Pantelis Antoniou wrote:
>> On May 23, 2014, at 9:47 PM, Stephen Warren wrote:
>>> Rather than just returning -1 everywhere, try to return something
>>> meaningful from mmc_select_hwpart(). Note that most other MMC functions
>>> don't do this, including functions called from mmc_select_hwpart(), so
>>> I'm not sure how effective this will be. Still, it's one less place with
>>> hard-coded -1.
> ...
>> This does indeed look good.
> ...
>> Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
> 
> Are you intending to apply this patch, or were you expecting someone
> else to?

I will apply the patch, but it will go out with the rest on the next
mmc pull request this week.

Regards

-- Pantelis

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

end of thread, other threads:[~2014-06-10 16:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-23 18:47 [U-Boot] [PATCH] mmc: return meaningful error codes from mmc_select_hwpart Stephen Warren
2014-05-30 21:11 ` Stephen Warren
2014-06-02  6:18 ` Pantelis Antoniou
2014-06-10 16:00   ` Stephen Warren
2014-06-10 16:01     ` Pantelis Antoniou

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