diff options
author | Jean-Jacques Hiblot <jjhiblot@ti.com> | 2017-06-09 16:45:18 +0200 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2017-09-11 21:43:58 -0600 |
commit | 5fe7702eccf1bae5b10f0309cef03e02bfdfa6ef (patch) | |
tree | 1c32f209698ac10b795e3a61f0977cf65da1aee7 /drivers | |
parent | c98ac3487e413c71e5d36322ef3324b21c6f60f9 (diff) |
blk: dm: make blk_create_device() take a number of block instead of a size
There is an overflow problem when taking the size instead of the number
of blocks in blk_create_device(). This results in a wrong device size: the
device apparent size is its real size modulo 4GB.
Using the number of blocks instead of the device size fixes the problem and
is more coherent with the internals of the block layer.
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/blk-uclass.c | 8 | ||||
-rw-r--r-- | drivers/block/sandbox.c | 2 | ||||
-rw-r--r-- | drivers/scsi/scsi.c | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index 3c5a87b60a..aee2a50d62 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -546,7 +546,7 @@ static int blk_claim_devnum(enum if_type if_type, int devnum) 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; @@ -567,7 +567,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name, 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; @@ -578,7 +578,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name, 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; @@ -589,7 +589,7 @@ int blk_create_devicef(struct udevice *parent, const char *drv_name, 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; diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c index 34d1c638bc..98df6b33b6 100644 --- a/drivers/block/sandbox.c +++ b/drivers/block/sandbox.c @@ -129,7 +129,7 @@ int host_dev_bind(int devnum, char *filename) } 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); diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 1a65a3f9b9..df998921f5 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -580,7 +580,7 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) */ 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; |