Commit e35929e4a1ffe861f2f45e107986568c56c4f077

Authored by Simon Glass
1 parent ebac37cfbf

dm: blk: Rename get_device_and_partition()

Rename this function to blk_get_device_part_str(). This is a better name
because it makes it clear that the function returns a block device and
parses a string.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>

Showing 10 changed files with 51 additions and 17 deletions Side-by-side Diff

... ... @@ -38,7 +38,7 @@
38 38  
39 39 bootstage_mark(BOOTSTAGE_ID_IDE_BOOT_DEVICE);
40 40  
41   - part = get_device_and_partition(intf, (argc == 3) ? argv[2] : NULL,
  41 + part = blk_get_device_part_str(intf, (argc == 3) ? argv[2] : NULL,
42 42 &dev_desc, &info, 1);
43 43 if (part < 0) {
44 44 bootstage_error(BOOTSTAGE_ID_IDE_TYPE);
... ... @@ -77,7 +77,7 @@
77 77 return 0;
78 78 }
79 79  
80   - part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
  80 + part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
81 81 if (part < 0)
82 82 return 1;
83 83  
... ... @@ -114,7 +114,7 @@
114 114 if (argc < 5)
115 115 return cmd_usage(cmdtp);
116 116  
117   - part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
  117 + part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
118 118 if (part < 0)
119 119 return 1;
120 120  
... ... @@ -37,7 +37,7 @@
37 37 if (argc > 3)
38 38 return CMD_RET_USAGE;
39 39  
40   - part = get_device_and_partition(argv[0], argv[1], &dev_desc, &info, 0);
  40 + part = blk_get_device_part_str(argv[0], argv[1], &dev_desc, &info, 0);
41 41 if (part < 0)
42 42 return 1;
43 43  
... ... @@ -40,7 +40,7 @@
40 40 if (argc < 3)
41 41 return CMD_RET_USAGE;
42 42  
43   - part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
  43 + part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
44 44 if (part < 0)
45 45 return 1;
46 46  
... ... @@ -122,7 +122,7 @@
122 122 return 1;
123 123 }
124 124  
125   - part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
  125 + part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
126 126 if (part < 0)
127 127 return 1;
128 128  
... ... @@ -80,7 +80,7 @@
80 80 return 1;
81 81 }
82 82  
83   - part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
  83 + part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
84 84 if (part < 0)
85 85 return 1;
86 86  
... ... @@ -145,7 +145,7 @@
145 145 if (argc == 4)
146 146 filename = argv[3];
147 147  
148   - part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
  148 + part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
149 149 if (part < 0)
150 150 return 1;
151 151  
... ... @@ -48,7 +48,7 @@
48 48 if (err)
49 49 return err;
50 50  
51   - part = get_device_and_partition(FAT_ENV_INTERFACE,
  51 + part = blk_get_device_part_str(FAT_ENV_INTERFACE,
52 52 FAT_ENV_DEVICE_AND_PART,
53 53 &dev_desc, &info, 1);
54 54 if (part < 0)
... ... @@ -82,7 +82,7 @@
82 82 int dev, part;
83 83 int err;
84 84  
85   - part = get_device_and_partition(FAT_ENV_INTERFACE,
  85 + part = blk_get_device_part_str(FAT_ENV_INTERFACE,
86 86 FAT_ENV_DEVICE_AND_PART,
87 87 &dev_desc, &info, 1);
88 88 if (part < 0)
... ... @@ -511,7 +511,7 @@
511 511 #define PART_UNSPECIFIED -2
512 512 #define PART_AUTO -1
513 513 #define MAX_SEARCH_PARTITIONS 16
514   -int get_device_and_partition(const char *ifname, const char *dev_part_str,
  514 +int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
515 515 struct blk_desc **dev_desc,
516 516 disk_partition_t *info, int allow_whole_dev)
517 517 {
... ... @@ -213,7 +213,7 @@
213 213 }
214 214 #endif
215 215  
216   - part = get_device_and_partition(ifname, dev_part_str, &fs_dev_desc,
  216 + part = blk_get_device_part_str(ifname, dev_part_str, &fs_dev_desc,
217 217 &fs_partition, 1);
218 218 if (part < 0)
219 219 return -1;
... ... @@ -569,7 +569,7 @@
569 569 }
570 570  
571 571 /*
572   - * Should never happen since get_device_and_partition() already checks
  572 + * Should never happen since blk_get_device_part_str() already checks
573 573 * this, but better safe then sorry.
574 574 */
575 575 if (!ubifs_is_mounted()) {
... ... @@ -129,9 +129,43 @@
129 129 */
130 130 int blk_get_device_by_str(const char *ifname, const char *dev_str,
131 131 struct blk_desc **dev_desc);
132   -int get_device_and_partition(const char *ifname, const char *dev_part_str,
133   - struct blk_desc **dev_desc,
134   - disk_partition_t *info, int allow_whole_dev);
  132 +
  133 +/**
  134 + * blk_get_device_part_str() - Get a block device and partition
  135 + *
  136 + * This calls blk_get_device_by_str() to look up a device. It also looks up
  137 + * a partition and returns information about it.
  138 + *
  139 + * @dev_part_str is in the format:
  140 + * <dev>.<hw_part>:<part> where <dev> is the device number,
  141 + * <hw_part> is the optional hardware partition number and
  142 + * <part> is the partition number
  143 + *
  144 + * If ifname is "hostfs" then this function returns the sandbox host block
  145 + * device.
  146 + *
  147 + * If ifname is ubi, then this function returns 0, with @info set to a
  148 + * special UBI device.
  149 + *
  150 + * If @dev_part_str is NULL or empty or "-", then this function looks up
  151 + * the "bootdevice" environment variable and uses that string instead.
  152 + *
  153 + * If the partition string is empty then the first partition is used. If the
  154 + * partition string is "auto" then the first bootable partition is used.
  155 + *
  156 + * @ifname: Interface name (e.g. "ide", "scsi")
  157 + * @dev_part_str: Device and partition string
  158 + * @dev_desc: Returns a pointer to the block device on success
  159 + * @info: Returns partition information
  160 + * @allow_whole_dev: true to allow the user to select partition 0
  161 + * (which means the whole device), false to require a valid
  162 + * partition number >= 1
  163 + * @return partition number, or -1 on error
  164 + *
  165 + */
  166 +int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
  167 + struct blk_desc **dev_desc,
  168 + disk_partition_t *info, int allow_whole_dev);
135 169 #else
136 170 static inline struct blk_desc *blk_get_dev(const char *ifname, int dev)
137 171 { return NULL; }
... ... @@ -153,7 +187,7 @@
153 187 static inline int blk_get_device_by_str(const char *ifname, const char *dev_str,
154 188 struct blk_desc **dev_desc)
155 189 { return -1; }
156   -static inline int get_device_and_partition(const char *ifname,
  190 +static inline int blk_get_device_part_str(const char *ifname,
157 191 const char *dev_part_str,
158 192 struct blk_desc **dev_desc,
159 193 disk_partition_t *info,