Skip to contentSkip to conversation

mtd: rawnand: Improve compile-test coverage

PATCH Superseded Boris Brezillon 5 participants 38 messages Jul 9, 2018 – Jul 18, 2018 1 message not in the archive

Subsystems (7)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover mtd: rawnand: Improve compile-test coverage

Hello,

This is an attempt at adding "depends || COMPILE_TEST" to all NAND drivers that have no compile-time dependencies on arch features/headers.

This will hopefully help us (NAND/MTD maintainers) in detecting build issues earlier. Unfortunately we still have a few drivers that can't easily be modified to be arch independent.

I tried to put all patches that only touch the NAND subsystem first, so that they can be applied even if other patches are being discussed.

Don't hesitate to point any missing dependencies when compiled with COMPILE_TEST. I didn't have any problem when compiling, but that might be because the dependencies were already selected.

In this v2, I tried to fix all warnings/errors reported by kbuild/0day robots. The only remaining ones are those in omap_elm.c which seems to do some weird cpu_to_be32() conversions. I guess I could replace those by iowrite32be() calls (or just add (__force __u32)), but I don't want to risk a regression on this driver, so I'm just leaving it for someone else to fix :P.

Regards,

Boris

Changes in v2:
- Fix a few problems reported by kbuild robots and Stephen Rothwell

Boris Brezillon (24):
mtd: rawnand: atmel: Use uintptr_t casts instead of unsigned int
mtd: rawnand: atmel: Add an __iomem cast on gen_pool_dma_alloc() call
mtd: rawnand: atmel: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: s3c2410: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: orion: Avoid direct inclusion of asm headers
mtd: rawnand: orion: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: davinci: Stop doing iomem pointer <-> u32 conversions
mtd: rawnand: davinci: Use uintptr_t casts instead of unsigned ones
mtd: rawnand: davinci: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: sunxi: Add an U suffix to NFC_PAGE_OP definition
mtd: rawnand: sunxi: Make sure ret is initialized in
sunxi_nfc_read_byte()
mtd: rawnand: sunxi: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: fscm: Avoid collision on PC def when compiling for MIPS
mtd: rawnand: fsmc: Use uintptr_t casts instead of unsigned ones
mtd: rawnand: fsmc: Allow selection of this driver when COMPILE_TEST=y
memory: fsl_ifc: Allow selection of this driver when COMPILE_TEST=y
mtd: rawnand: fsl_ifc: Add an __iomem specifier on eccstat_regs
mtd: rawnand: fsl_ifc: Allow selection of this driver when
COMPILE_TEST=y
MIPS: txx9: Move the ndfc.h header to include/linux/platform_data/txx9
mtd: rawnand: txx9ndfmc: Allow selection of this driver when
COMPILE_TEST=y
MIPS: jz4740: Move jz4740_nand.h header to
include/linux/platform_data/jz4740
mtd: rawnand: jz4740: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: jz4780: Drop the dependency on MACH_JZ4780
memory: jz4780-nemc: Allow selection of this driver when
COMPILE_TEST=y

 arch/mips/jz4740/board-qi_lb60.c                   |  3 +-
 arch/mips/txx9/generic/setup.c                     |  2 +-
 arch/mips/txx9/generic/setup_tx4938.c              |  2 +-
 arch/mips/txx9/generic/setup_tx4939.c              |  2 +-
 drivers/memory/Kconfig                             |  6 ++--
 drivers/mtd/nand/raw/Kconfig                       | 33 ++++++++++++++--------
 drivers/mtd/nand/raw/atmel/nand-controller.c       |  8 +++---
 drivers/mtd/nand/raw/davinci_nand.c                | 33 ++++++++++------------
 drivers/mtd/nand/raw/fsl_ifc_nand.c                |  2 +-
 drivers/mtd/nand/raw/fsmc_nand.c                   | 33 +++++++++++-----------
 drivers/mtd/nand/raw/jz4740_nand.c                 |  2 +-
 drivers/mtd/nand/raw/orion_nand.c                  |  2 +-
 drivers/mtd/nand/raw/sunxi_nand.c                  |  4 +--
 drivers/mtd/nand/raw/txx9ndfmc.c                   |  2 +-
 .../linux/platform_data/jz4740}/jz4740_nand.h      |  4 +--
 .../linux/platform_data}/txx9/ndfmc.h              |  6 ++--
 16 files changed, 77 insertions(+), 67 deletions(-)
 rename {arch/mips/include/asm/mach-jz4740 => include/linux/platform_data/jz4740}/jz4740_nand.h (91%)
 rename {arch/mips/include/asm => include/linux/platform_data}/txx9/ndfmc.h (91%)
Signature · 1 line
2.14.1
#1 lore raw

PATCH v2 1/24 mtd: rawnand: atmel: Use uintptr_t casts instead of unsigned int

When casting a pointer to an unsigned in, uintptr_t should be used to cope with the pointer size differences between 32-bit and 64-bit architectures.

This is needed if we want to allow compilation of this driver when COMPILE_TEST=y.

---
 drivers/mtd/nand/raw/atmel/nand-controller.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +1 -1
index e686fe73159e..e8f7549d0354 100644
@@ -2050,7 +2050,7 @@ atmel_smc_nand_controller_init(struct atmel_smc_nand_controller *nc)
 		return ret;
 	}
 
-	nc->ebi_csa_offs = (unsigned int)match->data;
+	nc->ebi_csa_offs = (uintptr_t)match->data;
 
 	/*
 	 * The at91sam9263 has 2 EBIs, if the NAND controller is under EBI1
Signature · 1 line
2.14.1
#2 lore raw

PATCH v2 2/24 mtd: rawnand: atmel: Add an __iomem cast on gen_pool_dma_alloc() call

In reply to Boris Brezillon

gen_pool_dma_alloc() return type is void *, while internally, the memory region exposed by the sram driver has been mapped with ioremap().

Add a void * to void __iomem * cast to make sparse happy.

---
 drivers/mtd/nand/raw/atmel/nand-controller.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +3 -3
index e8f7549d0354..30dae4c9d439 100644
@@ -2219,9 +2219,9 @@ atmel_hsmc_nand_controller_init(struct atmel_hsmc_nand_controller *nc)
 		return -ENOMEM;
 	}
 
-	nc->sram.virt = gen_pool_dma_alloc(nc->sram.pool,
-					    ATMEL_NFC_SRAM_SIZE,
-					    &nc->sram.dma);
+	nc->sram.virt = (void __iomem *)gen_pool_dma_alloc(nc->sram.pool,
+							   ATMEL_NFC_SRAM_SIZE,
+							   &nc->sram.dma);
 	if (!nc->sram.virt) {
 		dev_err(nc->base.dev,
 			"Could not allocate memory from the NFC SRAM pool\n");
Signature · 1 line
2.14.1
#3 lore raw

PATCH v2 3/24 mtd: rawnand: atmel: Allow selection of this driver when COMPILE_TEST=y

In reply to Boris Brezillon

It just makes NAND maintainers' life easier by allowing them to compile-test this driver without having ARCH_AT91 enabled.

We also need to add a dependency on HAS_IOMEM to make sure the driver compiles correctly.

---
 drivers/mtd/nand/raw/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/Kconfig +2 -1
index 230311fa2cc0..1488ad0a0199 100644
@@ -277,7 +277,8 @@ config MTD_NAND_CS553X
 
 config MTD_NAND_ATMEL
 	tristate "Support for NAND Flash / SmartMedia on AT91"
-	depends on ARCH_AT91
+	depends on ARCH_AT91 || COMPILE_TEST
+	depends on HAS_IOMEM
 	select MFD_ATMEL_SMC
 	help
 	  Enables support for NAND Flash / Smart Media Card interface
Signature · 1 line
2.14.1
#4 lore raw

PATCH v2 4/24 mtd: rawnand: s3c2410: Allow selection of this driver when COMPILE_TEST=y

In reply to Boris Brezillon

It just makes NAND maintainers' life easier by allowing them to compile-test this driver without having ARCH_S3C24XX or ARCH_S3C64XX enabled.

We add a dependency on HAS_IOMEM to make sure the driver compiles correctly, and a dependency on !IA64 because the {read,write}s{bwl}() accessors are not defined for this architecture.

---
 drivers/mtd/nand/raw/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/Kconfig +2 -1
index 1488ad0a0199..e01b3da726c0 100644
@@ -119,7 +119,8 @@ config MTD_NAND_AU1550
 
 config MTD_NAND_S3C2410
 	tristate "NAND Flash support for Samsung S3C SoCs"
-	depends on ARCH_S3C24XX || ARCH_S3C64XX
+	depends on ARCH_S3C24XX || ARCH_S3C64XX || COMPILE_TEST
+	depends on HAS_IOMEM && !IA64
 	help
 	  This enables the NAND flash controller on the S3C24xx and S3C64xx
 	  SoCs
Signature · 1 line
2.14.1
#5 lore raw

Re: [PATCH v2 04/24] mtd: rawnand: s3c2410: Allow selection of this driver when COMPILE_TEST=y

Quoted 7 lines · On Mon, 9 Jul 2018 22:09:25 +0200 Boris Brezillon…

It just makes NAND maintainers' life easier by allowing them to compile-test this driver without having ARCH_S3C24XX or ARCH_S3C64XX enabled.

We add a dependency on HAS_IOMEM to make sure the driver compiles correctly, and a dependency on !IA64 because the {read,write}s{bwl}() accessors are not defined for this architecture.

I see that SPARC does not define those accessors either. So I guess we should add depends on !SPARC.

Arnd, any other way to know when the platform implements {read,write}s{bwl}() accessors?

Quoted 20 lines
---
 drivers/mtd/nand/raw/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/Kconfig +2 -1
index 1488ad0a0199..e01b3da726c0 100644
@@ -119,7 +119,8 @@ config MTD_NAND_AU1550
 
 config MTD_NAND_S3C2410
 	tristate "NAND Flash support for Samsung S3C SoCs"
-	depends on ARCH_S3C24XX || ARCH_S3C64XX
+	depends on ARCH_S3C24XX || ARCH_S3C64XX || COMPILE_TEST
+	depends on HAS_IOMEM && !IA64
 	help
 	  This enables the NAND flash controller on the S3C24xx and S3C64xx
 	  SoCs
#6 lore raw

Re: [PATCH v2 04/24] mtd: rawnand: s3c2410: Allow selection of this driver when COMPILE_TEST=y

Quoted 11 lines · Boris Brezillon
Quoted 7 lines · On Mon, 9 Jul 2018 22:09:25 +0200 Boris Brezillon…

It just makes NAND maintainers' life easier by allowing them to compile-test this driver without having ARCH_S3C24XX or ARCH_S3C64XX enabled.

We add a dependency on HAS_IOMEM to make sure the driver compiles correctly, and a dependency on !IA64 because the {read,write}s{bwl}() accessors are not defined for this architecture.

Quoted 5 lines

I see that SPARC does not define those accessors either. So I guess we should add depends on !SPARC.

Arnd, any other way to know when the platform implements {read,write}s{bwl}() accessors?

I'd just consider that a bug, and send a patch to fix sparc64 if it's broken. sparc32 appears to have these, and when Thierry sent the patch
to implement them everywhere[1], he said that he tested sparc64 as well, so either something regressed since then, or his testing was incomplete. Either way, the correct answer IMHO would be to make it work rather than to add infrastructure around the broken configurations.

Arnd

[1] https://lwn.net/Articles/604819/

#7 lore raw

Re: [PATCH v2 04/24] mtd: rawnand: s3c2410: Allow selection of this driver when COMPILE_TEST=y

Quoted 19 lines · On Wed, 11 Jul 2018 13:27:53 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 11 lines · Boris Brezillon
Quoted 7 lines · On Mon, 9 Jul 2018 22:09:25 +0200 Boris Brezillon…

It just makes NAND maintainers' life easier by allowing them to compile-test this driver without having ARCH_S3C24XX or ARCH_S3C64XX enabled.

We add a dependency on HAS_IOMEM to make sure the driver compiles correctly, and a dependency on !IA64 because the {read,write}s{bwl}() accessors are not defined for this architecture.

Quoted 5 lines

I see that SPARC does not define those accessors either. So I guess we should add depends on !SPARC.

Arnd, any other way to know when the platform implements {read,write}s{bwl}() accessors?

Quoted 7 lines

I'd just consider that a bug, and send a patch to fix sparc64 if it's broken. sparc32 appears to have these, and when Thierry sent the patch
to implement them everywhere[1], he said that he tested sparc64 as well, so either something regressed since then, or his testing was incomplete. Either way, the correct answer IMHO would be to make it work rather than to add infrastructure around the broken configurations.

I guess the same goes for IA64 then.

#8 lore raw

Re: [PATCH v2 04/24] mtd: rawnand: s3c2410: Allow selection of this driver when COMPILE_TEST=y

Quoted 30 lines · Boris Brezillon
Quoted 19 lines · On Wed, 11 Jul 2018 13:27:53 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 11 lines · Boris Brezillon
Quoted 7 lines · On Mon, 9 Jul 2018 22:09:25 +0200 Boris Brezillon…

It just makes NAND maintainers' life easier by allowing them to compile-test this driver without having ARCH_S3C24XX or ARCH_S3C64XX enabled.

We add a dependency on HAS_IOMEM to make sure the driver compiles correctly, and a dependency on !IA64 because the {read,write}s{bwl}() accessors are not defined for this architecture.

Quoted 5 lines

I see that SPARC does not define those accessors either. So I guess we should add depends on !SPARC.

Arnd, any other way to know when the platform implements {read,write}s{bwl}() accessors?

Quoted 7 lines

I'd just consider that a bug, and send a patch to fix sparc64 if it's broken. sparc32 appears to have these, and when Thierry sent the patch
to implement them everywhere[1], he said that he tested sparc64 as well, so either something regressed since then, or his testing was incomplete. Either way, the correct answer IMHO would be to make it work rather than to add infrastructure around the broken configurations.

Quoted 1 line

I guess the same goes for IA64 then.

Right. FWIW, I just tried it out and sent the respective arch patches.

Arnd

#9 lore raw

Re: [PATCH v2 04/24] mtd: rawnand: s3c2410: Allow selection of this driver when COMPILE_TEST=y

Quoted 32 lines · On Wed, 11 Jul 2018 14:09:19 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 30 lines · Boris Brezillon
Quoted 26 lines · On Wed, 11 Jul 2018 13:27:53 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 11 lines · Boris Brezillon
Quoted 7 lines · On Mon, 9 Jul 2018 22:09:25 +0200 Boris Brezillon…

It just makes NAND maintainers' life easier by allowing them to compile-test this driver without having ARCH_S3C24XX or ARCH_S3C64XX enabled.

We add a dependency on HAS_IOMEM to make sure the driver compiles correctly, and a dependency on !IA64 because the {read,write}s{bwl}() accessors are not defined for this architecture.

Quoted 5 lines

I see that SPARC does not define those accessors either. So I guess we should add depends on !SPARC.

Arnd, any other way to know when the platform implements {read,write}s{bwl}() accessors?

I'd just consider that a bug, and send a patch to fix sparc64 if it's broken. sparc32 appears to have these, and when Thierry sent the patch
to implement them everywhere[1], he said that he tested sparc64 as well, so either something regressed since then, or his testing was incomplete. Either way, the correct answer IMHO would be to make it work rather than to add infrastructure around the broken configurations.

Quoted 3 lines
Quoted 1 line

I guess the same goes for IA64 then.

Right. FWIW, I just tried it out and sent the respective arch patches.

Cool! Thanks for doing that.

#10 lore raw

PATCH v2 5/24 mtd: rawnand: orion: Avoid direct inclusion of asm headers

In reply to Boris Brezillon

Include linux/sizes.h instead of asm/sizes.h to make code completely arch independent.

---
 drivers/mtd/nand/raw/orion_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/orion_nand.c +1 -1
index 1a4828442675..27cc902545f3 100644
@@ -18,7 +18,7 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/io.h>
-#include <asm/sizes.h>
+#include <linux/sizes.h>
 #include <linux/platform_data/mtd-orion_nand.h>
 
 struct orion_nand_info {
Signature · 1 line
2.14.1
#11 lore raw

PATCH v2 6/24 mtd: rawnand: orion: Allow selection of this driver when COMPILE_TEST=y

In reply to Boris Brezillon

It just makes NAND maintainers' life easier by allowing them to compile-test this driver without having PLAT_ORION enabled.

We add a dependency on HAS_IOMEM to make sure the driver compiles correctly, and a dependency on !IA64 because the {read,write}s{bwl}() accessors are not defined for this architecture.

---
 drivers/mtd/nand/raw/Kconfig | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/Kconfig +3 -2
index e01b3da726c0..efc5dcd5135c 100644
@@ -289,7 +289,7 @@ config MTD_NAND_MARVELL
 	tristate "NAND controller support on Marvell boards"
 	depends on PXA3xx || ARCH_MMP || PLAT_ORION || ARCH_MVEBU || \
 		   COMPILE_TEST
-	depends on HAS_IOMEM
+	depends on HAS_IOMEM && !IA64
 	help
 	  This enables the NAND flash controller driver for Marvell boards,
 	  including:
@@ -381,7 +381,8 @@ config MTD_NAND_PLATFORM
 
 config MTD_NAND_ORION
 	tristate "NAND Flash support for Marvell Orion SoC"
-	depends on PLAT_ORION
+	depends on PLAT_ORION || COMPILE_TEST
+	depends on HAS_IOMEM
 	help
 	  This enables the NAND flash controller on Orion machines.
 
Signature · 1 line
2.14.1
#12 lore raw

PATCH v2 7/24 mtd: rawnand: davinci: Stop doing iomem pointer <-> u32 conversions

In reply to Boris Brezillon

There is no point in doing this sort of conversion since pointers can we can replace |= by += operations which are perfectly valid on pointers.

This is done in preparation of COMPILE_TEST addition to the NAND_DAVINCI Kconfig entry, since building for x86 generates a several warnings because of inappropriate u32 <-> void * conversions (pointers are 64bits large on x86_64).

---
 drivers/mtd/nand/raw/davinci_nand.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)
drivers/mtd/nand/raw/davinci_nand.c +10 -13
index cd12e5abafde..9cd36a750965 100644
@@ -60,8 +60,7 @@ struct davinci_nand_info {
 	void __iomem		*base;
 	void __iomem		*vaddr;
 
-	uint32_t		ioaddr;
-	uint32_t		current_cs;
+	void __iomem		*current_cs;
 
 	uint32_t		mask_chipsel;
 	uint32_t		mask_ale;
@@ -102,17 +101,17 @@ static void nand_davinci_hwcontrol(struct mtd_info *mtd, int cmd,
 				   unsigned int ctrl)
 {
 	struct davinci_nand_info	*info = to_davinci_nand(mtd);
-	uint32_t			addr = info->current_cs;
+	void __iomem			*addr = info->current_cs;
 	struct nand_chip		*nand = mtd_to_nand(mtd);
 
 	/* Did the control lines change? */
 	if (ctrl & NAND_CTRL_CHANGE) {
 		if ((ctrl & NAND_CTRL_CLE) == NAND_CTRL_CLE)
-			addr |= info->mask_cle;
+			addr += info->mask_cle;
 		else if ((ctrl & NAND_CTRL_ALE) == NAND_CTRL_ALE)
-			addr |= info->mask_ale;
+			addr += info->mask_ale;
 
-		nand->IO_ADDR_W = (void __iomem __force *)addr;
+		nand->IO_ADDR_W = addr;
 	}
 
 	if (cmd != NAND_CMD_NONE)
@@ -122,14 +121,14 @@ static void nand_davinci_hwcontrol(struct mtd_info *mtd, int cmd,
 static void nand_davinci_select_chip(struct mtd_info *mtd, int chip)
 {
 	struct davinci_nand_info	*info = to_davinci_nand(mtd);
-	uint32_t			addr = info->ioaddr;
+
+	info->current_cs = info->vaddr;
 
 	/* maybe kick in a second chipselect */
 	if (chip > 0)
-		addr |= info->mask_chipsel;
-	info->current_cs = addr;
+		info->current_cs += info->mask_chipsel;
 
-	info->chip.IO_ADDR_W = (void __iomem __force *)addr;
+	info->chip.IO_ADDR_W = info->current_cs;
 	info->chip.IO_ADDR_R = info->chip.IO_ADDR_W;
 }
 
@@ -680,9 +679,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
 	info->chip.bbt_md	= pdata->bbt_md;
 	info->timing		= pdata->timing;
 
-	info->ioaddr		= (uint32_t __force) vaddr;
-
-	info->current_cs	= info->ioaddr;
+	info->current_cs	= info->vaddr;
 	info->core_chipsel	= pdata->core_chipsel;
 	info->mask_chipsel	= pdata->mask_chipsel;
 
Signature · 1 line
2.14.1
#13 lore raw

PATCH v2 8/24 mtd: rawnand: davinci: Use uintptr_t casts instead of unsigned ones

In reply to Boris Brezillon

uintptr_t should be used when casting a pointer to an unsigned int so that the code compiles without warnings even on 64-bit architectures.

This is needed if we want to allow selection of this driver when COMPILE_TEST=y.

---
 drivers/mtd/nand/raw/davinci_nand.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mtd/nand/raw/davinci_nand.c +5 -5
index 9cd36a750965..e79ed0f60ade 100644
@@ -318,7 +318,7 @@ static int nand_davinci_correct_4bit(struct mtd_info *mtd,
 	/* Unpack ten bytes into eight 10 bit values.  We know we're
 	 * little-endian, and use type punning for less shifting/masking.
 	 */
-	if (WARN_ON(0x01 & (unsigned) ecc_code))
+	if (WARN_ON(0x01 & (uintptr_t)ecc_code))
 		return -EINVAL;
 	ecc16 = (unsigned short *)ecc_code;
 
@@ -440,9 +440,9 @@ static void nand_davinci_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
 {
 	struct nand_chip *chip = mtd_to_nand(mtd);
 
-	if ((0x03 & ((unsigned)buf)) == 0 && (0x03 & len) == 0)
+	if ((0x03 & ((uintptr_t)buf)) == 0 && (0x03 & len) == 0)
 		ioread32_rep(chip->IO_ADDR_R, buf, len >> 2);
-	else if ((0x01 & ((unsigned)buf)) == 0 && (0x01 & len) == 0)
+	else if ((0x01 & ((uintptr_t)buf)) == 0 && (0x01 & len) == 0)
 		ioread16_rep(chip->IO_ADDR_R, buf, len >> 1);
 	else
 		ioread8_rep(chip->IO_ADDR_R, buf, len);
@@ -453,9 +453,9 @@ static void nand_davinci_write_buf(struct mtd_info *mtd,
 {
 	struct nand_chip *chip = mtd_to_nand(mtd);
 
-	if ((0x03 & ((unsigned)buf)) == 0 && (0x03 & len) == 0)
+	if ((0x03 & ((uintptr_t)buf)) == 0 && (0x03 & len) == 0)
 		iowrite32_rep(chip->IO_ADDR_R, buf, len >> 2);
-	else if ((0x01 & ((unsigned)buf)) == 0 && (0x01 & len) == 0)
+	else if ((0x01 & ((uintptr_t)buf)) == 0 && (0x01 & len) == 0)
 		iowrite16_rep(chip->IO_ADDR_R, buf, len >> 1);
 	else
 		iowrite8_rep(chip->IO_ADDR_R, buf, len);
Signature · 1 line
2.14.1
#14 lore raw

PATCH v2 9/24 mtd: rawnand: davinci: Allow selection of this driver when COMPILE_TEST=y

In reply to Boris Brezillon

It just makes NAND maintainers' life easier by allowing them to compile-test this driver without having ARCH_DAVINCI or ARCH_KEYSTONE enabled.

We also need to add a dependency on HAS_IOMEM to make sure the driver compiles correctly.

---
 drivers/mtd/nand/raw/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/Kconfig +2 -1
index efc5dcd5135c..539b0619f53a 100644
@@ -462,7 +462,8 @@ config MTD_NAND_SH_FLCTL
 
 config MTD_NAND_DAVINCI
         tristate "Support NAND on DaVinci/Keystone SoC"
-        depends on ARCH_DAVINCI || (ARCH_KEYSTONE && TI_AEMIF)
+	depends on ARCH_DAVINCI || (ARCH_KEYSTONE && TI_AEMIF) || COMPILE_TEST
+	depends on HAS_IOMEM
         help
 	  Enable the driver for NAND flash chips on Texas Instruments
 	  DaVinci/Keystone processors.
Signature · 1 line
2.14.1
#15 lore raw

PATCH v2 10/24 mtd: rawnand: sunxi: Add an U suffix to NFC_PAGE_OP definition

In reply to Boris Brezillon

Fixes the "warning: large integer implicitly truncated to unsigned type [-Woverflow]" warning when compiled for x86.

This is needed in order to allow compiling this driver when COMPILE_TEST=y.

---
 drivers/mtd/nand/raw/sunxi_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/sunxi_nand.c +1 -1
index d831a141a196..99043c3a4fa7 100644
@@ -127,7 +127,7 @@
 #define NFC_CMD_TYPE_MSK	GENMASK(31, 30)
 #define NFC_NORMAL_OP		(0 << 30)
 #define NFC_ECC_OP		(1 << 30)
-#define NFC_PAGE_OP		(2 << 30)
+#define NFC_PAGE_OP		(2U << 30)
 
 /* define bit use in NFC_RCMD_SET */
 #define NFC_READ_CMD_MSK	GENMASK(7, 0)
Signature · 1 line
2.14.1
#16 lore raw

PATCH v2 11/24 mtd: rawnand: sunxi: Make sure ret is initialized in sunxi_nfc_read_byte()

In reply to Boris Brezillon

Fixes the following smatch warning:

drivers/mtd/nand/raw/sunxi_nand.c:551 sunxi_nfc_read_byte() error: uninitialized symbol 'ret'.

---
 drivers/mtd/nand/raw/sunxi_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/sunxi_nand.c +1 -1
index 99043c3a4fa7..4b11cd4a79be 100644
@@ -544,7 +544,7 @@ static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf,
 
 static uint8_t sunxi_nfc_read_byte(struct mtd_info *mtd)
 {
-	uint8_t ret;
+	uint8_t ret = 0;
 
 	sunxi_nfc_read_buf(mtd, &ret, 1);
 
Signature · 1 line
2.14.1
#17 lore raw

Re: [PATCH v2 11/24] mtd: rawnand: sunxi: Make sure ret is initialized in sunxi_nfc_read_byte()

Quoted 14 lines · Boris Brezillon

Fixes the following smatch warning:

drivers/mtd/nand/raw/sunxi_nand.c:551 sunxi_nfc_read_byte() error: uninitialized symbol 'ret'.

---
 drivers/mtd/nand/raw/sunxi_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/sunxi_nand.c +0 -0
index 99043c3a4fa7..4b11cd4a79be 100644

drivers/mtd/nand/raw/sunxi_nand.c static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, · line 550

Quoted 8 lines
drivers/mtd/nand/raw/sunxi_nand.c +1 -1
@@ -544,7 +544,7 @@ static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf,
 
 static uint8_t sunxi_nfc_read_byte(struct mtd_info *mtd)
 {
-       uint8_t ret;
+       uint8_t ret = 0;
 
        sunxi_nfc_read_buf(mtd, &ret, 1);
 

Should there perhaps be a warning when no data was returned after a timeout?

Arnd

#18 lore raw

Re: [PATCH v2 11/24] mtd: rawnand: sunxi: Make sure ret is initialized in sunxi_nfc_read_byte()

Quoted 22 lines · On Mon, 9 Jul 2018 22:35:56 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 20 lines · Boris Brezillon

Fixes the following smatch warning:

drivers/mtd/nand/raw/sunxi_nand.c:551 sunxi_nfc_read_byte() error: uninitialized symbol 'ret'.

---
 drivers/mtd/nand/raw/sunxi_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/sunxi_nand.c +1 -1
index 99043c3a4fa7..4b11cd4a79be 100644
@@ -544,7 +544,7 @@ static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf,
 
 static uint8_t sunxi_nfc_read_byte(struct mtd_info *mtd)
 {
-       uint8_t ret;
+       uint8_t ret = 0;
 
Quoted 4 lines

drivers/mtd/nand/raw/sunxi_nand.c static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, · line 550

Quoted 2 lines
drivers/mtd/nand/raw/sunxi_nand.c +0 -0
        sunxi_nfc_read_buf(mtd, &ret, 1);
 

Should there perhaps be a warning when no data was returned after a timeout?

We're planning to move this driver to ->exec_op() soon, and with ->exec_op() errors are properly propagated to the core. I guess we can live with this lack of dev_warn() for a bit longer :-).

#19 lore raw

PATCH v2 12/24 mtd: rawnand: sunxi: Allow selection of this driver when COMPILE_TEST=y

In reply to Boris Brezillon

It just makes NAND maintainers' life easier by allowing them to compile-test this driver without having ARCH_SUNXI enabled.

We also need to add a dependency on HAS_IOMEM to make sure the driver compiles correctly.

---
 drivers/mtd/nand/raw/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/Kconfig +2 -1
index 539b0619f53a..ee836f7d7b8b 100644
@@ -518,7 +518,8 @@ config MTD_NAND_XWAY
 
 config MTD_NAND_SUNXI
 	tristate "Support for NAND on Allwinner SoCs"
-	depends on ARCH_SUNXI
+	depends on ARCH_SUNXI || COMPILE_TEST
+	depends on HAS_IOMEM
 	help
 	  Enables support for NAND Flash chips on Allwinner SoCs.
 
Signature · 1 line
2.14.1
#20 lore raw

PATCH v2 13/24 mtd: rawnand: fscm: Avoid collision on PC def when compiling for MIPS

In reply to Boris Brezillon

We want to allow this driver to be selected when COMPILE_TEST=y, this means the driver can be compiled for any arch, including MIPS. When compiling this driver for MIPS, we end up with a collision on the 'PC' macro definition (also defined in arch/mips/include/asm/ptrace.h).

Prefix the fsmc one with FSMC_ to avoid this problem.

---
 drivers/mtd/nand/raw/fsmc_nand.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)
drivers/mtd/nand/raw/fsmc_nand.c +15 -14
index f4a5a317d4ae..d71c49f50e77 100644
@@ -62,7 +62,7 @@
 						reg)
 
 /* fsmc controller registers for NAND flash */
-#define PC			0x00
+#define FSMC_PC			0x00
 	/* pc register definitions */
 	#define FSMC_RESET		(1 << 0)
 	#define FSMC_WAITON		(1 << 1)
@@ -273,12 +273,13 @@ static void fsmc_nand_setup(struct fsmc_nand_data *host,
 	tset = (tims->tset & FSMC_TSET_MASK) << FSMC_TSET_SHIFT;
 
 	if (host->nand.options & NAND_BUSWIDTH_16)
-		writel_relaxed(value | FSMC_DEVWID_16, host->regs_va + PC);
+		writel_relaxed(value | FSMC_DEVWID_16,
+			       host->regs_va + FSMC_PC);
 	else
-		writel_relaxed(value | FSMC_DEVWID_8, host->regs_va + PC);
+		writel_relaxed(value | FSMC_DEVWID_8, host->regs_va + FSMC_PC);
 
-	writel_relaxed(readl(host->regs_va + PC) | tclr | tar,
-		       host->regs_va + PC);
+	writel_relaxed(readl(host->regs_va + FSMC_PC) | tclr | tar,
+		       host->regs_va + FSMC_PC);
 	writel_relaxed(thiz | thold | twait | tset, host->regs_va + COMM);
 	writel_relaxed(thiz | thold | twait | tset, host->regs_va + ATTRIB);
 }
@@ -371,12 +372,12 @@ static void fsmc_enable_hwecc(struct mtd_info *mtd, int mode)
 {
 	struct fsmc_nand_data *host = mtd_to_fsmc(mtd);
 
-	writel_relaxed(readl(host->regs_va + PC) & ~FSMC_ECCPLEN_256,
-		       host->regs_va + PC);
-	writel_relaxed(readl(host->regs_va + PC) & ~FSMC_ECCEN,
-		       host->regs_va + PC);
-	writel_relaxed(readl(host->regs_va + PC) | FSMC_ECCEN,
-		       host->regs_va + PC);
+	writel_relaxed(readl(host->regs_va + FSMC_PC) & ~FSMC_ECCPLEN_256,
+		       host->regs_va + FSMC_PC);
+	writel_relaxed(readl(host->regs_va + FSMC_PC) & ~FSMC_ECCEN,
+		       host->regs_va + FSMC_PC);
+	writel_relaxed(readl(host->regs_va + FSMC_PC) | FSMC_ECCEN,
+		       host->regs_va + FSMC_PC);
 }
 
 /*
@@ -618,11 +619,11 @@ static void fsmc_select_chip(struct mtd_info *mtd, int chipnr)
 	if (chipnr > 0)
 		return;
 
-	pc = readl(host->regs_va + PC);
+	pc = readl(host->regs_va + FSMC_PC);
 	if (chipnr < 0)
-		writel_relaxed(pc & ~FSMC_ENABLE, host->regs_va + PC);
+		writel_relaxed(pc & ~FSMC_ENABLE, host->regs_va + FSMC_PC);
 	else
-		writel_relaxed(pc | FSMC_ENABLE, host->regs_va + PC);
+		writel_relaxed(pc | FSMC_ENABLE, host->regs_va + FSMC_PC);
 
 	/* nCE line must be asserted before starting any operation */
 	mb();
Signature · 1 line
2.14.1
#21 lore raw

PATCH v2 14/24 mtd: rawnand: fsmc: Use uintptr_t casts instead of unsigned ones

In reply to Boris Brezillon

uintptr_t should be used when casting a pointer to an unsigned int so that the code compiles without warnings even on 64-bit architectures.

This is needed if we want to allow selection of this driver when COMPILE_TEST=y.

---
 drivers/mtd/nand/raw/fsmc_nand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/fsmc_nand.c +2 -2
index d71c49f50e77..527bebc7e6c9 100644
@@ -547,7 +547,7 @@ static void fsmc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
 	struct fsmc_nand_data *host  = mtd_to_fsmc(mtd);
 	int i;
 
-	if (IS_ALIGNED((uint32_t)buf, sizeof(uint32_t)) &&
+	if (IS_ALIGNED((uintptr_t)buf, sizeof(uint32_t)) &&
 			IS_ALIGNED(len, sizeof(uint32_t))) {
 		uint32_t *p = (uint32_t *)buf;
 		len = len >> 2;
@@ -570,7 +570,7 @@ static void fsmc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
 	struct fsmc_nand_data *host  = mtd_to_fsmc(mtd);
 	int i;
 
-	if (IS_ALIGNED((uint32_t)buf, sizeof(uint32_t)) &&
+	if (IS_ALIGNED((uintptr_t)buf, sizeof(uint32_t)) &&
 			IS_ALIGNED(len, sizeof(uint32_t))) {
 		uint32_t *p = (uint32_t *)buf;
 		len = len >> 2;
Signature · 1 line
2.14.1
#22 lore raw

PATCH v2 15/24 mtd: rawnand: fsmc: Allow selection of this driver when COMPILE_TEST=y

In reply to Boris Brezillon

It just makes NAND maintainers' life easier by allowing them to compile-test this driver without having PLAT_SPEAR, ARCH_NOMADIK, ARCH_U8500 or MACH_U300 enabled.

We also need to add a dependency on HAS_IOMEM to make sure the driver compiles correctly.

---
 drivers/mtd/nand/raw/Kconfig | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/Kconfig +3 -2
index ee836f7d7b8b..29d360f984c9 100644
@@ -503,8 +503,9 @@ config MTD_NAND_JZ4780
 
 config MTD_NAND_FSMC
 	tristate "Support for NAND on ST Micros FSMC"
-	depends on OF
-	depends on PLAT_SPEAR || ARCH_NOMADIK || ARCH_U8500 || MACH_U300
+	depends on OF && HAS_IOMEM
+	depends on PLAT_SPEAR || ARCH_NOMADIK || ARCH_U8500 || MACH_U300 || \
+		   COMPILE_TEST
 	help
 	  Enables support for NAND Flash chips on the ST Microelectronics
 	  Flexible Static Memory Controller (FSMC)
Signature · 1 line
2.14.1
#23 lore raw

PATCH v2 16/24 memory: fsl_ifc: Allow selection of this driver when COMPILE_TEST=y

In reply to Boris Brezillon

It just makes maintainers' life easier by allowing them to compile-test this driver without having FSL_SOC, ARCH_LAYERSCAPE or SOC_LS1021A enabled.

We also need to add a dependency on HAS_IOMEM to make sure the driver compiles correctly.

---
 drivers/memory/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/memory/Kconfig +2 -1
index 8d731d6c3e54..78457ab2cbc4 100644
@@ -116,7 +116,8 @@ config FSL_CORENET_CF
 
 config FSL_IFC
 	bool
-	depends on FSL_SOC || ARCH_LAYERSCAPE || SOC_LS1021A
+	depends on FSL_SOC || ARCH_LAYERSCAPE || SOC_LS1021A || COMPILE_TEST
+	depends on HAS_IOMEM
 
 config JZ4780_NEMC
 	bool "Ingenic JZ4780 SoC NEMC driver"
Signature · 1 line
2.14.1
#24 lore raw

PATCH v2 17/24 mtd: rawnand: fsl_ifc: Add an __iomem specifier on eccstat_regs

In reply to Boris Brezillon

The local eccstat_regs variable in fsl_ifc_run_command() is missing an __iomem specifier, and sparce complains about that.

---
 drivers/mtd/nand/raw/fsl_ifc_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/fsl_ifc_nand.c +1 -1
index 382b67e97174..75d3c951f61a 100644
@@ -225,7 +225,7 @@ static void fsl_ifc_run_command(struct mtd_info *mtd)
 		int bufnum = nctrl->page & priv->bufnum_mask;
 		int sector_start = bufnum * chip->ecc.steps;
 		int sector_end = sector_start + chip->ecc.steps - 1;
-		__be32 *eccstat_regs;
+		__be32 __iomem *eccstat_regs;
 
 		eccstat_regs = ifc->ifc_nand.nand_eccstat;
 		eccstat = ifc_in32(&eccstat_regs[sector_start / 4]);
Signature · 1 line
2.14.1
#25 lore raw

PATCH v2 18/24 mtd: rawnand: fsl_ifc: Allow selection of this driver when COMPILE_TEST=y

In reply to Boris Brezillon

It just makes maintainers' life easier by allowing them to compile-test this driver without having FSL_SOC, ARCH_LAYERSCAPE or SOC_LS1021A enabled.

We also need to add a dependency on HAS_IOMEM to make sure the driver compiles correctly.

---
 drivers/mtd/nand/raw/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/Kconfig +2 -1
index 29d360f984c9..dc6c5aff4172 100644
@@ -408,7 +408,8 @@ config MTD_NAND_FSL_ELBC
 
 config MTD_NAND_FSL_IFC
 	tristate "NAND support for Freescale IFC controller"
-	depends on FSL_SOC || ARCH_LAYERSCAPE || SOC_LS1021A
+	depends on FSL_SOC || ARCH_LAYERSCAPE || SOC_LS1021A || COMPILE_TEST
+	depends on HAS_IOMEM
 	select FSL_IFC
 	select MEMORY
 	help
Signature · 1 line
2.14.1
#26 lore raw

PATCH v2 19/24 MIPS: txx9: Move the ndfc.h header to include/linux/platform_data/txx9

In reply to Boris Brezillon

This way we will be able to compile the ndfmc driver when COMPILE_TEST=y.

---
 arch/mips/txx9/generic/setup.c                                      | 2 +-
 arch/mips/txx9/generic/setup_tx4938.c                               | 2 +-
 arch/mips/txx9/generic/setup_tx4939.c                               | 2 +-
 drivers/mtd/nand/raw/txx9ndfmc.c                                    | 2 +-
 {arch/mips/include/asm => include/linux/platform_data}/txx9/ndfmc.h | 6 +++---
 5 files changed, 7 insertions(+), 7 deletions(-)
 rename {arch/mips/include/asm => include/linux/platform_data}/txx9/ndfmc.h (91%)
arch/mips/txx9/generic/setup.c +1 -1
index 1791a44ee570..aa47932abd28 100644
@@ -20,6 +20,7 @@
 #include <linux/err.h>
 #include <linux/gpio/driver.h>
 #include <linux/platform_device.h>
+#include <linux/platform_data/txx9/ndfmc.h>
 #include <linux/serial_core.h>
 #include <linux/mtd/physmap.h>
 #include <linux/leds.h>
@@ -35,7 +36,6 @@
 #include <asm/txx9/generic.h>
 #include <asm/txx9/pci.h>
 #include <asm/txx9tmr.h>
-#include <asm/txx9/ndfmc.h>
 #include <asm/txx9/dmac.h>
 #ifdef CONFIG_CPU_TX49XX
 #include <asm/txx9/tx4938.h>
arch/mips/txx9/generic/setup_tx4938.c +1 -1
index 85d1795652da..17395d5d15ca 100644
@@ -17,13 +17,13 @@
 #include <linux/ptrace.h>
 #include <linux/mtd/physmap.h>
 #include <linux/platform_device.h>
+#include <linux/platform_data/txx9/ndfmc.h>
 #include <asm/reboot.h>
 #include <asm/traps.h>
 #include <asm/txx9irq.h>
 #include <asm/txx9tmr.h>
 #include <asm/txx9pio.h>
 #include <asm/txx9/generic.h>
-#include <asm/txx9/ndfmc.h>
 #include <asm/txx9/dmac.h>
 #include <asm/txx9/tx4938.h>
 
arch/mips/txx9/generic/setup_tx4939.c +1 -1
index 274928987a21..360c388f4c82 100644
@@ -21,13 +21,13 @@
 #include <linux/ptrace.h>
 #include <linux/mtd/physmap.h>
 #include <linux/platform_device.h>
+#include <linux/platform_data/txx9/ndfmc.h>
 #include <asm/bootinfo.h>
 #include <asm/reboot.h>
 #include <asm/traps.h>
 #include <asm/txx9irq.h>
 #include <asm/txx9tmr.h>
 #include <asm/txx9/generic.h>
-#include <asm/txx9/ndfmc.h>
 #include <asm/txx9/dmac.h>
 #include <asm/txx9/tx4939.h>
 
drivers/mtd/nand/raw/txx9ndfmc.c +1 -1
index b567d212fe7d..04d57474ef97 100644
@@ -20,7 +20,7 @@
 #include <linux/mtd/nand_ecc.h>
 #include <linux/mtd/partitions.h>
 #include <linux/io.h>
-#include <asm/txx9/ndfmc.h>
+#include <linux/platform_data/txx9/ndfmc.h>
 
 /* TXX9 NDFMC Registers */
 #define TXX9_NDFDTR	0x00
include/linux/platform_data/txx9/ndfmc.h renamed from arch/mips/include/asm/txx9/ndfmc.h +3 -3
similarity index 91%
rename from arch/mips/include/asm/txx9/ndfmc.h
rename to include/linux/platform_data/txx9/ndfmc.h
index fa67f3df78fc..fc172627d54e 100644
@@ -5,8 +5,8 @@
  *
  * (C) Copyright TOSHIBA CORPORATION 2007
  */
-#ifndef __ASM_TXX9_NDFMC_H
-#define __ASM_TXX9_NDFMC_H
+#ifndef __TXX9_NDFMC_H
+#define __TXX9_NDFMC_H
 
 #define NDFMC_PLAT_FLAG_USE_BSPRT	0x01
 #define NDFMC_PLAT_FLAG_NO_RSTR		0x02
@@ -27,4 +27,4 @@ struct txx9ndfmc_platform_data {
 void txx9_ndfmc_init(unsigned long baseaddr,
 		     const struct txx9ndfmc_platform_data *plat_data);
 
-#endif /* __ASM_TXX9_NDFMC_H */
+#endif /* __TXX9_NDFMC_H */
Signature · 1 line
2.14.1
#27 lore raw

PATCH v2 20/24 mtd: rawnand: txx9ndfmc: Allow selection of this driver when COMPILE_TEST=y

In reply to Boris Brezillon

It just makes NAND maintainers' life easier by allowing them to compile-test this driver without having SOC_TX4938 or SOC_TX4939 enabled.

We also need to add a dependency on HAS_IOMEM to make sure the driver compiles correctly.

---
 drivers/mtd/nand/raw/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/Kconfig +2 -1
index dc6c5aff4172..f4bbc90ee250 100644
@@ -471,7 +471,8 @@ config MTD_NAND_DAVINCI
 
 config MTD_NAND_TXX9NDFMC
 	tristate "NAND Flash support for TXx9 SoC"
-	depends on SOC_TX4938 || SOC_TX4939
+	depends on SOC_TX4938 || SOC_TX4939 || COMPILE_TEST
+	depends on HAS_IOMEM
 	help
 	  This enables the NAND flash controller on the TXx9 SoCs.
 
Signature · 1 line
2.14.1
#28 lore raw

PATCH v2 21/24 MIPS: jz4740: Move jz4740_nand.h header to include/linux/platform_data/jz4740

In reply to Boris Brezillon

This way we will be able to compile the jz4740_nand driver when COMPILE_TEST=y.

---
 arch/mips/jz4740/board-qi_lb60.c                                      | 3 ++-
 drivers/mtd/nand/raw/jz4740_nand.c                                    | 2 +-
 .../mach-jz4740 => include/linux/platform_data/jz4740}/jz4740_nand.h  | 4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)
 rename {arch/mips/include/asm/mach-jz4740 => include/linux/platform_data/jz4740}/jz4740_nand.h (91%)
arch/mips/jz4740/board-qi_lb60.c +2 -1
index 60f0767507c6..af0c8ace0141 100644
@@ -29,10 +29,11 @@
 #include <linux/power/gpio-charger.h>
 #include <linux/pwm.h>
 
+#include <linux/platform_data/jz4740/jz4740_nand.h>
+
 #include <asm/mach-jz4740/gpio.h>
 #include <asm/mach-jz4740/jz4740_fb.h>
 #include <asm/mach-jz4740/jz4740_mmc.h>
-#include <asm/mach-jz4740/jz4740_nand.h>
 
 #include <linux/regulator/fixed.h>
 #include <linux/regulator/machine.h>
drivers/mtd/nand/raw/jz4740_nand.c +1 -1
index 613b00a9604b..a0254461812d 100644
@@ -25,7 +25,7 @@
 
 #include <linux/gpio.h>
 
-#include <asm/mach-jz4740/jz4740_nand.h>
+#include <linux/platform_data/jz4740/jz4740_nand.h>
 
 #define JZ_REG_NAND_CTRL	0x50
 #define JZ_REG_NAND_ECC_CTRL	0x100
include/linux/platform_data/jz4740/jz4740_nand.h renamed from arch/mips/include/asm/mach-jz4740/jz4740_nand.h +2 -2
similarity index 91%
rename from arch/mips/include/asm/mach-jz4740/jz4740_nand.h
rename to include/linux/platform_data/jz4740/jz4740_nand.h
index f381d465e768..bc571f6d5ced 100644
@@ -13,8 +13,8 @@
  *
  */
 
-#ifndef __ASM_MACH_JZ4740_JZ4740_NAND_H__
-#define __ASM_MACH_JZ4740_JZ4740_NAND_H__
+#ifndef __JZ4740_NAND_H__
+#define __JZ4740_NAND_H__
 
 #include <linux/mtd/rawnand.h>
 #include <linux/mtd/partitions.h>
Signature · 1 line
2.14.1
#29 lore raw

PATCH v2 22/24 mtd: rawnand: jz4740: Allow selection of this driver when COMPILE_TEST=y

In reply to Boris Brezillon

It just makes NAND maintainers' life easier by allowing them to compile-test this driver without having MACH_JZ4740 enabled.

We also need to add a dependency on HAS_IOMEM to make sure the driver compiles correctly.

---
 drivers/mtd/nand/raw/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/Kconfig +2 -1
index f4bbc90ee250..7b5e97719c25 100644
@@ -492,7 +492,8 @@ config MTD_NAND_NUC900
 
 config MTD_NAND_JZ4740
 	tristate "Support for JZ4740 SoC NAND controller"
-	depends on MACH_JZ4740
+	depends on MACH_JZ4740 || COMPILE_TEST
+	depends on HAS_IOMEM
 	help
 		Enables support for NAND Flash on JZ4740 SoC based boards.
 
Signature · 1 line
2.14.1
#30 lore raw

PATCH v2 23/24 mtd: rawnand: jz4780: Drop the dependency on MACH_JZ4780

In reply to Boris Brezillon

This MACH_JZ4780 dependency is taken care of by JZ4780_NEMC, no need to repeat it here.

---
 drivers/mtd/nand/raw/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/Kconfig +1 -1
index 7b5e97719c25..d9cd9608bc2d 100644
@@ -499,7 +499,7 @@ config MTD_NAND_JZ4740
 
 config MTD_NAND_JZ4780
 	tristate "Support for NAND on JZ4780 SoC"
-	depends on MACH_JZ4780 && JZ4780_NEMC
+	depends on JZ4780_NEMC
 	help
 	  Enables support for NAND Flash connected to the NEMC on JZ4780 SoC
 	  based boards, using the BCH controller for hardware error correction.
Signature · 1 line
2.14.1

A message that is not in the archive (sent off-list or not yet received): CANc+2y5vjUpM_ikegaoKTtqehSmBY3y_r+1E6y93AoivRQqmfg@mail.gmail.com

#32 lore raw

Re: [PATCH v2 23/24] mtd: rawnand: jz4780: Drop the dependency on MACH_JZ4780

Hi PrasannaKumar,

Quoted 19 lines · On Tue, 10 Jul 2018 22:16:50 +0530 PrasannaKumar Muralidharan…

Hi Boris,

Quoted 14 lines · Boris Brezillon

This MACH_JZ4780 dependency is taken care of by JZ4780_NEMC, no need to repeat it here.

---
 drivers/mtd/nand/raw/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/Kconfig +0 -0
index 7b5e97719c25..d9cd9608bc2d 100644
@@ -499,7 +499,7 @@ config MTD_NAND_JZ4740
 
Quoted 15 lines
Quoted 6 lines
drivers/mtd/nand/raw/Kconfig +1 -1
 config MTD_NAND_JZ4780
        tristate "Support for NAND on JZ4780 SoC"
-       depends on MACH_JZ4780 && JZ4780_NEMC
+       depends on JZ4780_NEMC
        help
          Enables support for NAND Flash connected to the NEMC on JZ4780
Quoted 8 lines

SoC
based boards, using the BCH controller for hardware error
correction.
--
2.14.1

JZ4780 has MLC NAND.

Hm, the NAND controller supports both MLC and SLC NANDs. Maybe there are only boards with MLC NANDs, but that doesn't mean we should remove the driver for the controller.

Quoted 2 lines

As MLC NAND is not supported in mainline do you think
this patch is required? Even wondering if the driver is required at all.

The fact that MLC NANDs are not supported by UBI is not necessarily definitive. I have a branch with all the work we've done to add MLC support to UBI [1]. If you have time to invest in it, feel free to take over this work.

Anyway, the decision to remove this driver is not mine, and this patch allows me to at least compile-test this driver.

Regards,

Boris

[1]https://github.com/bbrezillon/linux/commits/nand/mlc

#33 lore raw

Re: [PATCH v2 23/24] mtd: rawnand: jz4780: Drop the dependency on MACH_JZ4780

Quoted 40 lines · Boris Brezillon

Hi PrasannaKumar,

Quoted 19 lines · On Tue, 10 Jul 2018 22:16:50 +0530 PrasannaKumar Muralidharan…

Hi Boris,

Quoted 14 lines · Boris Brezillon

This MACH_JZ4780 dependency is taken care of by JZ4780_NEMC, no need to repeat it here.

---
 drivers/mtd/nand/raw/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/Kconfig +0 -0
index 7b5e97719c25..d9cd9608bc2d 100644
@@ -499,7 +499,7 @@ config MTD_NAND_JZ4740
 
Quoted 15 lines
Quoted 6 lines
drivers/mtd/nand/raw/Kconfig +1 -1
 config MTD_NAND_JZ4780
        tristate "Support for NAND on JZ4780 SoC"
-       depends on MACH_JZ4780 && JZ4780_NEMC
+       depends on JZ4780_NEMC
        help
          Enables support for NAND Flash connected to the NEMC on JZ4780
Quoted 8 lines

SoC
based boards, using the BCH controller for hardware error
correction.
--
2.14.1

JZ4780 has MLC NAND.

Quoted 3 lines

Hm, the NAND controller supports both MLC and SLC NANDs. Maybe there are only boards with MLC NANDs, but that doesn't mean we should remove the driver for the controller.

Creator CI20 board which uses JZ4780 SoC is supported by upstream as of now. It has MLC NAND.

But I agree that removing the driver is too extreme.

Quoted 7 lines
Quoted 2 lines

As MLC NAND is not supported in mainline do you think
this patch is required? Even wondering if the driver is required at all.

The fact that MLC NANDs are not supported by UBI is not necessarily definitive. I have a branch with all the work we've done to add MLC support to UBI [1]. If you have time to invest in it, feel free to take over this work.

I am afraid I don't have time as well as knowledge to work on it yet.

Quoted 8 lines

Anyway, the decision to remove this driver is not mine, and this patch allows me to at least compile-test this driver.

Regards,

Boris

[1]https://github.com/bbrezillon/linux/commits/nand/mlc

Thanks,
PrasannaKumar

#34 lore raw

PATCH v2 24/24 memory: jz4780-nemc: Allow selection of this driver when COMPILE_TEST=y

In reply to Boris Brezillon

It just makes maintainers' life easier by allowing them to compile-test this driver without having MACH_JZ4780 enabled.

We also need to add a dependency on HAS_IOMEM to make sure the driver compiles correctly.

---
 drivers/memory/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/memory/Kconfig +2 -1
index 78457ab2cbc4..a642552dfdc9 100644
@@ -122,7 +122,8 @@ config FSL_IFC
 config JZ4780_NEMC
 	bool "Ingenic JZ4780 SoC NEMC driver"
 	default y
-	depends on MACH_JZ4780
+	depends on MACH_JZ4780 || COMPILE_TEST
+	depends on HAS_IOMEM
 	help
 	  This driver is for the NAND/External Memory Controller (NEMC) in
 	  the Ingenic JZ4780. This controller is used to handle external
Signature · 1 line
2.14.1
#35 lore raw
In reply to Boris Brezillon
Quoted 10 lines · Boris Brezillon

Hello,

This is an attempt at adding "depends || COMPILE_TEST" to all NAND drivers that have no compile-time dependencies on arch features/headers.

This will hopefully help us (NAND/MTD maintainers) in detecting build issues earlier. Unfortunately we still have a few drivers that can't easily be modified to be arch independent.

Quoted 6 lines

I tried to put all patches that only touch the NAND subsystem first, so that they can be applied even if other patches are being discussed.

Don't hesitate to point any missing dependencies when compiled with COMPILE_TEST. I didn't have any problem when compiling, but that might be because the dependencies were already selected.

Looks good to me overall.

Quoted 6 lines

In this v2, I tried to fix all warnings/errors reported by kbuild/0day robots. The only remaining ones are those in omap_elm.c which seems to do some weird cpu_to_be32() conversions. I guess I could replace those by iowrite32be() calls (or just add (__force __u32)), but I don't want to risk a regression on this driver, so I'm just leaving it for someone else to fix :P.

Agreed, this is definedly very odd code. It looks like the intention is to write all the bits in reverse order, but four bytes at a time. I'm fairly sure the current implementation cannot work on big-endian, in particularly this line:

val = cpu_to_be32(*(u32 *) &ecc[0]) >> 12;

Since shifting a number after the byteswap is not well-defined. It's probably correct on little-endian, but it's not clear what the best way would be to write this is an endian-neutral way.

Arnd

Acked-by on the v2 series
#36 lore raw
In reply to Boris Brezillon

Hi Boris,

Quoted 11 lines · Boris Brezillon

MIPS: txx9: Move the ndfc.h header to include/linux/platform_data/txx9
mtd: rawnand: txx9ndfmc: Allow selection of this driver when
COMPILE_TEST=y
MIPS: jz4740: Move jz4740_nand.h header to
include/linux/platform_data/jz4740
mtd: rawnand: jz4740: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: jz4780: Drop the dependency on MACH_JZ4780
memory: jz4780-nemc: Allow selection of this driver when
COMPILE_TEST=y

Quoted 12 lines
 arch/mips/jz4740/board-qi_lb60.c                   |  3 +-
 arch/mips/txx9/generic/setup.c                     |  2 +-
 arch/mips/txx9/generic/setup_tx4938.c              |  2 +-
 arch/mips/txx9/generic/setup_tx4939.c              |  2 +-
 drivers/memory/Kconfig                             |  6 ++--
 drivers/mtd/nand/raw/Kconfig                       | 33 ++++++++++++++--------
 drivers/mtd/nand/raw/jz4740_nand.c                 |  2 +-
 drivers/mtd/nand/raw/txx9ndfmc.c                   |  2 +-
 .../linux/platform_data/jz4740}/jz4740_nand.h      |  4 +--
 .../linux/platform_data}/txx9/ndfmc.h              |  6 ++--
 rename {arch/mips/include/asm/mach-jz4740 => include/linux/platform_data/jz4740}/jz4740_nand.h (91%)
 rename {arch/mips/include/asm => include/linux/platform_data}/txx9/ndfmc.h (91%)

For the MIPS-related patches 19-24:

Thanks,
Paul

maintainer
#37 lore raw
In reply to Boris Brezillon

Hi Boris,

Boris Brezillon <[email protected]> wrote on Mon, 9 Jul 2018 22:09:21 +0200:

Quoted 79 lines

Hello,

This is an attempt at adding "depends || COMPILE_TEST" to all NAND drivers that have no compile-time dependencies on arch features/headers.

This will hopefully help us (NAND/MTD maintainers) in detecting build issues earlier. Unfortunately we still have a few drivers that can't easily be modified to be arch independent.

I tried to put all patches that only touch the NAND subsystem first, so that they can be applied even if other patches are being discussed.

Don't hesitate to point any missing dependencies when compiled with COMPILE_TEST. I didn't have any problem when compiling, but that might be because the dependencies were already selected.

In this v2, I tried to fix all warnings/errors reported by kbuild/0day robots. The only remaining ones are those in omap_elm.c which seems to do some weird cpu_to_be32() conversions. I guess I could replace those by iowrite32be() calls (or just add (__force __u32)), but I don't want to risk a regression on this driver, so I'm just leaving it for someone else to fix :P.

Regards,

Boris

Changes in v2:
- Fix a few problems reported by kbuild robots and Stephen Rothwell

Boris Brezillon (24):
mtd: rawnand: atmel: Use uintptr_t casts instead of unsigned int
mtd: rawnand: atmel: Add an __iomem cast on gen_pool_dma_alloc() call
mtd: rawnand: atmel: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: s3c2410: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: orion: Avoid direct inclusion of asm headers
mtd: rawnand: orion: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: davinci: Stop doing iomem pointer <-> u32 conversions
mtd: rawnand: davinci: Use uintptr_t casts instead of unsigned ones
mtd: rawnand: davinci: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: sunxi: Add an U suffix to NFC_PAGE_OP definition
mtd: rawnand: sunxi: Make sure ret is initialized in
sunxi_nfc_read_byte()
mtd: rawnand: sunxi: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: fscm: Avoid collision on PC def when compiling for MIPS
mtd: rawnand: fsmc: Use uintptr_t casts instead of unsigned ones
mtd: rawnand: fsmc: Allow selection of this driver when COMPILE_TEST=y
memory: fsl_ifc: Allow selection of this driver when COMPILE_TEST=y
mtd: rawnand: fsl_ifc: Add an __iomem specifier on eccstat_regs
mtd: rawnand: fsl_ifc: Allow selection of this driver when
COMPILE_TEST=y
MIPS: txx9: Move the ndfc.h header to include/linux/platform_data/txx9
mtd: rawnand: txx9ndfmc: Allow selection of this driver when
COMPILE_TEST=y
MIPS: jz4740: Move jz4740_nand.h header to
include/linux/platform_data/jz4740
mtd: rawnand: jz4740: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: jz4780: Drop the dependency on MACH_JZ4780
memory: jz4780-nemc: Allow selection of this driver when
COMPILE_TEST=y

 arch/mips/jz4740/board-qi_lb60.c                   |  3 +-
 arch/mips/txx9/generic/setup.c                     |  2 +-
 arch/mips/txx9/generic/setup_tx4938.c              |  2 +-
 arch/mips/txx9/generic/setup_tx4939.c              |  2 +-
 drivers/memory/Kconfig                             |  6 ++--
 drivers/mtd/nand/raw/Kconfig                       | 33 ++++++++++++++--------
 drivers/mtd/nand/raw/atmel/nand-controller.c       |  8 +++---
 drivers/mtd/nand/raw/davinci_nand.c                | 33 ++++++++++------------
 drivers/mtd/nand/raw/fsl_ifc_nand.c                |  2 +-
 drivers/mtd/nand/raw/fsmc_nand.c                   | 33 +++++++++++-----------
 drivers/mtd/nand/raw/jz4740_nand.c                 |  2 +-
Quoted 9 lines
 drivers/mtd/nand/raw/orion_nand.c                  |  2 +-
 drivers/mtd/nand/raw/sunxi_nand.c                  |  4 +--
 drivers/mtd/nand/raw/txx9ndfmc.c                   |  2 +-
 .../linux/platform_data/jz4740}/jz4740_nand.h      |  4 +--
 .../linux/platform_data}/txx9/ndfmc.h              |  6 ++--
 16 files changed, 77 insertions(+), 67 deletions(-)
 rename {arch/mips/include/asm/mach-jz4740 => include/linux/platform_data/jz4740}/jz4740_nand.h (91%)
 rename {arch/mips/include/asm => include/linux/platform_data}/txx9/ndfmc.h (91%)

Series applied with some typo fixes in the commit log as well as a proper indentation forced in drivers/mtd/nand/raw/Kconfig.

Thanks,
Miquèl

maintainer
#38 lore raw

Hi Miquel,

Miquel Raynal <[email protected]> wrote on Wed, 18 Jul 2018 09:13:32 +0200:

Quoted 94 lines

Hi Boris,

Boris Brezillon <[email protected]> wrote on Mon, 9 Jul 2018 22:09:21 +0200:

Quoted 79 lines

Hello,

This is an attempt at adding "depends || COMPILE_TEST" to all NAND drivers that have no compile-time dependencies on arch features/headers.

This will hopefully help us (NAND/MTD maintainers) in detecting build issues earlier. Unfortunately we still have a few drivers that can't easily be modified to be arch independent.

I tried to put all patches that only touch the NAND subsystem first, so that they can be applied even if other patches are being discussed.

Don't hesitate to point any missing dependencies when compiled with COMPILE_TEST. I didn't have any problem when compiling, but that might be because the dependencies were already selected.

In this v2, I tried to fix all warnings/errors reported by kbuild/0day robots. The only remaining ones are those in omap_elm.c which seems to do some weird cpu_to_be32() conversions. I guess I could replace those by iowrite32be() calls (or just add (__force __u32)), but I don't want to risk a regression on this driver, so I'm just leaving it for someone else to fix :P.

Regards,

Boris

Changes in v2:
- Fix a few problems reported by kbuild robots and Stephen Rothwell

Boris Brezillon (24):
mtd: rawnand: atmel: Use uintptr_t casts instead of unsigned int
mtd: rawnand: atmel: Add an __iomem cast on gen_pool_dma_alloc() call
mtd: rawnand: atmel: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: s3c2410: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: orion: Avoid direct inclusion of asm headers
mtd: rawnand: orion: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: davinci: Stop doing iomem pointer <-> u32 conversions
mtd: rawnand: davinci: Use uintptr_t casts instead of unsigned ones
mtd: rawnand: davinci: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: sunxi: Add an U suffix to NFC_PAGE_OP definition
mtd: rawnand: sunxi: Make sure ret is initialized in
sunxi_nfc_read_byte()
mtd: rawnand: sunxi: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: fscm: Avoid collision on PC def when compiling for MIPS
mtd: rawnand: fsmc: Use uintptr_t casts instead of unsigned ones
mtd: rawnand: fsmc: Allow selection of this driver when COMPILE_TEST=y
memory: fsl_ifc: Allow selection of this driver when COMPILE_TEST=y
mtd: rawnand: fsl_ifc: Add an __iomem specifier on eccstat_regs
mtd: rawnand: fsl_ifc: Allow selection of this driver when
COMPILE_TEST=y
MIPS: txx9: Move the ndfc.h header to include/linux/platform_data/txx9
mtd: rawnand: txx9ndfmc: Allow selection of this driver when
COMPILE_TEST=y
MIPS: jz4740: Move jz4740_nand.h header to
include/linux/platform_data/jz4740
mtd: rawnand: jz4740: Allow selection of this driver when
COMPILE_TEST=y
mtd: rawnand: jz4780: Drop the dependency on MACH_JZ4780
memory: jz4780-nemc: Allow selection of this driver when
COMPILE_TEST=y

 arch/mips/jz4740/board-qi_lb60.c                   |  3 +-
 arch/mips/txx9/generic/setup.c                     |  2 +-
 arch/mips/txx9/generic/setup_tx4938.c              |  2 +-
 arch/mips/txx9/generic/setup_tx4939.c              |  2 +-
 drivers/memory/Kconfig                             |  6 ++--
 drivers/mtd/nand/raw/Kconfig                       | 33 ++++++++++++++--------
 drivers/mtd/nand/raw/atmel/nand-controller.c       |  8 +++---
 drivers/mtd/nand/raw/davinci_nand.c                | 33 ++++++++++------------
 drivers/mtd/nand/raw/fsl_ifc_nand.c                |  2 +-
 drivers/mtd/nand/raw/fsmc_nand.c                   | 33 +++++++++++-----------
 drivers/mtd/nand/raw/jz4740_nand.c                 |  2 +-
Quoted 9 lines
 drivers/mtd/nand/raw/orion_nand.c                  |  2 +-
 drivers/mtd/nand/raw/sunxi_nand.c                  |  4 +--
 drivers/mtd/nand/raw/txx9ndfmc.c                   |  2 +-
 .../linux/platform_data/jz4740}/jz4740_nand.h      |  4 +--
 .../linux/platform_data}/txx9/ndfmc.h              |  6 ++--
 16 files changed, 77 insertions(+), 67 deletions(-)
 rename {arch/mips/include/asm/mach-jz4740 => include/linux/platform_data/jz4740}/jz4740_nand.h (91%)
 rename {arch/mips/include/asm => include/linux/platform_data}/txx9/ndfmc.h (91%)
Quoted 2 lines

Series applied with some typo fixes in the commit log as well as a proper indentation forced in drivers/mtd/nand/raw/Kconfig.

Forgot to mention: minus orion and s3c patches that will need a v3.

Quoted 3 lines

Thanks,
Miquèl