All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] cmd/gpt: Support gpt command for all devices.
@ 2013-03-26  9:05 egbert.eich at googlemail.com
  2013-03-26 14:04 ` Wolfgang Denk
  2013-04-09 15:11 ` [U-Boot] [Patch v2] " Egbert Eich
  0 siblings, 2 replies; 7+ messages in thread
From: egbert.eich at googlemail.com @ 2013-03-26  9:05 UTC (permalink / raw)
  To: u-boot

From: Egbert Eich <eich@suse.com>

The gpt command was only implemented for mmc devices. There is no reason
why this command should not be generalized and be applied all other
storage device classes.
This change both simplifies the implementation and eliminates a
build failure for systems that don't support mmcs.

Signed-off-by: Egbert Eich <eich@suse.com>
---
 common/cmd_gpt.c |   43 ++++++++++++++++++-------------------------
 1 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/common/cmd_gpt.c b/common/cmd_gpt.c
index efd7934..1a72e8e 100644
--- a/common/cmd_gpt.c
+++ b/common/cmd_gpt.c
@@ -23,7 +23,6 @@
 #include <common.h>
 #include <malloc.h>
 #include <command.h>
-#include <mmc.h>
 #include <part_efi.h>
 #include <exports.h>
 #include <linux/ctype.h>
@@ -134,7 +133,7 @@ static int set_gpt_info(block_dev_desc_t *dev_desc,
 	int errno = 0;
 	uint64_t size_ll, start_ll;
 
-	debug("%s: MMC lba num: 0x%x %d\n", __func__,
+	debug("%s:  lba num: 0x%x %d\n", __func__,
 	      (unsigned int)dev_desc->lba, (unsigned int)dev_desc->lba);
 
 	if (str_part == NULL)
@@ -247,25 +246,18 @@ err:
 	return errno;
 }
 
-static int gpt_mmc_default(int dev, const char *str_part)
+static int gpt_default(block_dev_desc_t *blk_dev_desc, const char *str_part)
 {
 	int ret;
 	char *str_disk_guid;
 	u8 part_count = 0;
 	disk_partition_t *partitions = NULL;
 
-	struct mmc *mmc = find_mmc_device(dev);
-
-	if (mmc == NULL) {
-		printf("%s: mmc dev %d NOT available\n", __func__, dev);
-		return CMD_RET_FAILURE;
-	}
-
 	if (!str_part)
 		return -1;
 
 	/* fill partitions */
-	ret = set_gpt_info(&mmc->block_dev, str_part,
+	ret = set_gpt_info(blk_dev_desc, str_part,
 			&str_disk_guid, &partitions, &part_count);
 	if (ret) {
 		if (ret == -1)
@@ -278,7 +270,7 @@ static int gpt_mmc_default(int dev, const char *str_part)
 	}
 
 	/* save partitions layout to disk */
-	gpt_restore(&mmc->block_dev, str_disk_guid, partitions, part_count);
+	gpt_restore(&blk_dev_desc, str_disk_guid, partitions, part_count);
 	free(str_disk_guid);
 	free(partitions);
 
@@ -306,20 +298,21 @@ static int do_gpt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	/* command: 'write' */
 	if ((strcmp(argv[1], "write") == 0) && (argc == 5)) {
-		/* device: 'mmc' */
-		if (strcmp(argv[2], "mmc") == 0) {
-			/* check if 'dev' is a number */
-			for (pstr = argv[3]; *pstr != '\0'; pstr++)
-				if (!isdigit(*pstr)) {
-					printf("'%s' is not a number\n",
-						argv[3]);
-					return CMD_RET_USAGE;
-				}
-			dev = (int)simple_strtoul(argv[3], NULL, 10);
-			/* write to mmc */
-			if (gpt_mmc_default(dev, argv[4]))
-				return CMD_RET_FAILURE;
+		char *ep;
+		block_dev_desc_t *blk_dev_desc;
+		dev = (int)simple_strtoul(argv[3], NULL, 10);
+		if (*ep) {
+			printf("'%s' is not a number\n", argv[3]);
+			return CMD_RET_USAGE;
 		}
+		blk_dev_desc = get_dev(argv[2], dev);
+		if (!blk_dev_desc) {
+			printf("%s: %s dev %d NOT available\n", __func__, argv[2], dev);
+			return CMD_RET_FAILURE;
+		}
+
+		if (gpt_default(blk_dev_desc, argv[4]))
+			return CMD_RET_FAILURE;
 	} else {
 		return CMD_RET_USAGE;
 	}
-- 
1.7.7

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

* [U-Boot] [PATCH] cmd/gpt: Support gpt command for all devices.
  2013-03-26  9:05 [U-Boot] [PATCH] cmd/gpt: Support gpt command for all devices egbert.eich at googlemail.com
@ 2013-03-26 14:04 ` Wolfgang Denk
  2013-04-09 15:11 ` [U-Boot] [Patch v2] " Egbert Eich
  1 sibling, 0 replies; 7+ messages in thread
From: Wolfgang Denk @ 2013-03-26 14:04 UTC (permalink / raw)
  To: u-boot

Dear egbert.eich at googlemail.com,

In message <1364288746-2597-1-git-send-email-egbert.eich@gmail.com> you wrote:
> From: Egbert Eich <eich@suse.com>
> 
> The gpt command was only implemented for mmc devices. There is no reason
> why this command should not be generalized and be applied all other
> storage device classes.
> This change both simplifies the implementation and eliminates a
> build failure for systems that don't support mmcs.
> 
> Signed-off-by: Egbert Eich <eich@suse.com>
> ---
>  common/cmd_gpt.c |   43 ++++++++++++++++++-------------------------
>  1 files changed, 18 insertions(+), 25 deletions(-)

Please mark resubmits of new versions of patches as such; also, please
provide a change log so we can see what you actually changed.  Please
see [1] for detailled instructions, and consider using patman to help
you doing this.

[1] http://www.denx.de/wiki/view/U-Boot/Patches#Sending_updated_patch_versions

Note that this patch is still not checkpatch-clean:

WARNING: line over 80 characters
#195: FILE: common/cmd_gpt.c:310:
+                       printf("%s: %s dev %d NOT available\n", __func__, argv[2], dev);

Please fix!!

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
As a general rule, the freedom of any people can  be  judged  by  the
volume of their laughter.

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

* [U-Boot] [Patch v2] cmd/gpt: Support gpt command for all devices
  2013-03-26  9:05 [U-Boot] [PATCH] cmd/gpt: Support gpt command for all devices egbert.eich at googlemail.com
  2013-03-26 14:04 ` Wolfgang Denk
@ 2013-04-09 15:11 ` Egbert Eich
  2013-04-09 15:28   ` Tom Rini
  2013-04-10 13:44   ` Piotr Wilczek
  1 sibling, 2 replies; 7+ messages in thread
From: Egbert Eich @ 2013-04-09 15:11 UTC (permalink / raw)
  To: u-boot

From: Egbert Eich <eich@suse.com>

The gpt command was only implemented for mmc devices. There is no reason
why this command should not be generalized and be applied all other
storage device classes.
This change both simplifies the implementation and eliminates a
build failure for systems that don't support mmcs.

Signed-off-by: Egbert Eich <eich@suse.com>
---
Changes for v2:
  - Coding style cleanup.

 common/cmd_gpt.c | 44 +++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 25 deletions(-)

diff --git a/common/cmd_gpt.c b/common/cmd_gpt.c
index efd7934..3594dca 100644
--- a/common/cmd_gpt.c
+++ b/common/cmd_gpt.c
@@ -23,7 +23,6 @@
 #include <common.h>
 #include <malloc.h>
 #include <command.h>
-#include <mmc.h>
 #include <part_efi.h>
 #include <exports.h>
 #include <linux/ctype.h>
@@ -134,7 +133,7 @@ static int set_gpt_info(block_dev_desc_t *dev_desc,
 	int errno = 0;
 	uint64_t size_ll, start_ll;
 
-	debug("%s: MMC lba num: 0x%x %d\n", __func__,
+	debug("%s:  lba num: 0x%x %d\n", __func__,
 	      (unsigned int)dev_desc->lba, (unsigned int)dev_desc->lba);
 
 	if (str_part == NULL)
@@ -247,25 +246,18 @@ err:
 	return errno;
 }
 
-static int gpt_mmc_default(int dev, const char *str_part)
+static int gpt_default(block_dev_desc_t *blk_dev_desc, const char *str_part)
 {
 	int ret;
 	char *str_disk_guid;
 	u8 part_count = 0;
 	disk_partition_t *partitions = NULL;
 
-	struct mmc *mmc = find_mmc_device(dev);
-
-	if (mmc == NULL) {
-		printf("%s: mmc dev %d NOT available\n", __func__, dev);
-		return CMD_RET_FAILURE;
-	}
-
 	if (!str_part)
 		return -1;
 
 	/* fill partitions */
-	ret = set_gpt_info(&mmc->block_dev, str_part,
+	ret = set_gpt_info(blk_dev_desc, str_part,
 			&str_disk_guid, &partitions, &part_count);
 	if (ret) {
 		if (ret == -1)
@@ -278,7 +270,7 @@ static int gpt_mmc_default(int dev, const char *str_part)
 	}
 
 	/* save partitions layout to disk */
-	gpt_restore(&mmc->block_dev, str_disk_guid, partitions, part_count);
+	gpt_restore(&blk_dev_desc, str_disk_guid, partitions, part_count);
 	free(str_disk_guid);
 	free(partitions);
 
@@ -306,20 +298,22 @@ static int do_gpt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	/* command: 'write' */
 	if ((strcmp(argv[1], "write") == 0) && (argc == 5)) {
-		/* device: 'mmc' */
-		if (strcmp(argv[2], "mmc") == 0) {
-			/* check if 'dev' is a number */
-			for (pstr = argv[3]; *pstr != '\0'; pstr++)
-				if (!isdigit(*pstr)) {
-					printf("'%s' is not a number\n",
-						argv[3]);
-					return CMD_RET_USAGE;
-				}
-			dev = (int)simple_strtoul(argv[3], NULL, 10);
-			/* write to mmc */
-			if (gpt_mmc_default(dev, argv[4]))
-				return CMD_RET_FAILURE;
+		char *ep;
+		block_dev_desc_t *blk_dev_desc;
+		dev = (int)simple_strtoul(argv[3], NULL, 10);
+		if (*ep) {
+			printf("'%s' is not a number\n", argv[3]);
+			return CMD_RET_USAGE;
 		}
+		blk_dev_desc = get_dev(argv[2], dev);
+		if (!blk_dev_desc) {
+			printf("%s: %s dev %d NOT available\n",
+			       __func__, argv[2], dev);
+			return CMD_RET_FAILURE;
+		}
+
+		if (gpt_default(blk_dev_desc, argv[4]))
+			return CMD_RET_FAILURE;
 	} else {
 		return CMD_RET_USAGE;
 	}
-- 
1.8.1.4

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

* [U-Boot] [Patch v2] cmd/gpt: Support gpt command for all devices
  2013-04-09 15:11 ` [U-Boot] [Patch v2] " Egbert Eich
@ 2013-04-09 15:28   ` Tom Rini
  2013-04-10 13:44   ` Piotr Wilczek
  1 sibling, 0 replies; 7+ messages in thread
From: Tom Rini @ 2013-04-09 15:28 UTC (permalink / raw)
  To: u-boot

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/09/2013 11:11 AM, Egbert Eich wrote:
> From: Egbert Eich <eich@suse.com>
> 
> The gpt command was only implemented for mmc devices. There is no 
> reason why this command should not be generalized and be applied 
> all other storage device classes. This change both simplifies the 
> implementation and eliminates a build failure for systems that 
> don't support mmcs.
> 
> Signed-off-by: Egbert Eich <eich@suse.com> --- Changes for v2: - 
> Coding style cleanup.
> 
> common/cmd_gpt.c | 44 +++++++++++++++++++-------------------------
>  1 file changed, 19 insertions(+), 25 deletions(-)

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

Thanks!

- -- 
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJRZDOLAAoJENk4IS6UOR1WdAwP/jUM63BXUnoe1ZdL40MjjK8W
ML48SoHv14unwjHB3Nr5fl4EGQOGpWN18HB7h/tGVdcZPCu6MaP3VQR+dV9iWDlh
ijwv0b390ojj2Hb9tqOy3VEt+v/jrOJOcfDdgheDkfs/82d6NysJnbxbmfCTbtFv
B68ToxYNKv2LirLz/HC4lUYWLekfwLSgqK+lcwA0WqgylnUuANa05d+VD8LUzPem
bPDzn7dhoMmhaCqfzyRhPCsdT3RREGeFNqQ3rkhmdXZ359Zj7ex2z0oVzzzxbWPy
mes60Hj9l6zRayiR2NQ4eiB31jJWM5EPj2mzKCV/XGIj7C/unecbfbt8JxJlTnUg
gkT8Y1b3vBSf18Zh6GrUBJRcofVbfj3e5hQJ8t36ItQqX8iPJu0lVCXVed8y+67I
u+WCQ6LIZroSYUM+f+U2S2ZPyRMq2gyp9C+P6VPXtQTL6v2qZEezZhsKzlNwKiql
UDZLMK3KafaWY52hXrld5d49fPpaufHS+2CfWR4+2tM2sFgHhXjCuBVwwcL7iJF1
E1gtJF77sFnGk8Dwcb/WGGbqbLw6kc+cMyIMKowLulvluQsbPkl2UWen4YI4Kom2
7+Z4wLVp9MExKAZ7F5ySjkCJ5LwE3VE8COZCzOfNYE4dfun2IPkGHguywGG/udQK
D8YnUvj3CfcACvYC/ZBt
=PcsZ
-----END PGP SIGNATURE-----

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

* [U-Boot] [Patch v2] cmd/gpt: Support gpt command for all devices
  2013-04-09 15:11 ` [U-Boot] [Patch v2] " Egbert Eich
  2013-04-09 15:28   ` Tom Rini
@ 2013-04-10 13:44   ` Piotr Wilczek
  1 sibling, 0 replies; 7+ messages in thread
From: Piotr Wilczek @ 2013-04-10 13:44 UTC (permalink / raw)
  To: u-boot

Dear Egbert Eich,

> -----Original Message-----
> From: Egbert Eich [mailto:egbert.eich at gmail.com]
> Sent: Tuesday, April 09, 2013 5:12 PM
> To: u-boot at lists.denx.de
> Cc: Piotr Wilczek; Egbert Eich
> Subject: [Patch v2] cmd/gpt: Support gpt command for all devices
> 
> From: Egbert Eich <eich@suse.com>
> 
> The gpt command was only implemented for mmc devices. There is no
> reason why this command should not be generalized and be applied all
> other storage device classes.
> This change both simplifies the implementation and eliminates a build
> failure for systems that don't support mmcs.
> 
> Signed-off-by: Egbert Eich <eich@suse.com>
> ---
> Changes for v2:
>   - Coding style cleanup.
> 
>  common/cmd_gpt.c | 44 +++++++++++++++++++-------------------------
>  1 file changed, 19 insertions(+), 25 deletions(-)
> 
> diff --git a/common/cmd_gpt.c b/common/cmd_gpt.c index efd7934..3594dca
> 100644
> --- a/common/cmd_gpt.c
> +++ b/common/cmd_gpt.c
> @@ -23,7 +23,6 @@
>  #include <common.h>
>  #include <malloc.h>
>  #include <command.h>
> -#include <mmc.h>
>  #include <part_efi.h>
>  #include <exports.h>
>  #include <linux/ctype.h>
> @@ -134,7 +133,7 @@ static int set_gpt_info(block_dev_desc_t *dev_desc,
>  	int errno = 0;
>  	uint64_t size_ll, start_ll;
> 
> -	debug("%s: MMC lba num: 0x%x %d\n", __func__,
> +	debug("%s:  lba num: 0x%x %d\n", __func__,
>  	      (unsigned int)dev_desc->lba, (unsigned int)dev_desc->lba);
> 
>  	if (str_part == NULL)
> @@ -247,25 +246,18 @@ err:
>  	return errno;
>  }
> 
> -static int gpt_mmc_default(int dev, const char *str_part)
> +static int gpt_default(block_dev_desc_t *blk_dev_desc, const char
> +*str_part)
>  {
>  	int ret;
>  	char *str_disk_guid;
>  	u8 part_count = 0;
>  	disk_partition_t *partitions = NULL;
> 
> -	struct mmc *mmc = find_mmc_device(dev);
> -
> -	if (mmc == NULL) {
> -		printf("%s: mmc dev %d NOT available\n", __func__, dev);
> -		return CMD_RET_FAILURE;
> -	}
> -
>  	if (!str_part)
>  		return -1;
> 
>  	/* fill partitions */
> -	ret = set_gpt_info(&mmc->block_dev, str_part,
> +	ret = set_gpt_info(blk_dev_desc, str_part,
>  			&str_disk_guid, &partitions, &part_count);
>  	if (ret) {
>  		if (ret == -1)
> @@ -278,7 +270,7 @@ static int gpt_mmc_default(int dev, const char
> *str_part)
>  	}
> 
>  	/* save partitions layout to disk */
> -	gpt_restore(&mmc->block_dev, str_disk_guid, partitions,
> part_count);
> +	gpt_restore(&blk_dev_desc, str_disk_guid, partitions,
> part_count);
'blk_dev_desc' is a pointer, no need to take its address

>  	free(str_disk_guid);
>  	free(partitions);
> 
> @@ -306,20 +298,22 @@ static int do_gpt(cmd_tbl_t *cmdtp, int flag, int
> argc, char * const argv[])
> 
>  	/* command: 'write' */
>  	if ((strcmp(argv[1], "write") == 0) && (argc == 5)) {
> -		/* device: 'mmc' */
> -		if (strcmp(argv[2], "mmc") == 0) {
> -			/* check if 'dev' is a number */
> -			for (pstr = argv[3]; *pstr != '\0'; pstr++)
> -				if (!isdigit(*pstr)) {
> -					printf("'%s' is not a number\n",
> -						argv[3]);
> -					return CMD_RET_USAGE;
> -				}
> -			dev = (int)simple_strtoul(argv[3], NULL, 10);
> -			/* write to mmc */
> -			if (gpt_mmc_default(dev, argv[4]))
> -				return CMD_RET_FAILURE;
> +		char *ep;
> +		block_dev_desc_t *blk_dev_desc;
> +		dev = (int)simple_strtoul(argv[3], NULL, 10);
> +		if (*ep) {
warning: 'ep' may be used uninitialized in this function
shouldn't the address of 'ep' be passed to 'simple_strtoul' and then
compared with argv[3]?

> +			printf("'%s' is not a number\n", argv[3]);
> +			return CMD_RET_USAGE;
>  		}
> +		blk_dev_desc = get_dev(argv[2], dev);
> +		if (!blk_dev_desc) {
> +			printf("%s: %s dev %d NOT available\n",
> +			       __func__, argv[2], dev);
> +			return CMD_RET_FAILURE;
> +		}
> +
> +		if (gpt_default(blk_dev_desc, argv[4]))
> +			return CMD_RET_FAILURE;
unused 'pstr' variable can be removed

>  	} else {
>  		return CMD_RET_USAGE;
>  	}
> --
> 1.8.1.4

Best ragards,
Piotr Wilczek

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

* [U-Boot] [PATCH] cmd/gpt: Support gpt command for all devices.
  2013-03-26  8:01 [U-Boot] [PATCH] " egbert.eich at googlemail.com
@ 2013-03-26 11:29 ` Wolfgang Denk
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Denk @ 2013-03-26 11:29 UTC (permalink / raw)
  To: u-boot

Dear egbert.eich at googlemail.com,

In message <1364284913-2277-1-git-send-email-egbert.eich@gmail.com> you wrote:
> From: Egbert Eich <eich@suse.com>
> 
> The gpt command was only implemented for mmc devices. There is no reason
> why this command should not be generalized and be applied all other
> storage device classes.
> This change both simplifies the implementation and eliminates a
> build failure for systems that don't support mmcs.
> 
> Signed-off-by: Egbert Eich <eich@suse.com>
> ---
>  common/cmd_gpt.c |   43 ++++++++++++++++++-------------------------
>  1 files changed, 18 insertions(+), 25 deletions(-)

WARNING: line over 80 characters
#198: FILE: common/cmd_gpt.c:310:
+                       printf("%s: %s dev %d NOT available\n", __func__, argv[2], dev);

Please fix.

and please always run all your patches through checkpatch - before
submitting!


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"May the forces of evil become confused on the way to your house."
- George Carlin

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

* [U-Boot] [PATCH] cmd/gpt: Support gpt command for all devices.
@ 2013-03-26  8:01 egbert.eich at googlemail.com
  2013-03-26 11:29 ` Wolfgang Denk
  0 siblings, 1 reply; 7+ messages in thread
From: egbert.eich at googlemail.com @ 2013-03-26  8:01 UTC (permalink / raw)
  To: u-boot

From: Egbert Eich <eich@suse.com>

The gpt command was only implemented for mmc devices. There is no reason
why this command should not be generalized and be applied all other
storage device classes.
This change both simplifies the implementation and eliminates a
build failure for systems that don't support mmcs.

Signed-off-by: Egbert Eich <eich@suse.com>
---
 common/cmd_gpt.c |   43 ++++++++++++++++++-------------------------
 1 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/common/cmd_gpt.c b/common/cmd_gpt.c
index efd7934..1a72e8e 100644
--- a/common/cmd_gpt.c
+++ b/common/cmd_gpt.c
@@ -23,7 +23,6 @@
 #include <common.h>
 #include <malloc.h>
 #include <command.h>
-#include <mmc.h>
 #include <part_efi.h>
 #include <exports.h>
 #include <linux/ctype.h>
@@ -134,7 +133,7 @@ static int set_gpt_info(block_dev_desc_t *dev_desc,
 	int errno = 0;
 	uint64_t size_ll, start_ll;
 
-	debug("%s: MMC lba num: 0x%x %d\n", __func__,
+	debug("%s:  lba num: 0x%x %d\n", __func__,
 	      (unsigned int)dev_desc->lba, (unsigned int)dev_desc->lba);
 
 	if (str_part == NULL)
@@ -247,25 +246,18 @@ err:
 	return errno;
 }
 
-static int gpt_mmc_default(int dev, const char *str_part)
+static int gpt_default(block_dev_desc_t *blk_dev_desc, const char *str_part)
 {
 	int ret;
 	char *str_disk_guid;
 	u8 part_count = 0;
 	disk_partition_t *partitions = NULL;
 
-	struct mmc *mmc = find_mmc_device(dev);
-
-	if (mmc == NULL) {
-		printf("%s: mmc dev %d NOT available\n", __func__, dev);
-		return CMD_RET_FAILURE;
-	}
-
 	if (!str_part)
 		return -1;
 
 	/* fill partitions */
-	ret = set_gpt_info(&mmc->block_dev, str_part,
+	ret = set_gpt_info(blk_dev_desc, str_part,
 			&str_disk_guid, &partitions, &part_count);
 	if (ret) {
 		if (ret == -1)
@@ -278,7 +270,7 @@ static int gpt_mmc_default(int dev, const char *str_part)
 	}
 
 	/* save partitions layout to disk */
-	gpt_restore(&mmc->block_dev, str_disk_guid, partitions, part_count);
+	gpt_restore(&blk_dev_desc, str_disk_guid, partitions, part_count);
 	free(str_disk_guid);
 	free(partitions);
 
@@ -306,20 +298,21 @@ static int do_gpt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	/* command: 'write' */
 	if ((strcmp(argv[1], "write") == 0) && (argc == 5)) {
-		/* device: 'mmc' */
-		if (strcmp(argv[2], "mmc") == 0) {
-			/* check if 'dev' is a number */
-			for (pstr = argv[3]; *pstr != '\0'; pstr++)
-				if (!isdigit(*pstr)) {
-					printf("'%s' is not a number\n",
-						argv[3]);
-					return CMD_RET_USAGE;
-				}
-			dev = (int)simple_strtoul(argv[3], NULL, 10);
-			/* write to mmc */
-			if (gpt_mmc_default(dev, argv[4]))
-				return CMD_RET_FAILURE;
+		char *ep;
+		block_dev_desc_t *blk_dev_desc;
+		dev = (int)simple_strtoul(argv[3], NULL, 10);
+		if (*ep) {
+			printf("'%s' is not a number\n", argv[3]);
+			return CMD_RET_USAGE;
 		}
+		blk_dev_desc = get_dev(argv[2], dev);
+		if (!blk_dev_desc) {
+			printf("%s: %s dev %d NOT available\n", __func__, argv[2], dev);
+			return CMD_RET_FAILURE;
+		}
+
+		if (gpt_default(blk_dev_desc, argv[4]))
+			return CMD_RET_FAILURE;
 	} else {
 		return CMD_RET_USAGE;
 	}
-- 
1.7.7

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

end of thread, other threads:[~2013-04-10 13:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-26  9:05 [U-Boot] [PATCH] cmd/gpt: Support gpt command for all devices egbert.eich at googlemail.com
2013-03-26 14:04 ` Wolfgang Denk
2013-04-09 15:11 ` [U-Boot] [Patch v2] " Egbert Eich
2013-04-09 15:28   ` Tom Rini
2013-04-10 13:44   ` Piotr Wilczek
  -- strict thread matches above, loose matches on Subject: below --
2013-03-26  8:01 [U-Boot] [PATCH] " egbert.eich at googlemail.com
2013-03-26 11:29 ` Wolfgang Denk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.