[PATCH 2/3] bus: ti-sysc: Simplify with clk_get_by_name_optional

"Markus Schneider-Pargmann (TI)" <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <20260827-v2026-10-next-topic-am45-ofupstream-ti-sysc-v1-2-e2c43cecc71e@baylibre.com>
clk_get_by_name_optional already checks for -ENODATA and -ENOENT. So use
that instead of clk_get_by_name(). clk_get_by_name_optional() leaves
clk->dev as NULL if it doesn't exist, so it is safe to run any other
operations on that.

Signed-off-by: Markus Schneider-Pargmann (TI) <[email protected]>
---
 drivers/bus/ti-sysc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
index d0395893519c..3c4ae585704e 100644
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -53,9 +53,9 @@ static int ti_sysc_get_one_clock(struct udevice *dev, enum ti_sysc_clocks index)
 
 	name = clock_names[index];
 
-	err = clk_get_by_name(dev, name, &priv->clocks[index]);
+	err = clk_get_by_name_optional(dev, name, &priv->clocks[index]);
 	if (err) {
-		if (err == -ENODATA || err == -ENOSYS)
+		if (err == -ENOSYS)
 			return 0;
 
 		dev_err(dev, "failed to get %s clock\n", name);
@@ -86,10 +86,10 @@ static int ti_sysc_get_clocks(struct udevice *dev)
 
 	for (i = 0; i < TI_SYSC_MAX_CLOCKS; i++) {
 		err = ti_sysc_get_one_clock(dev, i);
-		if (!err)
-			priv->clocks_count++;
-		else if (err != -ENOENT)
+		if (err)
 			return err;
+
+		priv->clocks_count++;
 	}
 
 	return 0;

-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.