]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
disk: introduce get_device()
authorStephen Warren <swarren@nvidia.com>
Fri, 21 Sep 2012 09:50:56 +0000 (09:50 +0000)
committerTom Rini <trini@ti.com>
Tue, 25 Sep 2012 21:49:33 +0000 (14:49 -0700)
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>
disk/part.c
include/part.h

index f0afd89553345b974c828bde34425da61c9ee9ef..ed6bbe29bc878bc0073b32e8bd5a007c106748ff 100644 (file)
@@ -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)
index a6d06f3a5ee91ab4cf04bda8982d736fcf507eec..144df4e70be58952bc73ece3487d7c3b718e1391 100644 (file)
@@ -112,6 +112,8 @@ int get_partition_info (block_dev_desc_t * dev_desc, int part, disk_partition_t
 void print_part (block_dev_desc_t *dev_desc);
 void  init_part (block_dev_desc_t *dev_desc);
 void dev_print(block_dev_desc_t *dev_desc);
+int get_device(const char *ifname, const char *dev_str,
+              block_dev_desc_t **dev_desc);
 int get_device_and_partition(const char *ifname, const char *dev_str,
                             block_dev_desc_t **dev_desc,
                             disk_partition_t *info);
@@ -131,6 +133,9 @@ static inline int get_partition_info (block_dev_desc_t * dev_desc, int part,
 static inline void print_part (block_dev_desc_t *dev_desc) {}
 static inline void  init_part (block_dev_desc_t *dev_desc) {}
 static inline void dev_print(block_dev_desc_t *dev_desc) {}
+static inline int get_device(const char *ifname, const char *dev_str,
+              block_dev_desc_t **dev_desc)
+{ return -1; }
 static inline int get_device_and_partition(const char *ifname,
                                           const char *dev_str,
                                           block_dev_desc_t **dev_desc,