summaryrefslogtreecommitdiff
path: root/drivers/block/blk-uclass.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-05-01 11:36:29 -0600
committerSimon Glass <sjg@chromium.org>2016-05-17 09:54:43 -0600
commit9107c973d32c72a6f7ac909fc4a6884a42e4e607 (patch)
tree29ebd7fae208b74ddaf86414847e3b1c70fbb2dd /drivers/block/blk-uclass.c
parent52138fd4072b64448855eac4c2c9815b46f5b43c (diff)
downloadu-boot-9107c973d32c72a6f7ac909fc4a6884a42e4e607.tar.gz
u-boot-9107c973d32c72a6f7ac909fc4a6884a42e4e607.tar.bz2
u-boot-9107c973d32c72a6f7ac909fc4a6884a42e4e607.zip
dm: blk: Add a easier way to create a named block device
Add a function that automatically builds the device name given the parent and a supplied string. Most callers will want to do this, so putting this functionality in one place makes more sense. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/block/blk-uclass.c')
-rw-r--r--drivers/block/blk-uclass.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index c947d95023..6ecbff0e93 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -463,6 +463,21 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
return 0;
}
+int blk_create_devicef(struct udevice *parent, const char *drv_name,
+ const char *name, int if_type, int devnum, int blksz,
+ lbaint_t size, struct udevice **devp)
+{
+ char dev_name[30], *str;
+
+ snprintf(dev_name, sizeof(dev_name), "%s.%s", parent->name, name);
+ str = strdup(dev_name);
+ if (!str)
+ return -ENOMEM;
+
+ return blk_create_device(parent, drv_name, str, if_type, devnum,
+ blksz, size, devp);
+}
+
int blk_unbind_all(int if_type)
{
struct uclass *uc;