linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of: add dummy of_platform_device_destroy
@ 2020-01-07 22:09 Arnd Bergmann
  2020-01-07 23:04 ` Rob Herring
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2020-01-07 22:09 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand, Jyri Sarha, Kishon Vijay Abraham I
  Cc: Arnd Bergmann, devicetree, linux-kernel

The new phy-j721e-wiz driver causes a link failure without CONFIG_OF:

drivers/phy/ti/phy-j721e-wiz.o: In function `wiz_remove':
phy-j721e-wiz.c:(.text+0x40): undefined reference to `of_platform_device_destroy'

Add a dummy version of this function to avoid having to add Kconfig
dependencies for the driver.

Fixes: 42440de5438a ("phy: ti: j721e-wiz: Add support for WIZ module present in TI J721E SoC")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/linux/of_platform.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index 84a966623e78..2551c263e57d 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -54,11 +54,16 @@ extern struct platform_device *of_device_alloc(struct device_node *np,
 					 struct device *parent);
 #ifdef CONFIG_OF
 extern struct platform_device *of_find_device_by_node(struct device_node *np);
+extern int of_platform_device_destroy(struct device *dev, void *data);
 #else
 static inline struct platform_device *of_find_device_by_node(struct device_node *np)
 {
 	return NULL;
 }
+static inline int of_platform_device_destroy(struct device *dev, void *data)
+{
+	return 0;
+}
 #endif
 
 /* Platform devices and busses creation */
-- 
2.20.0


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

* Re: [PATCH] of: add dummy of_platform_device_destroy
  2020-01-07 22:09 [PATCH] of: add dummy of_platform_device_destroy Arnd Bergmann
@ 2020-01-07 23:04 ` Rob Herring
  2020-01-08  8:25   ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Rob Herring @ 2020-01-07 23:04 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Frank Rowand, Jyri Sarha, Kishon Vijay Abraham I, devicetree,
	linux-kernel

On Tue, Jan 7, 2020 at 4:09 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> The new phy-j721e-wiz driver causes a link failure without CONFIG_OF:
>
> drivers/phy/ti/phy-j721e-wiz.o: In function `wiz_remove':
> phy-j721e-wiz.c:(.text+0x40): undefined reference to `of_platform_device_destroy'
>
> Add a dummy version of this function to avoid having to add Kconfig
> dependencies for the driver.
>
> Fixes: 42440de5438a ("phy: ti: j721e-wiz: Add support for WIZ module present in TI J721E SoC")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  include/linux/of_platform.h | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
> index 84a966623e78..2551c263e57d 100644
> --- a/include/linux/of_platform.h
> +++ b/include/linux/of_platform.h
> @@ -54,11 +54,16 @@ extern struct platform_device *of_device_alloc(struct device_node *np,
>                                          struct device *parent);
>  #ifdef CONFIG_OF
>  extern struct platform_device *of_find_device_by_node(struct device_node *np);
> +extern int of_platform_device_destroy(struct device *dev, void *data);

This is already declared, so don't you want to remove the existing one.

>  #else
>  static inline struct platform_device *of_find_device_by_node(struct device_node *np)
>  {
>         return NULL;
>  }
> +static inline int of_platform_device_destroy(struct device *dev, void *data)
> +{
> +       return 0;
> +}

I'm curious why this is needed, but of_platform_device_create() is not?

>  #endif
>
>  /* Platform devices and busses creation */
> --
> 2.20.0
>

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

* Re: [PATCH] of: add dummy of_platform_device_destroy
  2020-01-07 23:04 ` Rob Herring
@ 2020-01-08  8:25   ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2020-01-08  8:25 UTC (permalink / raw)
  To: Rob Herring
  Cc: Frank Rowand, Jyri Sarha, Kishon Vijay Abraham I, DTML, linux-kernel

On Wed, Jan 8, 2020 at 12:04 AM Rob Herring <robh+dt@kernel.org> wrote:
>
> On Tue, Jan 7, 2020 at 4:09 PM Arnd Bergmann <arnd@arndb.de> wrote:
> >
> > The new phy-j721e-wiz driver causes a link failure without CONFIG_OF:
> >
> > drivers/phy/ti/phy-j721e-wiz.o: In function `wiz_remove':
> > phy-j721e-wiz.c:(.text+0x40): undefined reference to `of_platform_device_destroy'
> >
> > Add a dummy version of this function to avoid having to add Kconfig
> > dependencies for the driver.
> >
> > Fixes: 42440de5438a ("phy: ti: j721e-wiz: Add support for WIZ module present in TI J721E SoC")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> >  include/linux/of_platform.h | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
> > index 84a966623e78..2551c263e57d 100644
> > --- a/include/linux/of_platform.h
> > +++ b/include/linux/of_platform.h
> > @@ -54,11 +54,16 @@ extern struct platform_device *of_device_alloc(struct device_node *np,
> >                                          struct device *parent);
> >  #ifdef CONFIG_OF
> >  extern struct platform_device *of_find_device_by_node(struct device_node *np);
> > +extern int of_platform_device_destroy(struct device *dev, void *data);
>
> This is already declared, so don't you want to remove the existing one.

Yes, this is what I had intended. I'm surprised there are no warnings when
the compiler sees both an 'extern' and a 'static inline' declaration, but both
clang and gcc seem to accept this, as long as the 'static inline' declaration
comes first.

> >  #else
> >  static inline struct platform_device *of_find_device_by_node(struct device_node *np)
> >  {
> >         return NULL;
> >  }
> > +static inline int of_platform_device_destroy(struct device *dev, void *data)
> > +{
> > +       return 0;
> > +}
>
> I'm curious why this is needed, but of_platform_device_create() is not?

I think what happens in the driver is that this is called from the
probe function
after calling some other interfaces that always return an error without
CONFIG_OF, so the compiler manages to optimize out that call.

I agree it makes sense to treat create the same as remove, I'll send a new
version addressing both comments.

     Arnd

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

end of thread, other threads:[~2020-01-08  8:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-07 22:09 [PATCH] of: add dummy of_platform_device_destroy Arnd Bergmann
2020-01-07 23:04 ` Rob Herring
2020-01-08  8:25   ` Arnd Bergmann

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).