All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Xiwen via B4 Relay <devnull+forbidden405.outlook.com@kernel.org>
To: Lukasz Majewski <lukma@denx.de>, Sean Anderson <seanga2@gmail.com>
Cc: u-boot@lists.denx.de, Yang Xiwen <forbidden405@outlook.com>
Subject: [PATCH RESEND 3/5] clk: also handle ENOENT in *_optional functions
Date: Fri, 18 Aug 2023 01:04:02 +0800	[thread overview]
Message-ID: <20230818-clk-fix-v1-3-49ec18f820bf@outlook.com> (raw)
In-Reply-To: <20230818-clk-fix-v1-0-49ec18f820bf@outlook.com>

From: Yang Xiwen <forbidden405@outlook.com>

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>
---
 include/clk.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/clk.h b/include/clk.h
index d91285235f..f95da0838d 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;

-- 
2.34.1


WARNING: multiple messages have this Message-ID (diff)
From: Yang Xiwen <forbidden405@outlook.com>
To: Lukasz Majewski <lukma@denx.de>, Sean Anderson <seanga2@gmail.com>
Cc: u-boot@lists.denx.de, Yang Xiwen <forbidden405@outlook.com>
Subject: [PATCH RESEND 3/5] clk: also handle ENOENT in *_optional functions
Date: Fri, 18 Aug 2023 01:04:02 +0800	[thread overview]
Message-ID: <20230818-clk-fix-v1-3-49ec18f820bf@outlook.com> (raw)
In-Reply-To: <20230818-clk-fix-v1-0-49ec18f820bf@outlook.com>

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>
---
 include/clk.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/clk.h b/include/clk.h
index d91285235f..f95da0838d 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;

-- 
2.34.1


  parent reply	other threads:[~2023-08-17 17:04 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-17 17:03 [PATCH RESEND 0/5] clk: A few bugfixes/enhancements for CCF Yang Xiwen via B4 Relay
2023-08-17 17:03 ` Yang Xiwen
2023-08-17 17:04 ` [PATCH RESEND 1/5] clk: export clk_register_mux_table() Yang Xiwen via B4 Relay
2023-08-17 17:04   ` Yang Xiwen
2023-11-01 17:50   ` Sean Anderson
2023-11-01 18:37     ` Yang Xiwen
2023-11-01 18:42       ` Sean Anderson
2023-08-17 17:04 ` [PATCH RESEND 2/5] clk: call log_debug() instead to avoid console log printing Yang Xiwen via B4 Relay
2023-08-17 17:04   ` Yang Xiwen
2023-11-01 17:55   ` Sean Anderson
2023-11-01 18:01     ` Sean Anderson
2023-11-01 18:54       ` Yang Xiwen
2023-08-17 17:04 ` Yang Xiwen via B4 Relay [this message]
2023-08-17 17:04   ` [PATCH RESEND 3/5] clk: also handle ENOENT in *_optional functions Yang Xiwen
2023-11-01 18:03   ` Sean Anderson
2023-08-17 17:04 ` [PATCH RESEND 4/5] clk: promote clk_dev_ops to linux/clk-provider.h Yang Xiwen via B4 Relay
2023-08-17 17:04   ` Yang Xiwen
2023-08-17 17:04 ` [PATCH RESEND 5/5] clk: ccf: call clock provided ops directly for endisable() Yang Xiwen via B4 Relay
2023-08-17 17:04   ` Yang Xiwen
2023-11-01 18:19   ` Sean Anderson
2023-11-01 18:50     ` Yang Xiwen
     [not found]     ` <f94b7313-0dd4-477b-b144-d3b2d08d14ad@outlook.com>
2023-11-01 20:33       ` Yang Xiwen
2023-11-04 15:35         ` Sean Anderson
2023-08-24 18:51 ` [PATCH RESEND 0/5] clk: A few bugfixes/enhancements for CCF Yang Xiwen
2023-11-01 21:03 ` (subset) " Sean Anderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230818-clk-fix-v1-3-49ec18f820bf@outlook.com \
    --to=devnull+forbidden405.outlook.com@kernel.org \
    --cc=forbidden405@outlook.com \
    --cc=lukma@denx.de \
    --cc=seanga2@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.