From 7020b2eca49e2c902bb443273ba21df2050d7f1e Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Tue, 26 Sep 2023 16:43:31 +0800 Subject: blk: Use a macro for the typical block size Avoid using the magic number 512 directly. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- include/blk.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/blk.h b/include/blk.h index 95e86e2d5d1..bbff057aed4 100644 --- a/include/blk.h +++ b/include/blk.h @@ -21,6 +21,8 @@ typedef ulong lbaint_t; #define LBAF "%" LBAFlength "x" #define LBAFU "%" LBAFlength "u" +#define DEFAULT_BLKSZ 512 + struct udevice; static inline bool blk_enabled(void) -- cgit v1.2.3 From 8897faba2d1d2e6802cd066580100685baa46f7f Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Tue, 26 Sep 2023 16:43:33 +0800 Subject: 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 --- include/sandbox_host.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/sandbox_host.h b/include/sandbox_host.h index ebd7d99b473..f7a5fc67230 100644 --- a/include/sandbox_host.h +++ b/include/sandbox_host.h @@ -74,10 +74,11 @@ int host_detach_file(struct udevice *dev); * @label: Label of the attachment, e.g. "test1" * @removable: true if the device should be marked as removable, false * if it is fixed. See enum blk_flag_t + * @blksz: logical block size of the device * @devp: Returns the device created, on success * Returns: 0 if OK, -ve on error */ -int host_create_device(const char *label, bool removable, +int host_create_device(const char *label, bool removable, unsigned long blksz, struct udevice **devp); /** @@ -87,11 +88,13 @@ int host_create_device(const char *label, bool removable, * @filename: Name of the file, e.g. "/path/to/disk.img" * @removable: true if the device should be marked as removable, false * if it is fixed. See enum blk_flag_t + * @blksz: logical block size of the device * @devp: Returns the device created, on success * Returns: 0 if OK, -ve on error */ int host_create_attach_file(const char *label, const char *filename, - bool removable, struct udevice **devp); + bool removable, unsigned long blksz, + struct udevice **devp); /** * host_find_by_label() - Find a host by label -- cgit v1.2.3 From a9bf25cb93b96502da814f22cd2fbb284272a800 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Tue, 26 Sep 2023 16:43:41 +0800 Subject: dm: blk: Rename get_desc() and make it externally visible get_desc() can be useful outside blk-uclass.c. Let's change it to an API and make it externally visible. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- include/blk.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/blk.h b/include/blk.h index bbff057aed4..b453b5a6026 100644 --- a/include/blk.h +++ b/include/blk.h @@ -515,6 +515,18 @@ const char *blk_get_devtype(struct udevice *dev); */ struct blk_desc *blk_get_by_device(struct udevice *dev); +/** + * blk_get_desc() - Get the block device descriptor for the given device number + * + * @uclass_id: Interface type + * @devnum: Device number (0 = first) + * @descp: Returns block device descriptor on success + * Return: 0 on success, -ENODEV if there is no such device and no device + * with a higher device number, -ENOENT if there is no such device but there + * is one with a higher number, or other -ve on other error. + */ +int blk_get_desc(enum uclass_id uclass_id, int devnum, struct blk_desc **descp); + #else #include /* -- cgit v1.2.3 From 94a846298ed5e0399099977b5b11f13d46c22f3f Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Tue, 26 Sep 2023 16:43:43 +0800 Subject: dm: blk: Drop blk_{read,write}_devnum() blk_{read,write}_devnum() are no longer used by anywhere in the source tree. Drop them. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- include/blk.h | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'include') diff --git a/include/blk.h b/include/blk.h index b453b5a6026..76bd5baf995 100644 --- a/include/blk.h +++ b/include/blk.h @@ -729,32 +729,6 @@ int blk_print_device_num(enum uclass_id uclass_id, int devnum); */ int blk_print_part_devnum(enum uclass_id uclass_id, int devnum); -/** - * blk_read_devnum() - read blocks from a device - * - * @uclass_id: Block device type - * @devnum: Device number - * @start: Start block number to read (0=first) - * @blkcnt: Number of blocks to read - * @buffer: Address to write data to - * Return: number of blocks read, or -ve error number on error - */ -ulong blk_read_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start, - lbaint_t blkcnt, void *buffer); - -/** - * blk_write_devnum() - write blocks to a device - * - * @uclass_id: Block device type - * @devnum: Device number - * @start: Start block number to write (0=first) - * @blkcnt: Number of blocks to write - * @buffer: Address to read data from - * Return: number of blocks written, or -ve error number on error - */ -ulong blk_write_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start, - lbaint_t blkcnt, const void *buffer); - /** * blk_select_hwpart_devnum() - select a hardware partition * -- cgit v1.2.3