diff mbox series

[v6,3/5] of/platform: Add stubs for of_platform_device_create/destroy()

Message ID 20210305113832.v6.3.I08fd2e1c775af04f663730e9fb4d00e6bbb38541@changeid
State Superseded
Headers show
Series USB: misc: Add onboard_usb_hub driver | expand

Commit Message

Matthias Kaehlcke March 5, 2021, 7:38 p.m. UTC
Code for platform_device_create() and of_platform_device_create() is
only generated if CONFIG_OF_ADDRESS=y. Add stubs to avoid unresolved
symbols when CONFIG_OF_ADDRESS is not set.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---

Changes in v6:
- patch added to the series

 include/linux/of_platform.h | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

Comments

Rob Herring (Arm) March 8, 2021, 10:32 p.m. UTC | #1
On Fri, Mar 05, 2021 at 11:38:51AM -0800, Matthias Kaehlcke wrote:
> Code for platform_device_create() and of_platform_device_create() is


You mean of_platform_device_create and of_platform_device_destroy?

Does of_platform_populate not work in your usecase?

> only generated if CONFIG_OF_ADDRESS=y. Add stubs to avoid unresolved

> symbols when CONFIG_OF_ADDRESS is not set.

> 

> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>

> ---

> 

> Changes in v6:

> - patch added to the series

> 

>  include/linux/of_platform.h | 22 ++++++++++++++++++----

>  1 file changed, 18 insertions(+), 4 deletions(-)

> 

> diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h

> index 84a966623e78..d15b6cd5e1c3 100644

> --- a/include/linux/of_platform.h

> +++ b/include/linux/of_platform.h

> @@ -61,16 +61,18 @@ static inline struct platform_device *of_find_device_by_node(struct device_node

>  }

>  #endif

>  

> +extern int of_platform_bus_probe(struct device_node *root,

> +				 const struct of_device_id *matches,

> +				 struct device *parent);

> +

> +#ifdef CONFIG_OF_ADDRESS

>  /* Platform devices and busses creation */

>  extern struct platform_device *of_platform_device_create(struct device_node *np,

>  						   const char *bus_id,

>  						   struct device *parent);

>  

>  extern int of_platform_device_destroy(struct device *dev, void *data);

> -extern int of_platform_bus_probe(struct device_node *root,

> -				 const struct of_device_id *matches,

> -				 struct device *parent);

> -#ifdef CONFIG_OF_ADDRESS

> +

>  extern int of_platform_populate(struct device_node *root,

>  				const struct of_device_id *matches,

>  				const struct of_dev_auxdata *lookup,

> @@ -84,6 +86,18 @@ extern int devm_of_platform_populate(struct device *dev);

>  

>  extern void devm_of_platform_depopulate(struct device *dev);

>  #else

> +/* Platform devices and busses creation */

> +static inline struct platform_device *of_platform_device_create(struct device_node *np,

> +								const char *bus_id,

> +								struct device *parent)

> +{

> +	return NULL;

> +}

> +static inline int of_platform_device_destroy(struct device *dev, void *data)

> +{

> +	return -ENODEV;

> +}

> +

>  static inline int of_platform_populate(struct device_node *root,

>  					const struct of_device_id *matches,

>  					const struct of_dev_auxdata *lookup,

> -- 

> 2.30.1.766.gb4fecdf3b7-goog

>
Matthias Kaehlcke March 9, 2021, 5:20 p.m. UTC | #2
On Mon, Mar 08, 2021 at 03:32:51PM -0700, Rob Herring wrote:
> On Fri, Mar 05, 2021 at 11:38:51AM -0800, Matthias Kaehlcke wrote:
> > Code for platform_device_create() and of_platform_device_create() is
> 
> You mean of_platform_device_create and of_platform_device_destroy?
> 
> Does of_platform_populate not work in your usecase?

of_platform_populate() would create a platform device for every node
under the USB controller or hub. While this could be restricted with
the 'matches' parameter it would still create two platform devices for
a hub controller that provides separate USB 2 and USB 3 hubs.

When of_platform_device_create() is used the onboard hub driver can
help to decide for which node the platform device should be created.

> > only generated if CONFIG_OF_ADDRESS=y. Add stubs to avoid unresolved
> > symbols when CONFIG_OF_ADDRESS is not set.
> > 
> > Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> > ---
> > 
> > Changes in v6:
> > - patch added to the series
> > 
> >  include/linux/of_platform.h | 22 ++++++++++++++++++----
> >  1 file changed, 18 insertions(+), 4 deletions(-)
> > 
> > diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
> > index 84a966623e78..d15b6cd5e1c3 100644
> > --- a/include/linux/of_platform.h
> > +++ b/include/linux/of_platform.h
> > @@ -61,16 +61,18 @@ static inline struct platform_device *of_find_device_by_node(struct device_node
> >  }
> >  #endif
> >  
> > +extern int of_platform_bus_probe(struct device_node *root,
> > +				 const struct of_device_id *matches,
> > +				 struct device *parent);
> > +
> > +#ifdef CONFIG_OF_ADDRESS
> >  /* Platform devices and busses creation */
> >  extern struct platform_device *of_platform_device_create(struct device_node *np,
> >  						   const char *bus_id,
> >  						   struct device *parent);
> >  
> >  extern int of_platform_device_destroy(struct device *dev, void *data);
> > -extern int of_platform_bus_probe(struct device_node *root,
> > -				 const struct of_device_id *matches,
> > -				 struct device *parent);
> > -#ifdef CONFIG_OF_ADDRESS
> > +
> >  extern int of_platform_populate(struct device_node *root,
> >  				const struct of_device_id *matches,
> >  				const struct of_dev_auxdata *lookup,
> > @@ -84,6 +86,18 @@ extern int devm_of_platform_populate(struct device *dev);
> >  
> >  extern void devm_of_platform_depopulate(struct device *dev);
> >  #else
> > +/* Platform devices and busses creation */
> > +static inline struct platform_device *of_platform_device_create(struct device_node *np,
> > +								const char *bus_id,
> > +								struct device *parent)
> > +{
> > +	return NULL;
> > +}
> > +static inline int of_platform_device_destroy(struct device *dev, void *data)
> > +{
> > +	return -ENODEV;
> > +}
> > +
> >  static inline int of_platform_populate(struct device_node *root,
> >  					const struct of_device_id *matches,
> >  					const struct of_dev_auxdata *lookup,
> > -- 
> > 2.30.1.766.gb4fecdf3b7-goog
> >
diff mbox series

Patch

diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index 84a966623e78..d15b6cd5e1c3 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -61,16 +61,18 @@  static inline struct platform_device *of_find_device_by_node(struct device_node
 }
 #endif
 
+extern int of_platform_bus_probe(struct device_node *root,
+				 const struct of_device_id *matches,
+				 struct device *parent);
+
+#ifdef CONFIG_OF_ADDRESS
 /* Platform devices and busses creation */
 extern struct platform_device *of_platform_device_create(struct device_node *np,
 						   const char *bus_id,
 						   struct device *parent);
 
 extern int of_platform_device_destroy(struct device *dev, void *data);
-extern int of_platform_bus_probe(struct device_node *root,
-				 const struct of_device_id *matches,
-				 struct device *parent);
-#ifdef CONFIG_OF_ADDRESS
+
 extern int of_platform_populate(struct device_node *root,
 				const struct of_device_id *matches,
 				const struct of_dev_auxdata *lookup,
@@ -84,6 +86,18 @@  extern int devm_of_platform_populate(struct device *dev);
 
 extern void devm_of_platform_depopulate(struct device *dev);
 #else
+/* Platform devices and busses creation */
+static inline struct platform_device *of_platform_device_create(struct device_node *np,
+								const char *bus_id,
+								struct device *parent)
+{
+	return NULL;
+}
+static inline int of_platform_device_destroy(struct device *dev, void *data)
+{
+	return -ENODEV;
+}
+
 static inline int of_platform_populate(struct device_node *root,
 					const struct of_device_id *matches,
 					const struct of_dev_auxdata *lookup,