[PATCH 1/8] disk: Drop always true conditional check

Marek Vasut marek.vasut+renesas at mailbox.org
Mon Aug 14 01:46:41 CEST 2023


if (device_get_uclass_id(dev) == UCLASS_PARTITION) is always
true, because this disk_blk_read() function calls dev_get_blk()
above and checks its return value for non-NULL. The dev_get_blk()
performs the same device_get_uclass_id(dev) check and returns NULL
if not UCLASS_PARTITION. Drop the duplicate check.

Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
---
Cc: AKASHI Takahiro <takahiro.akashi at linaro.org>
Cc: Abdellatif El Khlifi <abdellatif.elkhlifi at arm.com>
Cc: Bin Meng <bmeng.cn at gmail.com>
Cc: Heinrich Schuchardt <xypron.glplk at gmx.de>
Cc: Joshua Watt <jpewhacker at gmail.com>
Cc: Michal Suchanek <msuchanek at suse.de>
Cc: Simon Glass <sjg at chromium.org>
Cc: Tobias Waldekranz <tobias at waldekranz.com>
---
 disk/disk-uclass.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c
index d32747e2242..5974dd8c2ec 100644
--- a/disk/disk-uclass.c
+++ b/disk/disk-uclass.c
@@ -186,10 +186,8 @@ unsigned long disk_blk_read(struct udevice *dev, lbaint_t start,
 		return -ENOSYS;
 
 	start_in_disk = start;
-	if (device_get_uclass_id(dev) == UCLASS_PARTITION) {
-		part = dev_get_uclass_plat(dev);
-		start_in_disk += part->gpt_part_info.start;
-	}
+	part = dev_get_uclass_plat(dev);
+	start_in_disk += part->gpt_part_info.start;
 
 	if (blkcache_read(desc->uclass_id, desc->devnum, start_in_disk, blkcnt,
 			  desc->blksz, buffer))
-- 
2.40.1



More information about the U-Boot mailing list