summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-02-29 15:25:44 -0700
committerSimon Glass <sjg@chromium.org>2016-03-14 15:34:50 -0600
commite35929e4a1ffe861f2f45e107986568c56c4f077 (patch)
tree931c9af5f622d4fb90bf932a911100bcd94c75c0
parentebac37cfbfb32ea44704fe032fadd5cf334824b7 (diff)
downloadtalos-obmc-uboot-e35929e4a1ffe861f2f45e107986568c56c4f077.tar.gz
talos-obmc-uboot-e35929e4a1ffe861f2f45e107986568c56c4f077.zip
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>
-rw-r--r--cmd/disk.c2
-rw-r--r--cmd/fat.c4
-rw-r--r--cmd/part.c2
-rw-r--r--cmd/reiser.c4
-rw-r--r--cmd/zfs.c4
-rw-r--r--common/env_fat.c4
-rw-r--r--disk/part.c2
-rw-r--r--fs/fs.c2
-rw-r--r--fs/ubifs/ubifs.c2
-rw-r--r--include/part.h42
10 files changed, 51 insertions, 17 deletions
diff --git a/cmd/disk.c b/cmd/disk.c
index c53c2a2dbf..0883c79506 100644
--- a/cmd/disk.c
+++ b/cmd/disk.c
@@ -38,7 +38,7 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
bootstage_mark(BOOTSTAGE_ID_IDE_BOOT_DEVICE);
- part = get_device_and_partition(intf, (argc == 3) ? argv[2] : NULL,
+ part = blk_get_device_part_str(intf, (argc == 3) ? argv[2] : NULL,
&dev_desc, &info, 1);
if (part < 0) {
bootstage_error(BOOTSTAGE_ID_IDE_TYPE);
diff --git a/cmd/fat.c b/cmd/fat.c
index 82b9b38c2c..18a1be97e0 100644
--- a/cmd/fat.c
+++ b/cmd/fat.c
@@ -77,7 +77,7 @@ static int do_fat_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc,
return 0;
}
- part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
+ part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
if (part < 0)
return 1;
@@ -114,7 +114,7 @@ static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag,
if (argc < 5)
return cmd_usage(cmdtp);
- part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
+ part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
if (part < 0)
return 1;
diff --git a/cmd/part.c b/cmd/part.c
index dd32d505b0..415b38a522 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -37,7 +37,7 @@ static int do_part_uuid(int argc, char * const argv[])
if (argc > 3)
return CMD_RET_USAGE;
- part = get_device_and_partition(argv[0], argv[1], &dev_desc, &info, 0);
+ part = blk_get_device_part_str(argv[0], argv[1], &dev_desc, &info, 0);
if (part < 0)
return 1;
diff --git a/cmd/reiser.c b/cmd/reiser.c
index 1cca5eb658..a7179561e4 100644
--- a/cmd/reiser.c
+++ b/cmd/reiser.c
@@ -40,7 +40,7 @@ int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (argc < 3)
return CMD_RET_USAGE;
- part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
+ part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
if (part < 0)
return 1;
@@ -122,7 +122,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 1;
}
- part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
+ part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
if (part < 0)
return 1;
diff --git a/cmd/zfs.c b/cmd/zfs.c
index 9076a8a6bb..bb61afd80d 100644
--- a/cmd/zfs.c
+++ b/cmd/zfs.c
@@ -80,7 +80,7 @@ static int do_zfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
return 1;
}
- part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
+ part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
if (part < 0)
return 1;
@@ -145,7 +145,7 @@ static int do_zfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (argc == 4)
filename = argv[3];
- part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
+ part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
if (part < 0)
return 1;
diff --git a/common/env_fat.c b/common/env_fat.c
index e88279eb70..2f22710355 100644
--- a/common/env_fat.c
+++ b/common/env_fat.c
@@ -48,7 +48,7 @@ int saveenv(void)
if (err)
return err;
- part = get_device_and_partition(FAT_ENV_INTERFACE,
+ part = blk_get_device_part_str(FAT_ENV_INTERFACE,
FAT_ENV_DEVICE_AND_PART,
&dev_desc, &info, 1);
if (part < 0)
@@ -82,7 +82,7 @@ void env_relocate_spec(void)
int dev, part;
int err;
- part = get_device_and_partition(FAT_ENV_INTERFACE,
+ part = blk_get_device_part_str(FAT_ENV_INTERFACE,
FAT_ENV_DEVICE_AND_PART,
&dev_desc, &info, 1);
if (part < 0)
diff --git a/disk/part.c b/disk/part.c
index 2e7adbcd9d..255ee7959f 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -511,7 +511,7 @@ cleanup:
#define PART_UNSPECIFIED -2
#define PART_AUTO -1
#define MAX_SEARCH_PARTITIONS 16
-int get_device_and_partition(const char *ifname, const char *dev_part_str,
+int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
struct blk_desc **dev_desc,
disk_partition_t *info, int allow_whole_dev)
{
diff --git a/fs/fs.c b/fs/fs.c
index 8515beabf5..595ff1fe69 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -213,7 +213,7 @@ int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype)
}
#endif
- part = get_device_and_partition(ifname, dev_part_str, &fs_dev_desc,
+ part = blk_get_device_part_str(ifname, dev_part_str, &fs_dev_desc,
&fs_partition, 1);
if (part < 0)
return -1;
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 168ae2b697..cdc04c662d 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -569,7 +569,7 @@ int ubifs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info)
}
/*
- * Should never happen since get_device_and_partition() already checks
+ * Should never happen since blk_get_device_part_str() already checks
* this, but better safe then sorry.
*/
if (!ubifs_is_mounted()) {
diff --git a/include/part.h b/include/part.h
index 6ca87d0f63..6197101a96 100644
--- a/include/part.h
+++ b/include/part.h
@@ -129,9 +129,43 @@ void dev_print(struct blk_desc *dev_desc);
*/
int blk_get_device_by_str(const char *ifname, const char *dev_str,
struct blk_desc **dev_desc);
-int get_device_and_partition(const char *ifname, const char *dev_part_str,
- struct blk_desc **dev_desc,
- disk_partition_t *info, int allow_whole_dev);
+
+/**
+ * blk_get_device_part_str() - Get a block device and partition
+ *
+ * This calls blk_get_device_by_str() to look up a device. It also looks up
+ * a partition and returns information about it.
+ *
+ * @dev_part_str is in the format:
+ * <dev>.<hw_part>:<part> where <dev> is the device number,
+ * <hw_part> is the optional hardware partition number and
+ * <part> is the partition number
+ *
+ * If ifname is "hostfs" then this function returns the sandbox host block
+ * device.
+ *
+ * If ifname is ubi, then this function returns 0, with @info set to a
+ * special UBI device.
+ *
+ * If @dev_part_str is NULL or empty or "-", then this function looks up
+ * the "bootdevice" environment variable and uses that string instead.
+ *
+ * If the partition string is empty then the first partition is used. If the
+ * partition string is "auto" then the first bootable partition is used.
+ *
+ * @ifname: Interface name (e.g. "ide", "scsi")
+ * @dev_part_str: Device and partition string
+ * @dev_desc: Returns a pointer to the block device on success
+ * @info: Returns partition information
+ * @allow_whole_dev: true to allow the user to select partition 0
+ * (which means the whole device), false to require a valid
+ * partition number >= 1
+ * @return partition number, or -1 on error
+ *
+ */
+int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
+ struct blk_desc **dev_desc,
+ disk_partition_t *info, int allow_whole_dev);
#else
static inline struct blk_desc *blk_get_dev(const char *ifname, int dev)
{ return NULL; }
@@ -153,7 +187,7 @@ static inline void dev_print(struct blk_desc *dev_desc) {}
static inline int blk_get_device_by_str(const char *ifname, const char *dev_str,
struct blk_desc **dev_desc)
{ return -1; }
-static inline int get_device_and_partition(const char *ifname,
+static inline int blk_get_device_part_str(const char *ifname,
const char *dev_part_str,
struct blk_desc **dev_desc,
disk_partition_t *info,
OpenPOWER on IntegriCloud