mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 02/10] of: Add convenience functions to en/disable devicenodes
Date: Tue, 16 Jul 2013 16:05:58 +0200	[thread overview]
Message-ID: <1373983566-27721-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1373983566-27721-1-git-send-email-s.hauer@pengutronix.de>

These functions allow to manipulate the "status" property of
devicenodes effectively enabling/disabling devices.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/of/base.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/of.h      |  5 +++++
 2 files changed, 70 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 7bee912..9559bff 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1752,3 +1752,68 @@ int of_add_initrd(struct device_node *root, resource_size_t start,
 
 	return 0;
 }
+
+/**
+ * of_device_enable - enable a devicenode device
+ * @node - the node to enable
+ *
+ * This deletes the status property of a devicenode effectively
+ * enabling the device.
+ */
+int of_device_enable(struct device_node *node)
+{
+	struct property *pp;
+
+	pp = of_find_property(node, "status", NULL);
+	if (!pp)
+		return 0;
+
+	of_delete_property(pp);
+
+	return 0;
+}
+
+/**
+ * of_device_enable_path - enable a devicenode
+ * @path - the nodepath to enable
+ *
+ * wrapper around of_device_enable taking the nodepath as argument
+ */
+int of_device_enable_path(const char *path)
+{
+	struct device_node *node;
+
+	node = of_find_node_by_path(path);
+	if (!node)
+		return -ENODEV;
+
+	return of_device_enable(node);
+}
+
+/**
+ * of_device_enable - disable a devicenode device
+ * @node - the node to disable
+ *
+ * This sets the status of a devicenode to "disabled"
+ */
+int of_device_disable(struct device_node *node)
+{
+	return of_set_property(node, "status", "disabled", sizeof("disabled"), 1);
+}
+
+/**
+ * of_device_disable_path - disable a devicenode
+ * @path - the nodepath to disable
+ *
+ * wrapper around of_device_disable taking the nodepath as argument
+ */
+int of_device_disable_path(const char *path)
+{
+	struct device_node *node;
+
+	node = of_find_node_by_path(path);
+	if (!node)
+		return -ENODEV;
+
+	return of_device_disable(node);
+}
diff --git a/include/of.h b/include/of.h
index 710383c..7b600f0 100644
--- a/include/of.h
+++ b/include/of.h
@@ -682,4 +682,9 @@ static inline int of_property_write_u64(struct device_node *np,
 
 extern const struct of_device_id of_default_bus_match_table[];
 
+int of_device_enable(struct device_node *node);
+int of_device_enable_path(const char *path);
+int of_device_disable(struct device_node *node);
+int of_device_disable_path(const char *path);
+
 #endif /* __OF_H */
-- 
1.8.3.2


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

  parent reply	other threads:[~2013-07-16 14:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-16 14:05 [PATCH] configure environment from devicetree Sascha Hauer
2013-07-16 14:05 ` [PATCH 01/10] of: partition: check for valid node Sascha Hauer
2013-07-16 14:05 ` Sascha Hauer [this message]
2013-07-16 14:05 ` [PATCH 03/10] mtd: Add devicetree partition parsing Sascha Hauer
2013-07-16 14:06 ` [PATCH 04/10] mci: " Sascha Hauer
2013-07-16 14:06 ` [PATCH 05/10] Add configurability via devicetree Sascha Hauer
2013-07-16 14:06 ` [PATCH 06/10] ARM: i.MX Datamodul edmqx6: configure environment from devicetree Sascha Hauer
2013-07-16 14:06 ` [PATCH 07/10] ARM: i.MX51 babbage: " Sascha Hauer
2013-07-16 14:06 ` [PATCH 08/10] ARM: i.MX53 QSB: " Sascha Hauer
2013-07-16 14:06 ` [PATCH 09/10] ARM: i.MX51 efikasb: " Sascha Hauer
2013-07-16 14:06 ` [PATCH 10/10] ARM: i.MX6 tqma6x: " 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=1373983566-27721-3-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