[PATCH] clk: also return NULL for -ENOENT in devm_clk_get_optional functions

Yang Xiwen via B4 Relay devnull+forbidden405.outlook.com at kernel.org
Mon Jul 24 19:32:12 CEST 2023


From: Yang Xiwen <forbidden405 at outlook.com>

As described by the doc.

Signed-off-by: Yang Xiwen <forbidden405 at outlook.com>
---
Handle both ENODATA and ENOENT.
---
 include/clk.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/clk.h b/include/clk.h
index d91285235f..c9aa2360e1 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -224,8 +224,9 @@ static inline struct clk *devm_clk_get_optional(struct udevice *dev,
 						const char *id)
 {
 	struct clk *clk = devm_clk_get(dev, id);
+	int ret = PTR_ERR(clk);
 
-	if (PTR_ERR(clk) == -ENODATA)
+	if (ret == -ENODATA || ret == -ENOENT)
 		return NULL;
 
 	return clk;
@@ -335,7 +336,7 @@ static inline int clk_get_by_name_optional(struct udevice *dev,
 	int ret;
 
 	ret = clk_get_by_name(dev, name, clk);
-	if (ret == -ENODATA)
+	if (ret == -ENODATA || ret == -ENOENT)
 		return 0;
 
 	return ret;
@@ -359,7 +360,7 @@ static inline int clk_get_by_name_nodev_optional(ofnode node, const char *name,
 	int ret;
 
 	ret = clk_get_by_name_nodev(node, name, clk);
-	if (ret == -ENODATA)
+	if (ret == -ENODATA || ret == -ENOENT)
 		return 0;
 
 	return ret;

---
base-commit: 580eb31199be8a822e62f20965854a242f895d03
change-id: 20230725-clk-fix-inc-903aa0540739

Best regards,
-- 
Yang Xiwen <forbidden405 at outlook.com>



More information about the U-Boot mailing list