From 9107c973d32c72a6f7ac909fc4a6884a42e4e607 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 May 2016 11:36:29 -0600 Subject: 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 --- common/usb_storage.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'common') 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; -- cgit v1.1