dm: blk: Add a function to return the device type
authorSimon Glass <sjg@chromium.org>
Mon, 25 Apr 2022 05:31:03 +0000 (23:31 -0600)
committerTom Rini <trini@konsulko.com>
Mon, 25 Apr 2022 14:00:03 +0000 (10:00 -0400)
Use the uclass name to get the device type for a block device.

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

index f1e4a85..29f355f 100644 (file)
@@ -509,6 +509,13 @@ int blk_get_from_parent(struct udevice *parent, struct udevice **devp)
        return 0;
 }
 
+const char *blk_get_devtype(struct udevice *dev)
+{
+       struct udevice *parent = dev_get_parent(dev);
+
+       return uclass_get_name(device_get_uclass_id(parent));
+};
+
 int blk_find_max_devnum(enum if_type if_type)
 {
        struct udevice *dev;
index dbe9ae2..9503369 100644 (file)
@@ -434,6 +434,14 @@ int blk_select_hwpart(struct udevice *dev, int hwpart);
 int blk_get_from_parent(struct udevice *parent, struct udevice **devp);
 
 /**
+ * blk_get_devtype() - Get the device type of a block device
+ *
+ * @dev:       Block device to check
+ * Return: device tree, i.e. the uclass name of its parent, e.g. "mmc"
+ */
+const char *blk_get_devtype(struct udevice *dev);
+
+/**
  * blk_get_by_device() - Get the block device descriptor for the given device
  * @dev:       Instance of a storage device
  *