All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] acpi: unbreak ACPI_HANDLE(), encapsulate fwnode_operations
@ 2017-09-16  0:35 john.hubbard
  2017-09-16  0:35 ` [PATCH 1/1] " john.hubbard
  0 siblings, 1 reply; 6+ messages in thread
From: john.hubbard @ 2017-09-16  0:35 UTC (permalink / raw)
  To: LKML, Rob Herring, Sakari Ailus, Mika Westerberg,
	Rafael J . Wysocki
  Cc: John Hubbard

From: John Hubbard <jhubbard@nvidia.com>

Hi everyone,

I really don't know for sure which fix is going to be preferred--the
following patch, or just an obvious one-line fix that changes
DECLARE_ACPI_FWNODE_OPS() so that it invokes EXPORT_SYMBOL, instead of
EXPORT_SYMBOL_GPL. I explained the reasoning in PATCH 1/1, anyway, so
please see what you think.

John Hubbard (1):
  acpi: unbreak ACPI_HANDLE(), encapsulate fwnode_operations

 drivers/acpi/property.c | 13 +++++++++++++
 include/acpi/acpi_bus.h | 18 ++++--------------
 2 files changed, 17 insertions(+), 14 deletions(-)

-- 
2.14.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/1] acpi: unbreak ACPI_HANDLE(), encapsulate fwnode_operations
  2017-09-16  0:35 [PATCH 0/1] acpi: unbreak ACPI_HANDLE(), encapsulate fwnode_operations john.hubbard
@ 2017-09-16  0:35 ` john.hubbard
  2017-09-18 10:50   ` Sakari Ailus
  2017-09-19  7:44   ` Mika Westerberg
  0 siblings, 2 replies; 6+ messages in thread
From: john.hubbard @ 2017-09-16  0:35 UTC (permalink / raw)
  To: LKML, Rob Herring, Sakari Ailus, Mika Westerberg,
	Rafael J . Wysocki
  Cc: John Hubbard

From: John Hubbard <jhubbard@nvidia.com>

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.

Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
 drivers/acpi/property.c | 13 +++++++++++++
 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,
 DECLARE_ACPI_FWNODE_OPS(acpi_device_fwnode_ops);
 DECLARE_ACPI_FWNODE_OPS(acpi_data_fwnode_ops);
 const struct fwnode_operations acpi_static_fwnode_ops;
+
+bool is_acpi_device_node(const struct fwnode_handle *fwnode)
+{
+	return !IS_ERR_OR_NULL(fwnode) &&
+		fwnode->ops == &acpi_device_fwnode_ops;
+}
+EXPORT_SYMBOL(is_acpi_device_node);
+
+bool is_acpi_data_node(const struct fwnode_handle *fwnode)
+{
+	return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &acpi_data_fwnode_ops;
+}
+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;
 extern const struct fwnode_operations acpi_data_fwnode_ops;
 extern const struct fwnode_operations acpi_static_fwnode_ops;
 
+bool is_acpi_device_node(const struct fwnode_handle *fwnode);
+bool is_acpi_data_node(const 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(const struct fwnode_handle *fwnode)
-{
-	return !IS_ERR_OR_NULL(fwnode) &&
-		fwnode->ops == &acpi_device_fwnode_ops;
+	return (is_acpi_device_node(fwnode) || is_acpi_data_node(fwnode));
 }
 
 #define to_acpi_device_node(__fwnode)					\
@@ -422,11 +417,6 @@ static inline bool is_acpi_device_node(const struct fwnode_handle *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;
-}
-
 #define to_acpi_data_node(__fwnode)					\
 	({								\
 		typeof(__fwnode) __to_acpi_data_node_fwnode = __fwnode;	\
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] acpi: unbreak ACPI_HANDLE(), encapsulate fwnode_operations
  2017-09-16  0:35 ` [PATCH 1/1] " john.hubbard
@ 2017-09-18 10:50   ` Sakari Ailus
  2017-09-19  7:44   ` Mika Westerberg
  1 sibling, 0 replies; 6+ messages in thread
From: Sakari Ailus @ 2017-09-18 10:50 UTC (permalink / raw)
  To: john.hubbard
  Cc: LKML, Rob Herring, Mika Westerberg, Rafael J . Wysocki,
	John Hubbard

Hi John,

On Fri, Sep 15, 2017 at 05:35:27PM -0700, john.hubbard@gmail.com wrote:
> From: John Hubbard <jhubbard@nvidia.com>
> 
> 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.

Works for me.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

OF appears to have the same effective change; Rob: let me know if you'd
like me to send a patch for that, or whether this is preferred. On OF both
appear to be used (EXPORT_SYMBOL / EXPORT_SYMBOL_GPL).

-- 
Regards,

Sakari Ailus
sakari.ailus@linux.intel.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] acpi: unbreak ACPI_HANDLE(), encapsulate fwnode_operations
  2017-09-16  0:35 ` [PATCH 1/1] " john.hubbard
  2017-09-18 10:50   ` Sakari Ailus
@ 2017-09-19  7:44   ` Mika Westerberg
  2017-09-19 20:39     ` Rafael J. Wysocki
  1 sibling, 1 reply; 6+ messages in thread
From: Mika Westerberg @ 2017-09-19  7:44 UTC (permalink / raw)
  To: john.hubbard
  Cc: LKML, Rob Herring, Sakari Ailus, Rafael J . Wysocki, John Hubbard

On Fri, Sep 15, 2017 at 05:35:27PM -0700, john.hubbard@gmail.com wrote:
> From: John Hubbard <jhubbard@nvidia.com>
> 
> 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.
> 
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] acpi: unbreak ACPI_HANDLE(), encapsulate fwnode_operations
  2017-09-19  7:44   ` Mika Westerberg
@ 2017-09-19 20:39     ` Rafael J. Wysocki
  2017-09-20  8:34       ` Mika Westerberg
  0 siblings, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2017-09-19 20:39 UTC (permalink / raw)
  To: Mika Westerberg, john.hubbard, Sakari Ailus
  Cc: LKML, Rob Herring, Rafael J . Wysocki, John Hubbard

On Tuesday, September 19, 2017 9:44:00 AM CEST Mika Westerberg wrote:
> On Fri, Sep 15, 2017 at 05:35:27PM -0700, john.hubbard@gmail.com wrote:
> > From: John Hubbard <jhubbard@nvidia.com>
> > 
> > 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.
> > 
> > Signed-off-by: John Hubbard <jhubbard@nvidia.com>
> 
> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> 

OK, applied.

Side note: I'm slightly unhappy with the number of checks in the
ACPI_COMPANION() path.

Do we really ever pass anything other than struct acpi_device to
ACPI_COMPANION_SET() as the second arg?

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] acpi: unbreak ACPI_HANDLE(), encapsulate fwnode_operations
  2017-09-19 20:39     ` Rafael J. Wysocki
@ 2017-09-20  8:34       ` Mika Westerberg
  0 siblings, 0 replies; 6+ messages in thread
From: Mika Westerberg @ 2017-09-20  8:34 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: john.hubbard, Sakari Ailus, LKML, Rob Herring, Rafael J . Wysocki,
	John Hubbard

On Tue, Sep 19, 2017 at 10:39:36PM +0200, Rafael J. Wysocki wrote:
> Do we really ever pass anything other than struct acpi_device to
> ACPI_COMPANION_SET() as the second arg?

No, and we should not accept anything else than acpi_device either.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-09-20  8:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-16  0:35 [PATCH 0/1] acpi: unbreak ACPI_HANDLE(), encapsulate fwnode_operations john.hubbard
2017-09-16  0:35 ` [PATCH 1/1] " john.hubbard
2017-09-18 10:50   ` Sakari Ailus
2017-09-19  7:44   ` Mika Westerberg
2017-09-19 20:39     ` Rafael J. Wysocki
2017-09-20  8:34       ` Mika Westerberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.