]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
dm: blk: Add a function to find an interface-type name
authorSimon Glass <sjg@chromium.org>
Sat, 29 Jul 2017 17:34:53 +0000 (11:34 -0600)
committerJaehoon Chung <jh80.chung@samsung.com>
Thu, 17 Aug 2017 07:44:16 +0000 (16:44 +0900)
Add a function to find the name of an interface type (e.g. "sata", "scsi")
from the interface type enum.

This is useful for generic code (not specific to SATA or SCSI, for
example) that wants to display the type of interface it is dealing with.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/block/blk-uclass.c
drivers/block/blk_legacy.c
include/blk.h

index a3737badec6df61ca318cfee975f6f95a6535191..3adb92b58e8b5d072a8539c4d09bae2a3f0fedac 100644 (file)
@@ -57,6 +57,11 @@ static enum uclass_id if_type_to_uclass_id(enum if_type if_type)
        return if_type_uclass_id[if_type];
 }
 
+const char *blk_get_if_type_name(enum if_type if_type)
+{
+       return if_typename_str[if_type];
+}
+
 struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
 {
        struct blk_desc *desc;
index 7b90a8a6e18ebc3010bf043b5d71c4966f2fba75..981872ecb35cd516087effc09ffd6b30e21886cd 100644 (file)
@@ -38,6 +38,13 @@ static struct blk_driver *blk_driver_lookup_typename(const char *if_typename)
        return NULL;
 }
 
+const char *blk_get_if_type_name(enum if_type if_type)
+{
+       struct blk_driver *drv = blk_driver_lookup_type(if_type);
+
+       return drv ? drv->if_typename : NULL;
+}
+
 /**
  * get_desc() - Get the block device descriptor for the given device number
  *
index 61b56281b3150cc815a7385969ed6504d8d0d379..8672e32fe1dfd7c9aface8d5ccb35d91a8cd4d5b 100644 (file)
@@ -624,4 +624,12 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
  */
 int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
 
+/**
+ * blk_get_if_type_name() - Get the name of an interface type
+ *
+ * @if_type: Interface type to check
+ * @return name of interface, or NULL if none
+ */
+const char *blk_get_if_type_name(enum if_type if_type);
+
 #endif