Skip to contentSkip to conversation

block: sandbox: Add support for SYS_64BIT_LBA

PATCH In review Tom Rini 2 participants 3 messages Jul 4, 2025 – Jul 11, 2025 Block layer

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 block: sandbox: Add support for SYS_64BIT_LBA

In order to use SYS_64BIT_LBA with this driver we need for "start" to also be of type lbaint_t and to then use the correct printf format characters.

---
 drivers/block/sandbox.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/block/sandbox.c +4 -4
index 6c74d66037e7..9cb27561a97f 100644
@@ -18,7 +18,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 static unsigned long host_block_read(struct udevice *dev,
-				     unsigned long start, lbaint_t blkcnt,
+				     lbaint_t start, lbaint_t blkcnt,
 				     void *buffer)
 {
 	struct blk_desc *desc = dev_get_uclass_plat(dev);
@@ -26,7 +26,7 @@ static unsigned long host_block_read(struct udevice *dev,
 	struct host_sb_plat *plat = dev_get_plat(host_dev);
 
 	if (os_lseek(plat->fd, start * desc->blksz, OS_SEEK_SET) < 0) {
-		printf("ERROR: Invalid block %lx\n", start);
+		printf("ERROR: Invalid block " LBAF "\n", start);
 		return -1;
 	}
 	ssize_t len = os_read(plat->fd, buffer, blkcnt * desc->blksz);
@@ -37,7 +37,7 @@ static unsigned long host_block_read(struct udevice *dev,
 }
 
 static unsigned long host_block_write(struct udevice *dev,
-				      unsigned long start, lbaint_t blkcnt,
+				      lbaint_t start, lbaint_t blkcnt,
 				      const void *buffer)
 {
 	struct blk_desc *desc = dev_get_uclass_plat(dev);
@@ -45,7 +45,7 @@ static unsigned long host_block_write(struct udevice *dev,
 	struct host_sb_plat *plat = dev_get_plat(host_dev);
 
 	if (os_lseek(plat->fd, start * desc->blksz, OS_SEEK_SET) < 0) {
-		printf("ERROR: Invalid block %lx\n", start);
+		printf("ERROR: Invalid block " LBAF "\n", start);
 		return -1;
 	}
 	ssize_t len = os_write(plat->fd, buffer, blkcnt * desc->blksz);
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 41 lines · Tom Rini

In order to use SYS_64BIT_LBA with this driver we need for "start" to also be of type lbaint_t and to then use the correct printf format characters.

---
  drivers/block/sandbox.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
drivers/block/sandbox.c +3 -3
index 6c74d66037e7..9cb27561a97f 100644
@@ -18,7 +18,7 @@
  DECLARE_GLOBAL_DATA_PTR;
 
  static unsigned long host_block_read(struct udevice *dev,
-				     unsigned long start, lbaint_t blkcnt,
+				     lbaint_t start, lbaint_t blkcnt,
  				     void *buffer)
  {
  	struct blk_desc *desc = dev_get_uclass_plat(dev);
@@ -26,7 +26,7 @@ static unsigned long host_block_read(struct udevice *dev,
  	struct host_sb_plat *plat = dev_get_plat(host_dev);
 
  	if (os_lseek(plat->fd, start * desc->blksz, OS_SEEK_SET) < 0) {
-		printf("ERROR: Invalid block %lx\n", start);
+		printf("ERROR: Invalid block " LBAF "\n", start);
  		return -1;
  	}
  	ssize_t len = os_read(plat->fd, buffer, blkcnt * desc->blksz);
@@ -37,7 +37,7 @@ static unsigned long host_block_read(struct udevice *dev,
  }
 
  static unsigned long host_block_write(struct udevice *dev,
-				      unsigned long start, lbaint_t blkcnt,
+				      lbaint_t start, lbaint_t blkcnt,
  				      const void *buffer)
  {
  	struct blk_desc *desc = dev_get_uclass_plat(dev);

drivers/block/sandbox.c static unsigned long host_block_write(struct udevice *dev, · line 51

Quoted 8 lines
drivers/block/sandbox.c +1 -1
@@ -45,7 +45,7 @@ static unsigned long host_block_write(struct udevice *dev,
  	struct host_sb_plat *plat = dev_get_plat(host_dev);
 
  	if (os_lseek(plat->fd, start * desc->blksz, OS_SEEK_SET) < 0) {
-		printf("ERROR: Invalid block %lx\n", start);
+		printf("ERROR: Invalid block " LBAF "\n", start);
  		return -1;
  	}
  	ssize_t len = os_write(plat->fd, buffer, blkcnt * desc->blksz);
author
#2 lore raw
In reply to Tom Rini
Quoted 5 lines · Tom Rini

In order to use SYS_64BIT_LBA with this driver we need for "start" to also be of type lbaint_t and to then use the correct printf format characters.

Applied to u-boot/master, thanks!

[1/1] block: sandbox: Add support for SYS_64BIT_LBA

      commit: 53bd87651e45b32efa398dd5e433d8b93d781445
Signature · 1 line
Tom