#ifdef CONFIG_BLK
struct us_data *data;
- char dev_name[30], *str;
int ret;
#else
int start;
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;
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;
const char *name, int if_type, int devnum, int blksz,
lbaint_t size, struct udevice **devp);
+/**
+ * blk_create_devicef() - Create a new named block device
+ *
+ * @parent: Parent of the new device
+ * @drv_name: Driver name to use for the block device
+ * @name: Name for the device (parent name is prepended)
+ * @if_type: Interface type (enum if_type_t)
+ * @devnum: Device number, specific to the interface type, or -1 to
+ * allocate the next available number
+ * @blksz: Block size of the device in bytes (typically 512)
+ * @size: Total size of the device in bytes
+ * @devp: the new device (which has not been probed)
+ */
+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);
+
/**
* blk_prepare_device() - Prepare a block device for use
*