devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: sudeep.holla-5wv7dgnIgG8@public.gmane.org,
	lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org,
	mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
	rafael-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	ahs3-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Subject: [PATCH 12/20] device property: Use fwnode_operations for obtaining parent node
Date: Thu, 23 Feb 2017 19:01:08 +0200	[thread overview]
Message-ID: <1487869276-25244-13-git-send-email-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <1487869276-25244-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

Change the implementation of fwnode_property_get_parent() function to use
struct fwnode_operations.

Signed-off-by: Sakari Ailus <sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/acpi/property.c |  7 +++++++
 drivers/base/property.c | 14 +-------------
 drivers/of/base.c       | 12 ++++++++++++
 3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 4e76b31..a20b81f 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -1150,8 +1150,15 @@ static int acpi_fwnode_property_read_string_array(
 				   val, nval);
 }
 
+static struct fwnode_handle *acpi_fwnode_get_parent(
+	struct fwnode_handle *fwnode)
+{
+	return acpi_node_get_parent(fwnode);
+}
+
 const struct fwnode_operations acpi_fwnode_ops = {
 	.property_present = acpi_fwnode_property_present,
 	.property_read_int_array = acpi_fwnode_property_read_int_array,
 	.property_read_string_array = acpi_fwnode_property_read_string_array,
+	.get_parent = acpi_fwnode_get_parent,
 };
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 136ba66..e730f4f 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -863,19 +863,7 @@ EXPORT_SYMBOL_GPL(fwnode_get_next_parent);
  */
 struct fwnode_handle *fwnode_get_parent(struct fwnode_handle *fwnode)
 {
-	struct fwnode_handle *parent = NULL;
-
-	if (is_of_node(fwnode)) {
-		struct device_node *node;
-
-		node = of_get_parent(to_of_node(fwnode));
-		if (node)
-			parent = &node->fwnode;
-	} else if (is_acpi_node(fwnode)) {
-		parent = acpi_node_get_parent(fwnode);
-	}
-
-	return parent;
+	return fwnode_call_ptr_op(fwnode, get_parent);
 }
 EXPORT_SYMBOL_GPL(fwnode_get_parent);
 
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 7bd9eec..5825eda 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2531,10 +2531,22 @@ static int of_fwnode_property_read_string_array(
 	return -EOVERFLOW;
 }
 
+static struct fwnode_handle *of_fwnode_get_parent(struct fwnode_handle *fwnode)
+{
+	struct device_node *node;
+
+	node = of_get_parent(to_of_node(fwnode));
+	if (node)
+		return of_fwnode_handle(node);
+
+	return NULL;
+}
+
 const struct fwnode_operations of_fwnode_ops = {
 	.get = of_fwnode_get,
 	.put = of_fwnode_put,
 	.property_present = of_fwnode_property_present,
 	.property_read_int_array = of_fwnode_property_read_int_array,
 	.property_read_string_array = of_fwnode_property_read_string_array,
+	.get_parent = of_fwnode_get_parent,
 };
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-02-23 17:01 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-23 17:00 [PATCH 00/20] Move firmware specific code to firmware specific locations Sakari Ailus
2017-02-23 17:00 ` [PATCH 01/20] device property: fwnode_property_read_string_array() may return -EILSEQ Sakari Ailus
2017-02-23 17:00 ` [PATCH 02/20] device property: Fix reading pset strings using array access functions Sakari Ailus
2017-02-23 17:00 ` [PATCH 03/20] device property: of_property_read_string_array() returns number of strings Sakari Ailus
2017-02-23 23:42   ` Rob Herring
2017-02-24  8:15     ` Sakari Ailus
2017-02-23 17:01 ` [PATCH 04/20] device property: Add operations struct for fwnode operations Sakari Ailus
2017-02-23 17:01 ` [PATCH 05/20] device property: Add macros for calling " Sakari Ailus
2017-02-24  9:36   ` [PATCH v1.1 " Sakari Ailus
2017-02-23 17:01 ` [PATCH 06/20] device property: Introduce firmware property operations, set them Sakari Ailus
2017-02-23 17:01 ` [PATCH 07/20] device property: Use fwnode_operations for fwnode_handle_{get,put} Sakari Ailus
2017-02-23 17:01 ` [PATCH 08/20] device property: Use fwnode_operations for fwnode_property_present() Sakari Ailus
2017-02-23 17:01 ` [PATCH 09/20] device property: Use fwnode_operations for reading integer arrays Sakari Ailus
2017-02-23 17:01 ` [PATCH 10/20] device property: Read strings using string array reading functions Sakari Ailus
2017-02-23 17:01 ` [PATCH 13/20] device property: Use fwnode_operations for obtaining next child node Sakari Ailus
2017-02-23 17:01 ` [PATCH 14/20] device property: Use fwnode_operations for obtaining a named " Sakari Ailus
     [not found] ` <1487869276-25244-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-02-23 17:01   ` [PATCH 11/20] device property: Use fwnode_operations for reading string arrays Sakari Ailus
2017-02-23 17:01   ` Sakari Ailus [this message]
2017-02-23 17:01   ` [PATCH 15/20] device property: Use fwnode_operations for obtaining next graph endpoint Sakari Ailus
2017-02-23 17:01   ` [PATCH 17/20] device property: Use fwnode_operations for obtaining the remote port Sakari Ailus
2017-02-23 17:01 ` [PATCH 16/20] device property: Use fwnode_operations for obtaining the remote endpoint Sakari Ailus
2017-02-23 17:01 ` [PATCH 18/20] device property: Use fwnode_operations for obtaining the remote port parent Sakari Ailus
2017-02-23 17:01 ` [PATCH 19/20] device property: Use fwnode_operations for parsing graph endpoint Sakari Ailus
2017-02-23 17:01 ` [PATCH 20/20] device property: Implement fwnode_get_next_parent() using fwnode interface Sakari Ailus
2017-02-23 22:37 ` [PATCH 00/20] Move firmware specific code to firmware specific locations Rafael J. Wysocki
     [not found]   ` <2915459.fDeP2CYj8T-yvgW3jdyMHm1GS7QM15AGw@public.gmane.org>
2017-02-24  8:25     ` Sakari Ailus

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=1487869276-25244-13-git-send-email-sakari.ailus@linux.intel.com \
    --to=sakari.ailus-vuqaysv1563yd54fqh9/ca@public.gmane.org \
    --cc=ahs3-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=rafael-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=sudeep.holla-5wv7dgnIgG8@public.gmane.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;
as well as URLs for NNTP newsgroup(s).