summaryrefslogtreecommitdiff
path: root/common
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 /common
parent52138fd4072b64448855eac4c2c9815b46f5b43c (diff)
downloadu-boot-imx-9107c973d32c72a6f7ac909fc4a6884a42e4e607.zip
u-boot-imx-9107c973d32c72a6f7ac909fc4a6884a42e4e607.tar.gz
u-boot-imx-9107c973d32c72a6f7ac909fc4a6884a42e4e607.tar.bz2
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 'common')
-rw-r--r--common/usb_storage.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/common/usb_storage.c b/common/usb_storage.c
index f2da3a3..7e6e52d 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -200,7 +200,6 @@ static int usb_stor_probe_device(struct usb_device *udev)
#ifdef CONFIG_BLK
struct us_data *data;
- char dev_name[30], *str;
int ret;
#else
int start;
@@ -223,14 +222,12 @@ static int usb_stor_probe_device(struct usb_device *udev)
for (lun = 0; lun <= max_lun; lun++) {
struct blk_desc *blkdev;
struct udevice *dev;
+ char str[10];
- snprintf(dev_name, sizeof(dev_name), "%s.lun%d",
- udev->dev->name, lun);
- str = strdup(dev_name);
- if (!str)
- return -ENOMEM;
- ret = blk_create_device(udev->dev, "usb_storage_blk", str,
- IF_TYPE_USB, usb_max_devs, 512, 0, &dev);
+ snprintf(str, sizeof(str), "lun%d", lun);
+ ret = blk_create_devicef(udev->dev, "usb_storage_blk", str,
+ IF_TYPE_USB, usb_max_devs, 512, 0,
+ &dev);
if (ret) {
debug("Cannot bind driver\n");
return ret;