int blk_create_device(struct udevice *parent, const char *drv_name,
const char *name, int if_type, int devnum, int blksz,
- lbaint_t size, struct udevice **devp)
+ lbaint_t lba, struct udevice **devp)
{
struct blk_desc *desc;
struct udevice *dev;
desc = dev_get_uclass_platdata(dev);
desc->if_type = if_type;
desc->blksz = blksz;
- desc->lba = size / blksz;
+ desc->lba = lba;
desc->part_type = PART_TYPE_UNKNOWN;
desc->bdev = dev;
desc->devnum = devnum;
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)
+ lbaint_t lba, struct udevice **devp)
{
char dev_name[30], *str;
int ret;
return -ENOMEM;
ret = blk_create_device(parent, drv_name, str, if_type, devnum,
- blksz, size, devp);
+ blksz, lba, devp);
if (ret) {
free(str);
return ret;
}
ret = blk_create_device(gd->dm_root, "sandbox_host_blk", str,
IF_TYPE_HOST, devnum, 512,
- os_lseek(fd, 0, OS_SEEK_END), &dev);
+ os_lseek(fd, 0, OS_SEEK_END) / 512, &dev);
if (ret)
goto err_file;
ret = device_probe(dev);
*/
snprintf(str, sizeof(str), "id%dlun%d", id, lun);
ret = blk_create_devicef(dev, "scsi_blk", str, IF_TYPE_SCSI, -1,
- bd.blksz, bd.blksz * bd.lba, &bdev);
+ bd.blksz, bd.lba, &bdev);
if (ret) {
debug("Can't create device\n");
return ret;
* @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
+ * @lba: Total number of blocks of the device
* @devp: the new device (which has not been probed)
*/
int blk_create_device(struct udevice *parent, const char *drv_name,
const char *name, int if_type, int devnum, int blksz,
- lbaint_t size, struct udevice **devp);
+ lbaint_t lba, struct udevice **devp);
/**
* blk_create_devicef() - Create a new named block device
* @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
+ * @lba: Total number of blocks of the device
* @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);
+ lbaint_t lba, struct udevice **devp);
/**
* blk_prepare_device() - Prepare a block device for use
/* Create two, one the parent of the other */
ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test",
- IF_TYPE_HOST, 1, 512, 1024, &blk));
+ IF_TYPE_HOST, 1, 512, 2, &blk));
ut_assertok(blk_create_device(blk, "usb_storage_blk", "test",
- IF_TYPE_USB, 3, 512, 1024, &usb_blk));
+ IF_TYPE_USB, 3, 512, 2, &usb_blk));
/* Check we can find them */
ut_asserteq(-ENODEV, blk_get_device(IF_TYPE_HOST, 0, &dev));
struct udevice *blk, *dev;
ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test",
- IF_TYPE_HOST, 1, 512, 1024, &blk));
+ IF_TYPE_HOST, 1, 512, 2, &blk));
ut_asserteq(-ENODEV, blk_find_device(IF_TYPE_HOST, 0, &dev));
ut_assertok(blk_find_device(IF_TYPE_HOST, 1, &dev));
ut_asserteq_ptr(blk, dev);