mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 1/3] reset: Allow dummy reset lines
Date: Mon, 23 Nov 2015 10:24:29 +0100	[thread overview]
Message-ID: <1448270671-24307-1-git-send-email-s.hauer@pengutronix.de> (raw)

Treat NULL as a dummy reset line which is returned by the reset core
when there is no reset line connected to a device (that is, no
reset is described in the device tree). With this consumers can
just use the reset functions without having to check for existence.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/reset/core.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 101913a..1821283 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -84,6 +84,9 @@ EXPORT_SYMBOL_GPL(reset_controller_unregister);
  */
 int reset_control_reset(struct reset_control *rstc)
 {
+	if (!rstc)
+		return 0;
+
 	if (rstc->rcdev->ops->reset)
 		return rstc->rcdev->ops->reset(rstc->rcdev, rstc->id);
 
@@ -97,6 +100,9 @@ EXPORT_SYMBOL_GPL(reset_control_reset);
  */
 int reset_control_assert(struct reset_control *rstc)
 {
+	if (!rstc)
+		return 0;
+
 	if (rstc->rcdev->ops->assert)
 		return rstc->rcdev->ops->assert(rstc->rcdev, rstc->id);
 
@@ -110,6 +116,9 @@ EXPORT_SYMBOL_GPL(reset_control_assert);
  */
 int reset_control_deassert(struct reset_control *rstc)
 {
+	if (!rstc)
+		return 0;
+
 	if (rstc->rcdev->ops->deassert)
 		return rstc->rcdev->ops->deassert(rstc->rcdev, rstc->id);
 
@@ -136,6 +145,9 @@ struct reset_control *of_reset_control_get(struct device_node *node,
 	int rstc_id;
 	int ret;
 
+	if (!of_get_property(node, "resets", NULL))
+		return NULL;
+
 	if (id)
 		index = of_property_match_string(node,
 						 "reset-names", id);
@@ -188,8 +200,13 @@ struct reset_control *reset_control_get(struct device_d *dev, const char *id)
 		return ERR_PTR(-EINVAL);
 
 	rstc = of_reset_control_get(dev->device_node, id);
-	if (!IS_ERR(rstc))
-		rstc->dev = dev;
+	if (IS_ERR(rstc))
+		return ERR_CAST(rstc);
+
+	if (!rstc)
+		return NULL;
+
+	rstc->dev = dev;
 
 	return rstc;
 }
@@ -202,7 +219,7 @@ EXPORT_SYMBOL_GPL(reset_control_get);
 
 void reset_control_put(struct reset_control *rstc)
 {
-	if (IS_ERR(rstc))
+	if (IS_ERR_OR_NULL(rstc))
 		return;
 
 	kfree(rstc);
-- 
2.6.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2015-11-23  9:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-23  9:24 Sascha Hauer [this message]
2015-11-23  9:24 ` [PATCH 2/3] reset: Remove unused *_optional functions Sascha Hauer
2015-11-23  9:24 ` [PATCH 3/3] reset: Add gpio reset support Sascha Hauer

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=1448270671-24307-1-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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