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>
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 3c5a87b..aee2a50 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -546,7 +546,7 @@
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 @@
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_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 @@
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;