public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alex Deymo <deymo@google.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/6] disk: Return the partition number in part_get_info_by_name()
Date: Sun,  2 Apr 2017 01:49:50 -0700	[thread overview]
Message-ID: <20170402084952.5102-5-deymo@google.com> (raw)
In-Reply-To: <20170402084952.5102-4-deymo@google.com>

Similar to what blk_get_device_part_str() does, this patch makes
part_get_info_by_name() return the partition number in case of a match.
This is useful when the partition number is needed and not just the
descriptor.

Signed-off-by: Alex Deymo <deymo@google.com>
---
 common/fb_mmc.c | 6 +++---
 disk/part.c     | 2 +-
 include/part.h  | 3 ++-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index 6cc113d825..866982e41c 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -37,7 +37,7 @@ static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc,
 	int ret;
 
 	ret = part_get_info_by_name(dev_desc, name, info);
-	if (ret) {
+	if (ret < 0) {
 		/* strlen("fastboot_partition_alias_") + 32(part_name) + 1 */
 		char env_alias_name[25 + 32 + 1];
 		char *aliased_part_name;
@@ -153,7 +153,7 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,
 	}
 #endif
 
-	if (part_get_info_by_name_or_alias(dev_desc, cmd, &info)) {
+	if (part_get_info_by_name_or_alias(dev_desc, cmd, &info) < 0) {
 		error("cannot find partition: '%s'\n", cmd);
 		fastboot_fail("cannot find partition");
 		return;
@@ -205,7 +205,7 @@ void fb_mmc_erase(const char *cmd)
 	}
 
 	ret = part_get_info_by_name_or_alias(dev_desc, cmd, &info);
-	if (ret) {
+	if (ret < 0) {
 		error("cannot find partition: '%s'", cmd);
 		fastboot_fail("cannot find partition");
 		return;
diff --git a/disk/part.c b/disk/part.c
index cd447024c0..491b02dc9c 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -635,7 +635,7 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
 			}
 			if (strcmp(name, (const char *)info->name) == 0) {
 				/* matched */
-				return 0;
+				return i;
 			}
 		}
 	}
diff --git a/include/part.h b/include/part.h
index b6d1b33167..83bce05a43 100644
--- a/include/part.h
+++ b/include/part.h
@@ -163,7 +163,8 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
  * @param gpt_name - the specified table entry name
  * @param info - returns the disk partition info
  *
- * @return - '0' on match, '-1' on no match, otherwise error
+ * @return - the partition number on match (starting on 1), -1 on no match,
+ * otherwise error
  */
 int part_get_info_by_name(struct blk_desc *dev_desc,
 			      const char *name, disk_partition_t *info);
-- 
2.12.2.564.g063fe858b8-goog

  reply	other threads:[~2017-04-02  8:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <a74b3d5e65b4bf5c2edca98bba9e678be762ebe7>
2017-04-02  8:49 ` [U-Boot] [PATCH 0/6] Android A/B Bootloader support Alex Deymo
2017-04-02  8:49   ` [U-Boot] [PATCH 1/6] image: Update include/android_image.h Alex Deymo
2017-04-02  8:49     ` [U-Boot] [PATCH 2/6] image: Implement a function to load Android Images Alex Deymo
2017-04-02  8:49       ` [U-Boot] [PATCH 3/6] cmd: Add 'load_android' command to load Android images Alex Deymo
2017-04-02  8:49         ` Alex Deymo [this message]
2017-04-02  8:49           ` [U-Boot] [PATCH 5/6] Initial support for the Android Bootloader flow Alex Deymo
2017-04-02  8:49             ` [U-Boot] [PATCH 6/6] cmd: Add "boot_android" command Alex Deymo
2017-04-04 14:46               ` Lukasz Majewski
2017-04-09 19:27             ` [U-Boot] [PATCH 5/6] Initial support for the Android Bootloader flow Simon Glass
2017-04-06 22:42           ` [U-Boot] [PATCH 4/6] disk: Return the partition number in part_get_info_by_name() Simon Glass
2017-05-12 17:18           ` [U-Boot] [U-Boot, " Tom Rini
2017-04-06 22:42         ` [U-Boot] [PATCH 3/6] cmd: Add 'load_android' command to load Android images Simon Glass
2017-04-06 22:42       ` [U-Boot] [PATCH 2/6] image: Implement a function to load Android Images Simon Glass
2017-04-06 22:42     ` [U-Boot] [PATCH 1/6] image: Update include/android_image.h Simon Glass
2017-05-12 17:18     ` [U-Boot] [U-Boot,1/6] " Tom Rini
2017-04-19  8:42   ` [U-Boot] [PATCH 0/6] Android A/B Bootloader support Kever Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170402084952.5102-5-deymo@google.com \
    --to=deymo@google.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox