diff options
author | Yang Xiwen <forbidden405@outlook.com> | 2023-08-18 01:04:02 +0800 |
---|---|---|
committer | Sean Anderson <seanga2@gmail.com> | 2023-11-01 15:14:51 -0400 |
commit | c4b52fda6924e92c6745351f32c4cafc36034170 (patch) | |
tree | 53de5a5313f93be89db394ba90ce924415ab6674 | |
parent | 0755db477fa7478e2659568bb7da038a9eaabb8d (diff) |
clk: also handle ENOENT in *_optional functions
If the device does not specify any clocks in device tree, these
functions will return PTR_ERR(-ENOENT). This is not the intended
behavior and does not comply with linux kernel CCF. Fix that by
returning NULL under such circumstances instead.
Signed-off-by: Yang Xiwen <forbidden405@outlook.com>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
Link: https://lore.kernel.org/r/20230818-clk-fix-v1-3-49ec18f820bf@outlook.com
-rw-r--r-- | include/clk.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/include/clk.h b/include/clk.h index a342297007..249c0e0ab4 100644 --- a/include/clk.h +++ b/include/clk.h @@ -223,9 +223,11 @@ struct clk *devm_clk_get(struct udevice *dev, const char *id); static inline struct clk *devm_clk_get_optional(struct udevice *dev, const char *id) { + int ret; struct clk *clk = devm_clk_get(dev, id); - if (PTR_ERR(clk) == -ENODATA) + ret = PTR_ERR(clk); + if (ret == -ENODATA || ret == -ENOENT) return NULL; return clk; @@ -335,7 +337,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 +361,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; |