devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of_mtd: Add no-op stubs to support CONFIG_OF=n
@ 2013-09-03  2:37 Ezequiel Garcia
  2013-09-03  5:36 ` Brian Norris
  0 siblings, 1 reply; 3+ messages in thread
From: Ezequiel Garcia @ 2013-09-03  2:37 UTC (permalink / raw)
  To: linux-mtd, devicetree
  Cc: Josh Wu, Brian Norris, David Woodhouse, Ezequiel Garcia,
	Artem Bityutskiy

Just like the rest of the subsystems, let's add the required no-op
functions to implement stubs when CONFIG_OF=n.

This prevents MTD drivers from having ugly ifdefs in their code,
and instead hide the ifdef monster in the header closet (far away
from people's sight).

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 include/linux/of_mtd.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/linux/of_mtd.h b/include/linux/of_mtd.h
index ed7f267..66f173e 100644
--- a/include/linux/of_mtd.h
+++ b/include/linux/of_mtd.h
@@ -14,6 +14,21 @@
 int of_get_nand_ecc_mode(struct device_node *np);
 int of_get_nand_bus_width(struct device_node *np);
 bool of_get_nand_on_flash_bbt(struct device_node *np);
+#else
+static inline int of_get_nand_ecc_mode(struct device_node *np)
+{
+	return -ENOSYS;
+}
+
+static inline int of_get_nand_bus_width(struct device_node *np)
+{
+	return -ENOSYS;
+}
+
+static inline bool of_get_nand_on_flash_bbt(struct device_node *np)
+{
+	return false;
+}
 #endif
 
 #endif /* __LINUX_OF_MTD_H */
-- 
1.8.1.5


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] of_mtd: Add no-op stubs to support CONFIG_OF=n
  2013-09-03  2:37 [PATCH] of_mtd: Add no-op stubs to support CONFIG_OF=n Ezequiel Garcia
@ 2013-09-03  5:36 ` Brian Norris
  2013-09-03 10:53   ` Ezequiel Garcia
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Norris @ 2013-09-03  5:36 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: devicetree, Josh Wu, linux-mtd, David Woodhouse, Artem Bityutskiy

On Mon, Sep 02, 2013 at 11:37:53PM -0300, Ezequiel Garcia wrote:
> Just like the rest of the subsystems, let's add the required no-op
> functions to implement stubs when CONFIG_OF=n.
> 
> This prevents MTD drivers from having ugly ifdefs in their code,
> and instead hide the ifdef monster in the header closet (far away
> from people's sight).
> 
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>  include/linux/of_mtd.h | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/include/linux/of_mtd.h b/include/linux/of_mtd.h
> index ed7f267..66f173e 100644
> --- a/include/linux/of_mtd.h
> +++ b/include/linux/of_mtd.h
> @@ -14,6 +14,21 @@
>  int of_get_nand_ecc_mode(struct device_node *np);
>  int of_get_nand_bus_width(struct device_node *np);
>  bool of_get_nand_on_flash_bbt(struct device_node *np);
> +#else

I would include an extra line on either side of #else.

> +static inline int of_get_nand_ecc_mode(struct device_node *np)
> +{
> +	return -ENOSYS;
> +}
> +
> +static inline int of_get_nand_bus_width(struct device_node *np)
> +{
> +	return -ENOSYS;
> +}
> +
> +static inline bool of_get_nand_on_flash_bbt(struct device_node *np)
> +{
> +	return false;
> +}
>  #endif

Although we are "hiding" the #ifdef's here in the header, we can still
help to make them extra clear; I think the typical style is to include
/* CONFIG_OF_MTD */ markers to show which #ifdef/#else/#endif block it
belongs to.

>  
>  #endif /* __LINUX_OF_MTD_H */

With this trivial changes, I amended your patch and pushed to
l2-mtd.git. Thanks! I look forward to the following patches to remove
some of the driver #ifdef's.

Thanks,
Brian

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] of_mtd: Add no-op stubs to support CONFIG_OF=n
  2013-09-03  5:36 ` Brian Norris
@ 2013-09-03 10:53   ` Ezequiel Garcia
  0 siblings, 0 replies; 3+ messages in thread
From: Ezequiel Garcia @ 2013-09-03 10:53 UTC (permalink / raw)
  To: Brian Norris
  Cc: devicetree, Josh Wu, linux-mtd, David Woodhouse, Artem Bityutskiy

On Mon, Sep 02, 2013 at 10:36:58PM -0700, Brian Norris wrote:
> On Mon, Sep 02, 2013 at 11:37:53PM -0300, Ezequiel Garcia wrote:
> > Just like the rest of the subsystems, let's add the required no-op
> > functions to implement stubs when CONFIG_OF=n.
> > 
> > This prevents MTD drivers from having ugly ifdefs in their code,
> > and instead hide the ifdef monster in the header closet (far away
> > from people's sight).
> > 
> > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > ---
> >  include/linux/of_mtd.h | 15 +++++++++++++++
> >  1 file changed, 15 insertions(+)
> > 
> > diff --git a/include/linux/of_mtd.h b/include/linux/of_mtd.h
> > index ed7f267..66f173e 100644
> > --- a/include/linux/of_mtd.h
> > +++ b/include/linux/of_mtd.h
> > @@ -14,6 +14,21 @@
> >  int of_get_nand_ecc_mode(struct device_node *np);
> >  int of_get_nand_bus_width(struct device_node *np);
> >  bool of_get_nand_on_flash_bbt(struct device_node *np);
> > +#else
> 
> I would include an extra line on either side of #else.
> 
> > +static inline int of_get_nand_ecc_mode(struct device_node *np)
> > +{
> > +	return -ENOSYS;
> > +}
> > +
> > +static inline int of_get_nand_bus_width(struct device_node *np)
> > +{
> > +	return -ENOSYS;
> > +}
> > +
> > +static inline bool of_get_nand_on_flash_bbt(struct device_node *np)
> > +{
> > +	return false;
> > +}
> >  #endif
> 
> Although we are "hiding" the #ifdef's here in the header, we can still
> help to make them extra clear; I think the typical style is to include
> /* CONFIG_OF_MTD */ markers to show which #ifdef/#else/#endif block it
> belongs to.
> 

Right, forgot about those markers!

> >  
> >  #endif /* __LINUX_OF_MTD_H */
> 
> With this trivial changes, I amended your patch and pushed to
> l2-mtd.git. Thanks! I look forward to the following patches to remove
> some of the driver #ifdef's.
> 

Great, thanks for fixing it!
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2013-09-03 10:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-03  2:37 [PATCH] of_mtd: Add no-op stubs to support CONFIG_OF=n Ezequiel Garcia
2013-09-03  5:36 ` Brian Norris
2013-09-03 10:53   ` Ezequiel Garcia

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