mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mtd: nand_base: replace ifdef with IS_ENABLE
@ 2015-08-05  6:10 Antony Pavlov
  2015-08-05  7:53 ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Antony Pavlov @ 2015-08-05  6:10 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 drivers/mtd/nand/nand_base.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 2b3f9a9..bf4110a 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -445,15 +445,15 @@ static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip,
 {
 	struct nand_chip *chip = mtd->priv;
 
-#ifdef CONFIG_NAND_BBT
-	if (!chip->bbt)
-		return chip->block_bad(mtd, ofs, getchip);
+	if (IS_ENABLED(CONFIG_NAND_BBT)) {
+		if (!chip->bbt)
+			return chip->block_bad(mtd, ofs, getchip);
+
+		/* Return info from the table */
+		return nand_isbad_bbt(mtd, ofs, allowbbt);
+	}
 
-	/* Return info from the table */
-	return nand_isbad_bbt(mtd, ofs, allowbbt);
-#else
 	return chip->block_bad(mtd, ofs, getchip);
-#endif
 }
 
 /* Wait for the ready pin, after a command. The timeout is caught later. */
-- 
2.5.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] mtd: nand_base: replace ifdef with IS_ENABLE
  2015-08-05  6:10 [PATCH] mtd: nand_base: replace ifdef with IS_ENABLE Antony Pavlov
@ 2015-08-05  7:53 ` Sascha Hauer
  2015-08-05  8:28   ` Antony Pavlov
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2015-08-05  7:53 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Wed, Aug 05, 2015 at 09:10:34AM +0300, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
>  drivers/mtd/nand/nand_base.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] mtd: nand_base: replace ifdef with IS_ENABLE
  2015-08-05  7:53 ` Sascha Hauer
@ 2015-08-05  8:28   ` Antony Pavlov
  2015-08-05  8:39     ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Antony Pavlov @ 2015-08-05  8:28 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Wed, 5 Aug 2015 09:53:56 +0200
Sascha Hauer <s.hauer@pengutronix.de> wrote:

> On Wed, Aug 05, 2015 at 09:10:34AM +0300, Antony Pavlov wrote:
> > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > ---
> >  drivers/mtd/nand/nand_base.c | 14 +++++++-------
> >  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> Applied, thanks

It looks like I have to recall this patch.

+       if (IS_ENABLED(CONFIG_NAND_BBT)) {
+               if (!chip->bbt)
+                       return chip->block_bad(mtd, ofs, getchip);
+
+               /* Return info from the table */
+               return nand_isbad_bbt(mtd, ofs, allowbbt);
+       }

the nand_isbad_bbt() function is defined in drivers/mtd/nand/nand_bbt.c,
but nand_bbt.c is compiled-in only if CONFIG_NAND_BBT is enabled.

My current gcc-4.9.2-based toolchain has no problem with this,
but if CONFIG_NAND_BBT is disabled I suppose rather old toolchain can throw link error here.

I have to add something like this

#ifndef CONFIG_NAND_BBT

static inline nand_isbad_bbt(...) { };

#endif

to include/linux/mtd/nand.h.


-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] mtd: nand_base: replace ifdef with IS_ENABLE
  2015-08-05  8:28   ` Antony Pavlov
@ 2015-08-05  8:39     ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2015-08-05  8:39 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Wed, Aug 05, 2015 at 11:28:44AM +0300, Antony Pavlov wrote:
> On Wed, 5 Aug 2015 09:53:56 +0200
> Sascha Hauer <s.hauer@pengutronix.de> wrote:
> 
> > On Wed, Aug 05, 2015 at 09:10:34AM +0300, Antony Pavlov wrote:
> > > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > > ---
> > >  drivers/mtd/nand/nand_base.c | 14 +++++++-------
> > >  1 file changed, 7 insertions(+), 7 deletions(-)
> > 
> > Applied, thanks
> 
> It looks like I have to recall this patch.
> 
> +       if (IS_ENABLED(CONFIG_NAND_BBT)) {
> +               if (!chip->bbt)
> +                       return chip->block_bad(mtd, ofs, getchip);
> +
> +               /* Return info from the table */
> +               return nand_isbad_bbt(mtd, ofs, allowbbt);
> +       }
> 
> the nand_isbad_bbt() function is defined in drivers/mtd/nand/nand_bbt.c,
> but nand_bbt.c is compiled-in only if CONFIG_NAND_BBT is enabled.
> 
> My current gcc-4.9.2-based toolchain has no problem with this,
> but if CONFIG_NAND_BBT is disabled I suppose rather old toolchain can throw link error here.

If that throws a link error we would have tons of these problems
elsewhere. We currently heavily rely on the fact that gcc throws away
things inside if (0).

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2015-08-05  8:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-05  6:10 [PATCH] mtd: nand_base: replace ifdef with IS_ENABLE Antony Pavlov
2015-08-05  7:53 ` Sascha Hauer
2015-08-05  8:28   ` Antony Pavlov
2015-08-05  8:39     ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox