From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-acpi@vger.kernel.org
Cc: devicetree@vger.kernel.org, sudeep.holla@arm.com,
lorenzo.pieralisi@arm.com, mika.westerberg@linux.intel.com,
rafael@kernel.org, mark.rutland@arm.com, broonie@kernel.org,
robh@kernel.org, ahs3@redhat.com, frowand.list@gmail.com
Subject: [PATCH v2 4/7] ACPI: Constify acpi_bus helper functions, switch to macros
Date: Thu, 13 Jul 2017 16:27:04 +0300 [thread overview]
Message-ID: <1499952427-16130-5-git-send-email-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <1499952427-16130-1-git-send-email-sakari.ailus@linux.intel.com>
Constify arguments to is_acpi_node(), is_acpi_device_node(),
is_acpi_static_node() and acpi_data_node_match(). Make
to_acpi_device_node() and to_acpi_data_node() macros that can cope with
const and non-const arguments.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
include/acpi/acpi_bus.h | 42 +++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 91b1e58..89bc213 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -399,43 +399,51 @@ extern const struct fwnode_operations acpi_device_fwnode_ops;
extern const struct fwnode_operations acpi_data_fwnode_ops;
extern const struct fwnode_operations acpi_static_fwnode_ops;
-static inline bool is_acpi_node(struct fwnode_handle *fwnode)
+static inline bool is_acpi_node(const struct fwnode_handle *fwnode)
{
return !IS_ERR_OR_NULL(fwnode) &&
(fwnode->ops == &acpi_device_fwnode_ops
|| fwnode->ops == &acpi_data_fwnode_ops);
}
-static inline bool is_acpi_device_node(struct fwnode_handle *fwnode)
+static inline bool is_acpi_device_node(const struct fwnode_handle *fwnode)
{
return !IS_ERR_OR_NULL(fwnode) &&
fwnode->ops == &acpi_device_fwnode_ops;
}
-static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
-{
- return is_acpi_device_node(fwnode) ?
- container_of(fwnode, struct acpi_device, fwnode) : NULL;
-}
-
-static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
+#define to_acpi_device_node(__fwnode) \
+ ({ \
+ typeof(__fwnode) __to_acpi_device_node_fwnode = __fwnode; \
+ \
+ is_acpi_device_node(__to_acpi_device_node_fwnode) ? \
+ container_of(__to_acpi_device_node_fwnode, \
+ struct acpi_device, fwnode) : \
+ NULL; \
+ })
+
+static inline bool is_acpi_data_node(const struct fwnode_handle *fwnode)
{
return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &acpi_data_fwnode_ops;
}
-static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
-{
- return is_acpi_data_node(fwnode) ?
- container_of(fwnode, struct acpi_data_node, fwnode) : NULL;
-}
-
-static inline bool is_acpi_static_node(struct fwnode_handle *fwnode)
+#define to_acpi_data_node(__fwnode) \
+ ({ \
+ typeof(__fwnode) __to_acpi_data_node_fwnode = __fwnode; \
+ \
+ is_acpi_data_node(__to_acpi_data_node_fwnode) ? \
+ container_of(__to_acpi_data_node_fwnode, \
+ struct acpi_data_node, fwnode) : \
+ NULL; \
+ })
+
+static inline bool is_acpi_static_node(const struct fwnode_handle *fwnode)
{
return !IS_ERR_OR_NULL(fwnode) &&
fwnode->ops == &acpi_static_fwnode_ops;
}
-static inline bool acpi_data_node_match(struct fwnode_handle *fwnode,
+static inline bool acpi_data_node_match(const struct fwnode_handle *fwnode,
const char *name)
{
return is_acpi_data_node(fwnode) ?
--
2.7.4
next prev parent reply other threads:[~2017-07-13 13:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-13 13:27 [PATCH v2 0/7] Remove fwnode type field, constify property fwnode arguments Sakari Ailus
2017-07-13 13:27 ` [PATCH v2 1/7] ACPI: Use IS_ERR_OR_NULL() instead of non-NULL check in is_acpi_data_node Sakari Ailus
2017-07-13 13:27 ` [PATCH v2 2/7] device property: Get rid of struct fwnode_handle type field Sakari Ailus
2017-07-13 13:27 ` Sakari Ailus [this message]
[not found] ` <1499952427-16130-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-07-13 13:27 ` [PATCH v2 3/7] ACPI: Prepare for constifying acpi_get_next_subnode() fwnode argument Sakari Ailus
2017-07-13 13:27 ` [PATCH v2 5/7] ACPI: Constify internal fwnode arguments Sakari Ailus
2017-07-13 13:27 ` [PATCH v2 6/7] device property: Constify argument to pset fwnode backend Sakari Ailus
2017-07-13 13:27 ` [PATCH v2 7/7] device property: Constify fwnode property API Sakari Ailus
2017-07-13 15:07 ` Rob Herring
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=1499952427-16130-5-git-send-email-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=ahs3@redhat.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=linux-acpi@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=mark.rutland@arm.com \
--cc=mika.westerberg@linux.intel.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=sudeep.holla@arm.com \
/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).