summaryrefslogtreecommitdiff
path: root/disk
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2012-09-21 09:50:56 +0000
committerTom Rini <trini@ti.com>2012-09-25 14:49:33 -0700
commit2023e60861283ee808950a558e14b45be8776bf4 (patch)
treea8ddbbf0fdfd51fb59f26f460626eaa44d584a05 /disk
parent650f36641ccfe1c2444277891da7c76cdde99f8b (diff)
disk: introduce get_device()
This patch introduces function get_device(). This looks up a block_dev_desc_t from an interface name (e.g. mmc) and device number (e.g. 0). This function is essentially the non-partition-specific prefix of get_device_and_partition(). Signed-off-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'disk')
-rw-r--r--disk/part.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/disk/part.c b/disk/part.c
index f0afd89553..ed6bbe29bc 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -443,6 +443,28 @@ int get_partition_info(block_dev_desc_t *dev_desc, int part
return -1;
}
+int get_device(const char *ifname, const char *dev_str,
+ block_dev_desc_t **dev_desc)
+{
+ char *ep;
+ int dev;
+
+ dev = simple_strtoul(dev_str, &ep, 16);
+ if (*ep) {
+ printf("** Bad device specification %s %s **\n",
+ ifname, dev_str);
+ return -1;
+ }
+
+ *dev_desc = get_dev(ifname, dev);
+ if (!(*dev_desc) || ((*dev_desc)->type == DEV_TYPE_UNKNOWN)) {
+ printf("** Bad device %s %s **\n", ifname, dev_str);
+ return -1;
+ }
+
+ return dev;
+}
+
int get_device_and_partition(const char *ifname, const char *dev_str,
block_dev_desc_t **dev_desc,
disk_partition_t *info)