public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Kishon Vijay Abraham I <kishon@ti.com>
To: u-boot@lists.denx.de
Subject: [PATCH 2/2] reset: Let reset API's handle gracefully if reset_ctl is -ENODATA
Date: Fri, 7 May 2021 16:32:02 +0530	[thread overview]
Message-ID: <20210507110202.13697-3-kishon@ti.com> (raw)
In-Reply-To: <20210507110202.13697-1-kishon@ti.com>

Let reset API's (like reset_assert(), reset_deassert(), ..) handle
gracefully if the argument reset_ctl is -ENODATA. This is for seamlessly
handling client drivers which get optional reset controller using
devm_reset_control_get_optional().

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/reset/reset-uclass.c | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index 906f58ce3d..077ca956f4 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -162,7 +162,12 @@ int reset_get_by_name(struct udevice *dev, const char *name,
 
 int reset_request(struct reset_ctl *reset_ctl)
 {
-	struct reset_ops *ops = reset_dev_ops(reset_ctl->dev);
+	struct reset_ops *ops;
+
+	if (IS_ERR(reset_ctl) && PTR_ERR(reset_ctl) == -ENODATA)
+		return 0;
+
+	ops = reset_dev_ops(reset_ctl->dev);
 
 	debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
 
@@ -171,7 +176,12 @@ int reset_request(struct reset_ctl *reset_ctl)
 
 int reset_free(struct reset_ctl *reset_ctl)
 {
-	struct reset_ops *ops = reset_dev_ops(reset_ctl->dev);
+	struct reset_ops *ops;
+
+	if (IS_ERR(reset_ctl) && PTR_ERR(reset_ctl) == -ENODATA)
+		return 0;
+
+	ops = reset_dev_ops(reset_ctl->dev);
 
 	debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
 
@@ -180,7 +190,12 @@ int reset_free(struct reset_ctl *reset_ctl)
 
 int reset_assert(struct reset_ctl *reset_ctl)
 {
-	struct reset_ops *ops = reset_dev_ops(reset_ctl->dev);
+	struct reset_ops *ops;
+
+	if (IS_ERR(reset_ctl) && PTR_ERR(reset_ctl) == -ENODATA)
+		return 0;
+
+	ops = reset_dev_ops(reset_ctl->dev);
 
 	debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
 
@@ -202,7 +217,12 @@ int reset_assert_bulk(struct reset_ctl_bulk *bulk)
 
 int reset_deassert(struct reset_ctl *reset_ctl)
 {
-	struct reset_ops *ops = reset_dev_ops(reset_ctl->dev);
+	struct reset_ops *ops;
+
+	if (IS_ERR(reset_ctl) && PTR_ERR(reset_ctl) == -ENODATA)
+		return 0;
+
+	ops = reset_dev_ops(reset_ctl->dev);
 
 	debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
 
@@ -224,9 +244,12 @@ int reset_deassert_bulk(struct reset_ctl_bulk *bulk)
 
 int reset_status(struct reset_ctl *reset_ctl)
 {
-	struct reset_ops *ops = reset_dev_ops(reset_ctl->dev);
+	struct reset_ops *ops;
 
-	debug("%s(reset_ctl=%p)\n", __func__, reset_ctl);
+	if (IS_ERR(reset_ctl) && PTR_ERR(reset_ctl) == -ENODATA)
+		return 0;
+
+	ops = reset_dev_ops(reset_ctl->dev);
 
 	return ops->rst_status(reset_ctl);
 }
-- 
2.17.1

  parent reply	other threads:[~2021-05-07 11:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07 11:02 [PATCH 0/2] reset: Fix the behavior of optional reset Kishon Vijay Abraham I
2021-05-07 11:02 ` [PATCH 1/2] reset: Do not return NULL on error for devm_reset_control_get_optional() Kishon Vijay Abraham I
2021-05-07 16:34   ` Simon Glass
2021-05-11  6:26     ` Kishon Vijay Abraham I
2021-05-11 16:39       ` Simon Glass
2021-05-13  6:15         ` Kishon Vijay Abraham I
2021-05-13 23:56           ` Simon Glass
2021-05-14  5:18             ` Kishon Vijay Abraham I
2021-06-08 10:40               ` Pratyush Yadav
2021-06-19 17:32                 ` Simon Glass
2021-05-07 11:02 ` Kishon Vijay Abraham I [this message]
2021-05-07 16:34   ` [PATCH 2/2] reset: Let reset API's handle gracefully if reset_ctl is -ENODATA Simon Glass
2021-05-13  6:30     ` Kishon Vijay Abraham I
2021-05-13 17:00       ` Simon Glass

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=20210507110202.13697-3-kishon@ti.com \
    --to=kishon@ti.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox