Commit 8b9d6802 authored by Sakari Ailus's avatar Sakari Ailus Committed by Rafael J. Wysocki

ACPI: Constify acpi_bus helper functions, switch to macros

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: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 01c1da28
...@@ -399,43 +399,51 @@ extern const struct fwnode_operations acpi_device_fwnode_ops; ...@@ -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_data_fwnode_ops;
extern const struct fwnode_operations acpi_static_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) && return !IS_ERR_OR_NULL(fwnode) &&
(fwnode->ops == &acpi_device_fwnode_ops (fwnode->ops == &acpi_device_fwnode_ops
|| fwnode->ops == &acpi_data_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) && return !IS_ERR_OR_NULL(fwnode) &&
fwnode->ops == &acpi_device_fwnode_ops; fwnode->ops == &acpi_device_fwnode_ops;
} }
static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode) #define to_acpi_device_node(__fwnode) \
{ ({ \
return is_acpi_device_node(fwnode) ? typeof(__fwnode) __to_acpi_device_node_fwnode = __fwnode; \
container_of(fwnode, struct acpi_device, fwnode) : NULL; \
} is_acpi_device_node(__to_acpi_device_node_fwnode) ? \
container_of(__to_acpi_device_node_fwnode, \
static inline bool is_acpi_data_node(struct fwnode_handle *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; 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) #define to_acpi_data_node(__fwnode) \
{ ({ \
return is_acpi_data_node(fwnode) ? typeof(__fwnode) __to_acpi_data_node_fwnode = __fwnode; \
container_of(fwnode, struct acpi_data_node, fwnode) : NULL; \
} is_acpi_data_node(__to_acpi_data_node_fwnode) ? \
container_of(__to_acpi_data_node_fwnode, \
static inline bool is_acpi_static_node(struct fwnode_handle *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) && return !IS_ERR_OR_NULL(fwnode) &&
fwnode->ops == &acpi_static_fwnode_ops; 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) const char *name)
{ {
return is_acpi_data_node(fwnode) ? return is_acpi_data_node(fwnode) ?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment