[U-Boot] [PATCH v6 08/18] cmd: gpt: remove blk_desc parameter in static function

Patrick Delaunay patrick.delaunay at st.com
Thu May 11 07:51:58 UTC 2017


this patch prepare GPT over MTD support
blk_desc is only available for block device but not for MTD device

Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/gpt.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/cmd/gpt.c b/cmd/gpt.c
index 3e98821..5dfbce5 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -155,7 +155,8 @@ static bool found_key(const char *str, const char *key)
  * set_gpt_info(): Fill partition information from string
  *		function allocates memory, remember to free!
  *
- * @param dev_desc - pointer block device descriptor
+ * @param lba - lba index
+ * @param blksz - block size for device
  * @param str_part - pointer to string with partition information
  * @param str_disk_guid - pointer to pointer to allocated string with disk guid
  * @param partitions - pointer to pointer to allocated partitions array
@@ -164,7 +165,8 @@ static bool found_key(const char *str, const char *key)
  * @return - zero on success, otherwise error
  *
  */
-static int set_gpt_info(struct blk_desc *dev_desc,
+static int set_gpt_info(unsigned int lba,
+			unsigned int blksz,
 			const char *str_part,
 			char **str_disk_guid,
 			disk_partition_t **partitions,
@@ -179,8 +181,7 @@ static int set_gpt_info(struct blk_desc *dev_desc,
 	uint64_t size_ll, start_ll;
 	lbaint_t offset = 0;
 
-	debug("%s:  lba num: 0x%x %d\n", __func__,
-	      (unsigned int)dev_desc->lba, (unsigned int)dev_desc->lba);
+	debug("%s:  lba num: 0x%x %d\n", __func__, lba, lba);
 
 	if (str_part == NULL)
 		return -1;
@@ -298,7 +299,7 @@ static int set_gpt_info(struct blk_desc *dev_desc,
 			parts[i].size = 0;
 		} else {
 			size_ll = ustrtoull(p, &p, 0);
-			parts[i].size = lldiv(size_ll, dev_desc->blksz);
+			parts[i].size = lldiv(size_ll, blksz);
 		}
 
 		free(val);
@@ -309,7 +310,7 @@ static int set_gpt_info(struct blk_desc *dev_desc,
 			if (extract_env(val, &p))
 				p = val;
 			start_ll = ustrtoull(p, &p, 0);
-			parts[i].start = lldiv(start_ll, dev_desc->blksz);
+			parts[i].start = lldiv(start_ll, blksz);
 			free(val);
 		}
 
@@ -341,7 +342,7 @@ static int gpt_default(struct blk_desc *blk_dev_desc, const char *str_part)
 	disk_partition_t *partitions = NULL;
 
 	/* fill partitions */
-	ret = set_gpt_info(blk_dev_desc, str_part,
+	ret = set_gpt_info(blk_dev_desc->lba, blk_dev_desc->blksz, str_part,
 			&str_disk_guid, &partitions, &part_count);
 	if (ret) {
 		if (ret == -1)
@@ -372,7 +373,7 @@ static int gpt_verify(struct blk_desc *blk_dev_desc, const char *str_part)
 	int ret = 0;
 
 	/* fill partitions */
-	ret = set_gpt_info(blk_dev_desc, str_part,
+	ret = set_gpt_info(blk_dev_desc->lba, blk_dev_desc->blksz, str_part,
 			&str_disk_guid, &partitions, &part_count);
 	if (ret) {
 		if (ret == -1) {
-- 
1.9.1



More information about the U-Boot mailing list