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 v2 05/17] device property: Use fwnode_operations for fwnode_property_present()
Date: Mon,  6 Mar 2017 17:42:51 +0200	[thread overview]
Message-ID: <1488814983-25695-6-git-send-email-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <1488814983-25695-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

Change the implementation of fwnode_property_present() to use struct
fwnode_operations.

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

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 0651a74..14b96ec 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -1110,4 +1110,12 @@ int acpi_graph_get_remote_endpoint(struct fwnode_handle *fwnode,
 	return 0;
 }
 
-const struct fwnode_operations acpi_fwnode_ops;
+static bool acpi_fwnode_property_present(struct fwnode_handle *fwnode,
+					 const char *propname)
+{
+	return !acpi_node_prop_get(fwnode, propname, NULL);
+}
+
+const struct fwnode_operations acpi_fwnode_ops = {
+	.property_present = acpi_fwnode_property_present,
+};
diff --git a/drivers/base/property.c b/drivers/base/property.c
index faa4fa6..e150df0 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -183,7 +183,15 @@ static int pset_prop_read_string(struct property_set *pset,
 	return 0;
 }
 
-static const struct fwnode_operations pset_fwnode_ops;
+static bool pset_fwnode_property_present(struct fwnode_handle *fwnode,
+					 const char *propname)
+{
+	return !!pset_prop_get(to_pset_node(fwnode), propname);
+}
+
+static const struct fwnode_operations pset_fwnode_ops = {
+	.property_present = pset_fwnode_property_present,
+};
 
 /**
  * device_property_present - check if a property of a device is present
@@ -198,18 +206,6 @@ bool device_property_present(struct device *dev, const char *propname)
 }
 EXPORT_SYMBOL_GPL(device_property_present);
 
-static bool __fwnode_property_present(struct fwnode_handle *fwnode,
-				      const char *propname)
-{
-	if (is_of_node(fwnode))
-		return of_property_read_bool(to_of_node(fwnode), propname);
-	else if (is_acpi_node(fwnode))
-		return !acpi_node_prop_get(fwnode, propname, NULL);
-	else if (is_pset_node(fwnode))
-		return !!pset_prop_get(to_pset_node(fwnode), propname);
-	return false;
-}
-
 /**
  * fwnode_property_present - check if a property of a firmware node is present
  * @fwnode: Firmware node whose property to check
@@ -219,10 +215,11 @@ bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname)
 {
 	bool ret;
 
-	ret = __fwnode_property_present(fwnode, propname);
+	ret = fwnode_call_int_op(fwnode, property_present, propname);
 	if (ret == false && !IS_ERR_OR_NULL(fwnode) &&
 	    !IS_ERR_OR_NULL(fwnode->secondary))
-		ret = __fwnode_property_present(fwnode->secondary, propname);
+		ret = fwnode_call_int_op(fwnode->secondary, property_present,
+					 propname);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(fwnode_property_present);
diff --git a/drivers/of/base.c b/drivers/of/base.c
index c18da80..46e0b2a 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2546,7 +2546,14 @@ static void of_fwnode_put(struct fwnode_handle *fwnode)
 	of_node_put(to_of_node(fwnode));
 }
 
+static bool of_fwnode_property_present(struct fwnode_handle *fwnode,
+				       const char *propname)
+{
+	return of_property_read_bool(to_of_node(fwnode), propname);
+}
+
 const struct fwnode_operations of_fwnode_ops = {
 	.get = of_fwnode_get,
 	.put = of_fwnode_put,
+	.property_present = of_fwnode_property_present,
 };
-- 
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-03-06 15:42 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-06 15:42 [PATCH v2 00/17] Move firmware specific code to firmware specific locations Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 01/17] device property: Add operations struct for fwnode operations Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 02/17] device property: Add macros for calling " Sakari Ailus
     [not found] ` <1488814983-25695-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-03-06 15:42   ` [PATCH v2 03/17] device property: Introduce firmware property operations, set them Sakari Ailus
2017-03-06 15:42   ` [PATCH v2 04/17] device property: Use fwnode_operations for fwnode_handle_{get,put} Sakari Ailus
2017-03-06 15:42   ` Sakari Ailus [this message]
2017-03-06 15:42   ` [PATCH v2 06/17] device property: Use fwnode_operations for reading integer arrays Sakari Ailus
2017-03-06 15:42   ` [PATCH v2 09/17] device property: Use fwnode_operations for obtaining parent node Sakari Ailus
2017-03-13 22:27   ` [PATCH v2 00/17] Move firmware specific code to firmware specific locations Rafael J. Wysocki
2017-03-15 14:19     ` Sakari Ailus
2017-03-15 14:23       ` Rafael J. Wysocki
     [not found]         ` <CAJZ5v0i5o+2FksW+NmYQugD6qL-1QmREd2isATifu9n0g69Q+w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-16 22:50           ` Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 07/17] device property: Read strings using string array reading functions Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 08/17] device property: Use fwnode_operations for reading string arrays Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 10/17] device property: Use fwnode_operations for obtaining next child node Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 11/17] device property: Use fwnode_operations for obtaining a named " Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 12/17] device property: Use fwnode_operations for obtaining next graph endpoint Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 13/17] device property: Use fwnode_operations for obtaining the remote endpoint Sakari Ailus
2017-03-06 15:43 ` [PATCH v2 14/17] device property: Use fwnode_operations for obtaining the remote port Sakari Ailus
2017-03-06 15:43 ` [PATCH v2 15/17] device property: Use fwnode_operations for obtaining the remote port parent Sakari Ailus
2017-03-06 15:43 ` [PATCH v2 16/17] device property: Use fwnode_operations for parsing graph endpoint Sakari Ailus
2017-03-06 15:43 ` [PATCH v2 17/17] device property: Implement fwnode_get_next_parent() using fwnode interface 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=1488814983-25695-6-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).