diff options
author | John Hubbard <jhubbard@nvidia.com> | 2017-09-15 20:35:27 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-09-19 16:42:31 -0400 |
commit | 9e987b70ada27554c5d176421de1d167218c49b5 (patch) | |
tree | 1eb0e06e7c6f443ee1826554876ddc70c5b44f47 | |
parent | 2bd6bf03f4c1c59381d62c61d03f6cc3fe71f66e (diff) |
ACPI / bus: Make ACPI_HANDLE() work for non-GPL code again
Due to commit db3e50f3234b (device property: Get rid of struct
fwnode_handle type field), ACPI_HANDLE() inadvertently became
a GPL-only call. The call path that led to that was:
ACPI_HANDLE()
ACPI_COMPANION()
to_acpi_device_node()
is_acpi_device_node()
acpi_device_fwnode_ops
DECLARE_ACPI_FWNODE_OPS(acpi_device_fwnode_ops);
...and the new DECLARE_ACPI_FWNODE_OPS() includes
EXPORT_SYMBOL_GPL, whereas previously it was a static struct.
In order to avoid changing any of that, let's instead provide ever
so slightly better encapsulation of those struct fwnode_operations
instances. Those do not really need to be directly used in
inline function calls in header files. Simply moving two small
functions (is_acpi_device_node and is_acpi_data_node) out of
acpi_bus.h, and into a .c file, does that.
That leaves the internals of struct fwnode_operations as GPL-only
(which I think was the intent all along), but un-breaks any driver
code out there that relies on the ACPI subsystem's being (historically)
an EXPORT_SYMBOL-usable system. By that, I mean, ACPI_HANDLE() and
other basic ACPI calls were non-GPL-protected.
Also, while I'm there, remove a tiny bit of redundancy that was missed
in the earlier commit, by having is_acpi_node() use the other two
routines, instead of checking fwnode directly.
Fixes: db3e50f3234b (device property: Get rid of struct fwnode_handle type field)
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/property.c | 13 | ||||
-rw-r--r-- | include/acpi/acpi_bus.h | 18 |
2 files changed, 17 insertions, 14 deletions
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index c1c216163de3..1e3c2517a1ac 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c | |||
@@ -1293,3 +1293,16 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, | |||
1293 | DECLARE_ACPI_FWNODE_OPS(acpi_device_fwnode_ops); | 1293 | DECLARE_ACPI_FWNODE_OPS(acpi_device_fwnode_ops); |
1294 | DECLARE_ACPI_FWNODE_OPS(acpi_data_fwnode_ops); | 1294 | DECLARE_ACPI_FWNODE_OPS(acpi_data_fwnode_ops); |
1295 | const struct fwnode_operations acpi_static_fwnode_ops; | 1295 | const struct fwnode_operations acpi_static_fwnode_ops; |
1296 | |||
1297 | bool is_acpi_device_node(const struct fwnode_handle *fwnode) | ||
1298 | { | ||
1299 | return !IS_ERR_OR_NULL(fwnode) && | ||
1300 | fwnode->ops == &acpi_device_fwnode_ops; | ||
1301 | } | ||
1302 | EXPORT_SYMBOL(is_acpi_device_node); | ||
1303 | |||
1304 | bool is_acpi_data_node(const struct fwnode_handle *fwnode) | ||
1305 | { | ||
1306 | return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &acpi_data_fwnode_ops; | ||
1307 | } | ||
1308 | EXPORT_SYMBOL(is_acpi_data_node); | ||
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index dedf9d789166..fa1505292f6c 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
@@ -399,17 +399,12 @@ extern const struct fwnode_operations acpi_device_fwnode_ops; | |||
399 | extern const struct fwnode_operations acpi_data_fwnode_ops; | 399 | extern const struct fwnode_operations acpi_data_fwnode_ops; |
400 | extern const struct fwnode_operations acpi_static_fwnode_ops; | 400 | extern const struct fwnode_operations acpi_static_fwnode_ops; |
401 | 401 | ||
402 | bool is_acpi_device_node(const struct fwnode_handle *fwnode); | ||
403 | bool is_acpi_data_node(const struct fwnode_handle *fwnode); | ||
404 | |||
402 | static inline bool is_acpi_node(const struct fwnode_handle *fwnode) | 405 | static inline bool is_acpi_node(const struct fwnode_handle *fwnode) |
403 | { | 406 | { |
404 | return !IS_ERR_OR_NULL(fwnode) && | 407 | return (is_acpi_device_node(fwnode) || is_acpi_data_node(fwnode)); |
405 | (fwnode->ops == &acpi_device_fwnode_ops | ||
406 | || fwnode->ops == &acpi_data_fwnode_ops); | ||
407 | } | ||
408 | |||
409 | static inline bool is_acpi_device_node(const struct fwnode_handle *fwnode) | ||
410 | { | ||
411 | return !IS_ERR_OR_NULL(fwnode) && | ||
412 | fwnode->ops == &acpi_device_fwnode_ops; | ||
413 | } | 408 | } |
414 | 409 | ||
415 | #define to_acpi_device_node(__fwnode) \ | 410 | #define to_acpi_device_node(__fwnode) \ |
@@ -422,11 +417,6 @@ static inline bool is_acpi_device_node(const struct fwnode_handle *fwnode) | |||
422 | NULL; \ | 417 | NULL; \ |
423 | }) | 418 | }) |
424 | 419 | ||
425 | static inline bool is_acpi_data_node(const struct fwnode_handle *fwnode) | ||
426 | { | ||
427 | return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &acpi_data_fwnode_ops; | ||
428 | } | ||
429 | |||
430 | #define to_acpi_data_node(__fwnode) \ | 420 | #define to_acpi_data_node(__fwnode) \ |
431 | ({ \ | 421 | ({ \ |
432 | typeof(__fwnode) __to_acpi_data_node_fwnode = __fwnode; \ | 422 | typeof(__fwnode) __to_acpi_data_node_fwnode = __fwnode; \ |