aboutsummaryrefslogtreecommitdiff
path: root/drivers/block
diff options
context:
space:
mode:
authorBin Meng <bmeng@tinylab.org>2023-09-26 16:43:33 +0800
committerTom Rini <trini@konsulko.com>2023-10-10 16:19:43 -0400
commit8897faba2d1d2e6802cd066580100685baa46f7f (patch)
tree2589c2bb478a4c1f50c5b4e6d0f6fdf3c616406b /drivers/block
parent77ca9d74571e92969591d39df134ccd72296f4d9 (diff)
downloadu-boot-8897faba2d1d2e6802cd066580100685baa46f7f.zip
u-boot-8897faba2d1d2e6802cd066580100685baa46f7f.tar.gz
u-boot-8897faba2d1d2e6802cd066580100685baa46f7f.tar.bz2
blk: sandbox: Support binding a device with a given logical block size
Allow optionally set the logical block size of the host device to bind in the "host bind" command. If not given, defaults to 512. Signed-off-by: Bin Meng <bmeng@tinylab.org>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/host-uclass.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/block/host-uclass.c b/drivers/block/host-uclass.c
index 6460d96..b3647e3 100644
--- a/drivers/block/host-uclass.c
+++ b/drivers/block/host-uclass.c
@@ -13,6 +13,7 @@
#include <blk.h>
#include <dm.h>
#include <malloc.h>
+#include <part.h>
#include <sandbox_host.h>
#include <dm/device-internal.h>
#include <dm/lists.h>
@@ -29,7 +30,8 @@ struct host_priv {
struct udevice *cur_dev;
};
-int host_create_device(const char *label, bool removable, struct udevice **devp)
+int host_create_device(const char *label, bool removable, unsigned long blksz,
+ struct udevice **devp)
{
char dev_name[30], *str, *label_new;
struct host_sb_plat *plat;
@@ -68,6 +70,12 @@ int host_create_device(const char *label, bool removable, struct udevice **devp)
struct blk_desc *desc = dev_get_uclass_plat(blk);
desc->removable = removable;
+
+ /* update blk device's block size with the provided one */
+ if (blksz != desc->blksz) {
+ desc->blksz = blksz;
+ desc->log2blksz = LOG2(desc->blksz);
+ }
}
plat = dev_get_plat(dev);
@@ -95,12 +103,13 @@ int host_attach_file(struct udevice *dev, const char *filename)
}
int host_create_attach_file(const char *label, const char *filename,
- bool removable, struct udevice **devp)
+ bool removable, unsigned long blksz,
+ struct udevice **devp)
{
struct udevice *dev;
int ret;
- ret = host_create_device(label, removable, &dev);
+ ret = host_create_device(label, removable, blksz, &dev);
if (ret)
return log_msg_ret("cre", ret);