diff mbox series

[1/2] sandbox: fill block device meta information

Message ID 20210125115715.105568-2-xypron.glpk@gmx.de
State Accepted
Commit 168e313b5b128a0a2e55010875c1636dead38527
Delegated to: Simon Glass
Headers show
Series disk: part: sandbox support in dev_print() | expand

Commit Message

Heinrich Schuchardt Jan. 25, 2021, 11:57 a.m. UTC
Provide information about host backed block device.

Mark the device created by 'host bind' as removable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 drivers/block/sandbox.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

--
2.29.2

Comments

Simon Glass Jan. 30, 2021, 9:26 p.m. UTC | #1
Provide information about host backed block device.

Mark the device created by 'host bind' as removable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 drivers/block/sandbox.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index 34c26cda47..f57f690d3c 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -92,6 +92,7 @@  int host_dev_bind(int devnum, char *filename)
 {
 	struct host_block_dev *host_dev;
 	struct udevice *dev;
+	struct blk_desc *desc;
 	char dev_name[20], *str, *fname;
 	int ret, fd;

@@ -143,6 +144,12 @@  int host_dev_bind(int devnum, char *filename)
 		goto err_file;
 	}

+	desc = blk_get_devnum_by_type(IF_TYPE_HOST, devnum);
+	desc->removable = 1;
+	snprintf(desc->vendor, BLK_VEN_SIZE, "U-Boot");
+	snprintf(desc->product, BLK_PRD_SIZE, "hostfile");
+	snprintf(desc->revision, BLK_REV_SIZE, "1.0");
+
 	return 0;
 err_file:
 	os_close(fd);
@@ -187,6 +194,10 @@  int host_dev_bind(int dev, char *filename)
 	blk_dev->block_write = host_block_write;
 	blk_dev->devnum = dev;
 	blk_dev->part_type = PART_TYPE_UNKNOWN;
+	blk_dev->removable = 1;
+	snprintf(blk_dev->vendor, BLK_VEN_SIZE, "U-Boot");
+	snprintf(blk_dev->product, BLK_PRD_SIZE, "hostfile");
+	snprintf(blk_dev->revision, BLK_REV_SIZE, "1.0");
 	part_init(blk_dev);

 	return 0;