Skip to contentSkip to conversation

mtd: rawnand: ingenic: fix ingenic_ecc dependency

PATCH In review Arnd Bergmann 3 participants 7 messages Jun 17, 2019 – Jul 1, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: rawnand: ingenic: fix ingenic_ecc dependency

The ecc code is called from the main ingenic_nand module, but the Kconfig symbol gets selected by the dependent ones.

If the child drivers are loadable modules, this leads to a link error:

drivers/mtd/nand/raw/ingenic/ingenic_nand.o: In function `ingenic_nand_remove':
ingenic_nand.c:(.text+0x1a1): undefined reference to ingenic_ecc_release' drivers/mtd/nand/raw/ingenic/ingenic_nand.o: In function ingenic_nand_ecc_correct':
ingenic_nand.c:(.text+0x1fa): undefined reference to ingenic_ecc_correct' drivers/mtd/nand/raw/ingenic/ingenic_nand.o: In function ingenic_nand_ecc_calculate':
ingenic_nand.c:(.text+0x255): undefined reference to ingenic_ecc_calculate' drivers/mtd/nand/raw/ingenic/ingenic_nand.o: In function ingenic_nand_probe':
ingenic_nand.c:(.text+0x3ca): undefined reference to of_ingenic_ecc_get' ingenic_nand.c:(.text+0x685): undefined reference to ingenic_ecc_release'

Rearrange this to have the ecc code linked the same way as the main driver.

Fixes 15de8c6efd0e ("mtd: rawnand: ingenic: Separate top-level and SoC specific code")
---
 drivers/mtd/nand/raw/ingenic/Kconfig  | 2 +-
 drivers/mtd/nand/raw/ingenic/Makefile | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/ingenic/Kconfig +1 -1
index 19a96ce515c1..66b7cffdb0c2 100644
@@ -16,7 +16,7 @@ config MTD_NAND_JZ4780
 if MTD_NAND_JZ4780
 
 config MTD_NAND_INGENIC_ECC
-	tristate
+	bool
 
 config MTD_NAND_JZ4740_ECC
 	tristate "Hardware BCH support for JZ4740 SoC"
drivers/mtd/nand/raw/ingenic/Makefile +4 -1
index 1ac4f455baea..5a55efc5d9bb 100644
@@ -2,7 +2,10 @@
 obj-$(CONFIG_MTD_NAND_JZ4740) += jz4740_nand.o
 obj-$(CONFIG_MTD_NAND_JZ4780) += ingenic_nand.o
 
-obj-$(CONFIG_MTD_NAND_INGENIC_ECC) += ingenic_ecc.o
+ifdef CONFIG_MTD_NAND_INGENIC_ECC
+obj-$(CONFIG_MTD_NAND_JZ4780) += ingenic_ecc.o
+endif
+
 obj-$(CONFIG_MTD_NAND_JZ4740_ECC) += jz4740_ecc.o
 obj-$(CONFIG_MTD_NAND_JZ4725B_BCH) += jz4725b_bch.o
 obj-$(CONFIG_MTD_NAND_JZ4780_BCH) += jz4780_bch.o
Signature · 6 lines
2.20.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
maintainer
#1 lore raw

Hi Arnd,

Quoted 16 lines · Arnd Bergmann

The ecc code is called from the main ingenic_nand module, but the Kconfig symbol gets selected by the dependent ones.

If the child drivers are loadable modules, this leads to a link error:

drivers/mtd/nand/raw/ingenic/ingenic_nand.o: In function `ingenic_nand_remove':
ingenic_nand.c:(.text+0x1a1): undefined reference to ingenic_ecc_release' drivers/mtd/nand/raw/ingenic/ingenic_nand.o: In function ingenic_nand_ecc_correct':
ingenic_nand.c:(.text+0x1fa): undefined reference to ingenic_ecc_correct' drivers/mtd/nand/raw/ingenic/ingenic_nand.o: In function ingenic_nand_ecc_calculate':
ingenic_nand.c:(.text+0x255): undefined reference to ingenic_ecc_calculate' drivers/mtd/nand/raw/ingenic/ingenic_nand.o: In function ingenic_nand_probe':
ingenic_nand.c:(.text+0x3ca): undefined reference to of_ingenic_ecc_get' ingenic_nand.c:(.text+0x685): undefined reference to ingenic_ecc_release'

Quoted 2 lines

Rearrange this to have the ecc code linked the same way as the main driver.

I think there's a better way to fix it, only in Kconfig.

* Add a bool symbol MTD_NAND_INGENIC_USE_HW_ECC
* Have the three ECC/BCH drivers select this symbol instead of MTD_NAND_INGENIC_ECC
* Add the following to the MTD_NAND_JZ4780 config option:
"select MTD_NAND_INGENIC_ECC if MTD_NAND_INGENIC_USE_HW_ECC"

Quoted 39 lines
Fixes 15de8c6efd0e ("mtd: rawnand: ingenic: Separate top-level and SoC specific code")
---
 drivers/mtd/nand/raw/ingenic/Kconfig  | 2 +-
 drivers/mtd/nand/raw/ingenic/Makefile | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/ingenic/Kconfig +1 -1
index 19a96ce515c1..66b7cffdb0c2 100644
@@ -16,7 +16,7 @@ config MTD_NAND_JZ4780
 if MTD_NAND_JZ4780
 
 config MTD_NAND_INGENIC_ECC
-	tristate
+	bool
 
 config MTD_NAND_JZ4740_ECC
 	tristate "Hardware BCH support for JZ4740 SoC"
drivers/mtd/nand/raw/ingenic/Makefile +4 -2
index 1ac4f455baea..5a55efc5d9bb 100644
@@ -2,7 +2,10 @@
 obj-$(CONFIG_MTD_NAND_JZ4740) += jz4740_nand.o
 obj-$(CONFIG_MTD_NAND_JZ4780) += ingenic_nand.o
 
-obj-$(CONFIG_MTD_NAND_INGENIC_ECC) += ingenic_ecc.o
+ifdef CONFIG_MTD_NAND_INGENIC_ECC
+obj-$(CONFIG_MTD_NAND_JZ4780) += ingenic_ecc.o
+endif
+
 obj-$(CONFIG_MTD_NAND_JZ4740_ECC) += jz4740_ecc.o
 obj-$(CONFIG_MTD_NAND_JZ4725B_BCH) += jz4725b_bch.o
 obj-$(CONFIG_MTD_NAND_JZ4780_BCH) += jz4780_bch.o
--

2.20.0

#2 lore raw
Quoted 7 lines · Paul Cercueil

I think there's a better way to fix it, only in Kconfig.

* Add a bool symbol MTD_NAND_INGENIC_USE_HW_ECC
* Have the three ECC/BCH drivers select this symbol instead of MTD_NAND_INGENIC_ECC
* Add the following to the MTD_NAND_JZ4780 config option:
"select MTD_NAND_INGENIC_ECC if MTD_NAND_INGENIC_USE_HW_ECC"

I don't see much difference to my approach here, but if you want to submit that version with 'Reported-by: Arnd Bergmann <[email protected]>', please do so.

Yet another option would be to use Makefile code to link both files into one module, and remove the EXPORT_SYMBOL statements:

obj-$(CONFIG_MTD_NAND_JZ4780) += jz4780_nand.o jz4780_nand-y += ingenic_nand.o jz4780_nand-$(CONFIG_MTD_NAND_INGENIC_ECC) += ingenic_ecc.o

Arnd

maintainer
#3 lore raw

Hello,

Arnd Bergmann <[email protected]> wrote on Mon, 17 Jun 2019 14:12:48 +0200:

Quoted 14 lines · Paul Cercueil
Quoted 8 lines

I think there's a better way to fix it, only in Kconfig.

* Add a bool symbol MTD_NAND_INGENIC_USE_HW_ECC
* Have the three ECC/BCH drivers select this symbol instead of MTD_NAND_INGENIC_ECC
* Add the following to the MTD_NAND_JZ4780 config option:
"select MTD_NAND_INGENIC_ECC if MTD_NAND_INGENIC_USE_HW_ECC"

I don't see much difference to my approach here, but if you want to submit that version with 'Reported-by: Arnd Bergmann <[email protected]>', please do so.

Quoted 7 lines

Yet another option would be to use Makefile code to link both files into one module, and remove the EXPORT_SYMBOL statements:

obj-$(CONFIG_MTD_NAND_JZ4780) += jz4780_nand.o jz4780_nand-y += ingenic_nand.o jz4780_nand-$(CONFIG_MTD_NAND_INGENIC_ECC) += ingenic_ecc.o

I personally have a preference for this one.

Thanks,
Miquèl

maintainer
#4 lore raw

Hi Paul,

Miquel Raynal <[email protected]> wrote on Mon, 17 Jun 2019 14:16:59 +0200:

Quoted 21 lines

Hello,

Arnd Bergmann <[email protected]> wrote on Mon, 17 Jun 2019 14:12:48 +0200:

Quoted 17 lines · Paul Cercueil
Quoted 8 lines

I think there's a better way to fix it, only in Kconfig.

* Add a bool symbol MTD_NAND_INGENIC_USE_HW_ECC
* Have the three ECC/BCH drivers select this symbol instead of MTD_NAND_INGENIC_ECC
* Add the following to the MTD_NAND_JZ4780 config option:
"select MTD_NAND_INGENIC_ECC if MTD_NAND_INGENIC_USE_HW_ECC"

I don't see much difference to my approach here, but if you want to submit that version with 'Reported-by: Arnd Bergmann <[email protected]>', please do so.

Yet another option would be to use Makefile code to link both files into one module, and remove the EXPORT_SYMBOL statements:

Quoted 6 lines
Quoted 4 lines

obj-$(CONFIG_MTD_NAND_JZ4780) += jz4780_nand.o jz4780_nand-y += ingenic_nand.o jz4780_nand-$(CONFIG_MTD_NAND_INGENIC_ECC) += ingenic_ecc.o

I personally have a preference for this one.

Would you mind sending the above change? I forgot about it but I would like to queue it for the next release. Preferably the last version Arnd proposed.

Thanks,
Miquèl

maintainer
#5 lore raw
Quoted 34 lines · Miquel Raynal

Hi Paul,

Miquel Raynal <[email protected]> wrote on Mon, 17 Jun 2019 14:16:59 +0200:

Quoted 29 lines

Hello,

Arnd Bergmann <[email protected]> wrote on Mon, 17 Jun 2019 14:12:48
+0200:

Quoted 1 line

On Mon, Jun 17, 2019 at 1:24 PM Paul Cercueil

Quoted 11 lines · <[email protected]> wrote:
Quoted 8 lines

I think there's a better way to fix it, only in Kconfig.

* Add a bool symbol MTD_NAND_INGENIC_USE_HW_ECC
* Have the three ECC/BCH drivers select this symbol instead of MTD_NAND_INGENIC_ECC
* Add the following to the MTD_NAND_JZ4780 config option:
"select MTD_NAND_INGENIC_ECC if MTD_NAND_INGENIC_USE_HW_ECC"

I don't see much difference to my approach here, but if you want to submit that version with 'Reported-by: Arnd Bergmann

<[email protected]>',

Quoted 9 lines

please do so.

Yet another option would be to use Makefile code to link both files into one module, and remove the EXPORT_SYMBOL statements:

obj-$(CONFIG_MTD_NAND_JZ4780) += jz4780_nand.o jz4780_nand-y += ingenic_nand.o jz4780_nand-$(CONFIG_MTD_NAND_INGENIC_ECC) += ingenic_ecc.o

Quoted 5 lines
Quoted 1 line

I personally have a preference for this one.

Would you mind sending the above change? I forgot about it but I would like to queue it for the next release. Preferably the last version Arnd proposed.

It does change the module name from 'ingenic_nand' to 'jz4780_nand', though. That's not really ideal...

Quoted 3 lines

Thanks,
Miquèl

#6 lore raw
Quoted 7 lines · Paul Cercueil
Quoted 4 lines · Miquel Raynal

Miquel Raynal <[email protected]> wrote on Mon, 17 Jun 2019 14:16:59 +0200:

Quoted 1 line

I personally have a preference for this one.

Quoted 8 lines
Quoted 4 lines

Would you mind sending the above change? I forgot about it but I would like to queue it for the next release. Preferably the last version Arnd
proposed.

It does change the module name from 'ingenic_nand' to 'jz4780_nand', though.
That's not really ideal...

Any other suggestion for the name? If the module keeps getting called ingeneric_nand.ko, then the source file has to get renamed to something else instead.

Arnd