Commit 88b6329cce9b344159ac7d708f8f2d6bfd98faf0
Committed by
Tom Rini
1 parent
210a7176ee
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
disk: Return the partition number in part_get_info_by_name()
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> Reviewed-by: Simon Glass <sjg@chromium.org>
Showing 3 changed files with 6 additions and 5 deletions Side-by-side Diff
common/fb_mmc.c
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | int ret; |
38 | 38 | |
39 | 39 | ret = part_get_info_by_name(dev_desc, name, info); |
40 | - if (ret) { | |
40 | + if (ret < 0) { | |
41 | 41 | /* strlen("fastboot_partition_alias_") + 32(part_name) + 1 */ |
42 | 42 | char env_alias_name[25 + 32 + 1]; |
43 | 43 | char *aliased_part_name; |
... | ... | @@ -153,7 +153,7 @@ |
153 | 153 | } |
154 | 154 | #endif |
155 | 155 | |
156 | - if (part_get_info_by_name_or_alias(dev_desc, cmd, &info)) { | |
156 | + if (part_get_info_by_name_or_alias(dev_desc, cmd, &info) < 0) { | |
157 | 157 | error("cannot find partition: '%s'\n", cmd); |
158 | 158 | fastboot_fail("cannot find partition"); |
159 | 159 | return; |
... | ... | @@ -205,7 +205,7 @@ |
205 | 205 | } |
206 | 206 | |
207 | 207 | ret = part_get_info_by_name_or_alias(dev_desc, cmd, &info); |
208 | - if (ret) { | |
208 | + if (ret < 0) { | |
209 | 209 | error("cannot find partition: '%s'", cmd); |
210 | 210 | fastboot_fail("cannot find partition"); |
211 | 211 | return; |
disk/part.c
include/part.h
... | ... | @@ -163,7 +163,8 @@ |
163 | 163 | * @param gpt_name - the specified table entry name |
164 | 164 | * @param info - returns the disk partition info |
165 | 165 | * |
166 | - * @return - '0' on match, '-1' on no match, otherwise error | |
166 | + * @return - the partition number on match (starting on 1), -1 on no match, | |
167 | + * otherwise error | |
167 | 168 | */ |
168 | 169 | int part_get_info_by_name(struct blk_desc *dev_desc, |
169 | 170 | const char *name, disk_partition_t *info); |