diff mbox series

[26/30] ide: Correct LBA setting

Message ID 20230328080702.26.I5c93e458e2f7205b69ffef473ac7154a675fc9bd@changeid
State Changes Requested
Delegated to: Tom Rini
Headers show
Series ide: Clean up code and fix a few bugs | expand

Commit Message

Simon Glass March 27, 2023, 7:07 p.m. UTC
Fix a longstanding bug where the LBA is calculated as the size of the
media instead of the number of blocks. This was perhaps not noticed
earlier since it prints the correct value first, before setting the wrong
value.

Drop the unnecessary blksz variable while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 68e6f221ed0 ("block: ide: Fix block read/write with driver model")
---

 drivers/block/ide.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/drivers/block/ide.c b/drivers/block/ide.c
index 4c2a6a8e5309..72216540d040 100644
--- a/drivers/block/ide.c
+++ b/drivers/block/ide.c
@@ -1029,9 +1029,7 @@  static int ide_probe(struct udevice *udev)
 	for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; i++) {
 		struct blk_desc *desc, pdesc;
 		struct udevice *blk;
-		lbaint_t size;
 		char name[20];
-		int blksz;
 		int ret;
 
 		if (!bus_ok[IDE_BUS(i)])
@@ -1045,17 +1043,14 @@  static int ide_probe(struct udevice *udev)
 
 		sprintf(name, "blk#%d", i);
 
-		blksz = pdesc.blksz;
-		size = blksz * pdesc.lba;
-
 		/*
 		 * With CDROM, if there is no CD inserted, blksz will
 		 * be zero, don't bother to create IDE block device.
 		 */
-		if (!blksz)
+		if (!pdesc.blksz)
 			continue;
 		ret = blk_create_devicef(udev, "ide_blk", name, UCLASS_IDE, i,
-					 blksz, size, &blk);
+					 pdesc.blksz, pdesc.lba, &blk);
 		if (ret)
 			return ret;