public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] mtd: make mtd_test.c a separate module
@ 2024-05-29  9:50 Arnd Bergmann
  2024-05-29 12:13 ` Miquel Raynal
  2024-07-01 12:00 ` Miquel Raynal
  0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2024-05-29  9:50 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	David Woodhouse, Akinobu Mita, Artem Bityutskiy
  Cc: Arnd Bergmann, linux-mtd, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

This file gets linked into nine different modules, which causes a warning:

scripts/Makefile.build:236: drivers/mtd/tests/Makefile: mtd_test.o is added to multiple modules: mtd_nandbiterrs mtd_oobtest mtd_pagetest mtd_readtest mtd_speedtest mtd_stresstest mtd_subpagetest mtd_torturetest

Make it a separate module instead.

Fixes: a995c792280d ("mtd: tests: rename sources in order to link a helper object")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/mtd/tests/Makefile   | 34 +++++++++++++++++-----------------
 drivers/mtd/tests/mtd_test.c |  9 +++++++++
 2 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/drivers/mtd/tests/Makefile b/drivers/mtd/tests/Makefile
index 5de0378f90db..7dae831ee8b6 100644
--- a/drivers/mtd/tests/Makefile
+++ b/drivers/mtd/tests/Makefile
@@ -1,19 +1,19 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_MTD_TESTS) += mtd_oobtest.o
-obj-$(CONFIG_MTD_TESTS) += mtd_pagetest.o
-obj-$(CONFIG_MTD_TESTS) += mtd_readtest.o
-obj-$(CONFIG_MTD_TESTS) += mtd_speedtest.o
-obj-$(CONFIG_MTD_TESTS) += mtd_stresstest.o
-obj-$(CONFIG_MTD_TESTS) += mtd_subpagetest.o
-obj-$(CONFIG_MTD_TESTS) += mtd_torturetest.o
-obj-$(CONFIG_MTD_TESTS) += mtd_nandecctest.o
-obj-$(CONFIG_MTD_TESTS) += mtd_nandbiterrs.o
+obj-$(CONFIG_MTD_TESTS) += mtd_oobtest.o mtd_test.o
+obj-$(CONFIG_MTD_TESTS) += mtd_pagetest.o mtd_test.o
+obj-$(CONFIG_MTD_TESTS) += mtd_readtest.o mtd_test.o
+obj-$(CONFIG_MTD_TESTS) += mtd_speedtest.o mtd_test.o
+obj-$(CONFIG_MTD_TESTS) += mtd_stresstest.o mtd_test.o
+obj-$(CONFIG_MTD_TESTS) += mtd_subpagetest.o mtd_test.o
+obj-$(CONFIG_MTD_TESTS) += mtd_torturetest.o mtd_test.o
+obj-$(CONFIG_MTD_TESTS) += mtd_nandecctest.o mtd_test.o
+obj-$(CONFIG_MTD_TESTS) += mtd_nandbiterrs.o mtd_test.o
 
-mtd_oobtest-objs := oobtest.o mtd_test.o
-mtd_pagetest-objs := pagetest.o mtd_test.o
-mtd_readtest-objs := readtest.o mtd_test.o
-mtd_speedtest-objs := speedtest.o mtd_test.o
-mtd_stresstest-objs := stresstest.o mtd_test.o
-mtd_subpagetest-objs := subpagetest.o mtd_test.o
-mtd_torturetest-objs := torturetest.o mtd_test.o
-mtd_nandbiterrs-objs := nandbiterrs.o mtd_test.o
+mtd_oobtest-objs := oobtest.o
+mtd_pagetest-objs := pagetest.o
+mtd_readtest-objs := readtest.o
+mtd_speedtest-objs := speedtest.o
+mtd_stresstest-objs := stresstest.o
+mtd_subpagetest-objs := subpagetest.o
+mtd_torturetest-objs := torturetest.o
+mtd_nandbiterrs-objs := nandbiterrs.o
diff --git a/drivers/mtd/tests/mtd_test.c b/drivers/mtd/tests/mtd_test.c
index c84250beffdc..f391e0300cdc 100644
--- a/drivers/mtd/tests/mtd_test.c
+++ b/drivers/mtd/tests/mtd_test.c
@@ -25,6 +25,7 @@ int mtdtest_erase_eraseblock(struct mtd_info *mtd, unsigned int ebnum)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(mtdtest_erase_eraseblock);
 
 static int is_block_bad(struct mtd_info *mtd, unsigned int ebnum)
 {
@@ -57,6 +58,7 @@ int mtdtest_scan_for_bad_eraseblocks(struct mtd_info *mtd, unsigned char *bbt,
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(mtdtest_scan_for_bad_eraseblocks);
 
 int mtdtest_erase_good_eraseblocks(struct mtd_info *mtd, unsigned char *bbt,
 				unsigned int eb, int ebcnt)
@@ -75,6 +77,7 @@ int mtdtest_erase_good_eraseblocks(struct mtd_info *mtd, unsigned char *bbt,
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(mtdtest_erase_good_eraseblocks);
 
 int mtdtest_read(struct mtd_info *mtd, loff_t addr, size_t size, void *buf)
 {
@@ -92,6 +95,7 @@ int mtdtest_read(struct mtd_info *mtd, loff_t addr, size_t size, void *buf)
 
 	return err;
 }
+EXPORT_SYMBOL_GPL(mtdtest_read);
 
 int mtdtest_write(struct mtd_info *mtd, loff_t addr, size_t size,
 		const void *buf)
@@ -107,3 +111,8 @@ int mtdtest_write(struct mtd_info *mtd, loff_t addr, size_t size,
 
 	return err;
 }
+EXPORT_SYMBOL_GPL(mtdtest_write);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("MTD function test helpers");
+MODULE_AUTHOR("Akinobu Mita");
-- 
2.39.2


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

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

* Re: [PATCH] mtd: make mtd_test.c a separate module
  2024-05-29  9:50 [PATCH] mtd: make mtd_test.c a separate module Arnd Bergmann
@ 2024-05-29 12:13 ` Miquel Raynal
  2024-05-29 12:36   ` Arnd Bergmann
  2024-07-01 12:00 ` Miquel Raynal
  1 sibling, 1 reply; 5+ messages in thread
From: Miquel Raynal @ 2024-05-29 12:13 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Richard Weinberger, Vignesh Raghavendra, David Woodhouse,
	Akinobu Mita, Artem Bityutskiy, Arnd Bergmann, linux-mtd,
	linux-kernel

Hi Arnd,

arnd@kernel.org wrote on Wed, 29 May 2024 11:50:39 +0200:

> From: Arnd Bergmann <arnd@arndb.de>
> 
> This file gets linked into nine different modules, which causes a warning:
> 
> scripts/Makefile.build:236: drivers/mtd/tests/Makefile: mtd_test.o is added to multiple modules: mtd_nandbiterrs mtd_oobtest mtd_pagetest mtd_readtest mtd_speedtest mtd_stresstest mtd_subpagetest mtd_torturetest

I've never experienced this warning myself, how did you produce it?

> Make it a separate module instead.

I'm not a total fan of this just because it now requires an additional
step to insert these test modules (they are likely used for
debugging/development purposes, so not properly installed in the
rootfs). Is there any chance we can find another way?

Thanks,
Miquèl

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

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

* Re: [PATCH] mtd: make mtd_test.c a separate module
  2024-05-29 12:13 ` Miquel Raynal
@ 2024-05-29 12:36   ` Arnd Bergmann
  2024-05-30 13:45     ` Miquel Raynal
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2024-05-29 12:36 UTC (permalink / raw)
  To: Miquel Raynal, Arnd Bergmann
  Cc: Richard Weinberger, Vignesh Raghavendra, David Woodhouse,
	Akinobu Mita, Artem Bityutskiy, linux-mtd, linux-kernel

On Wed, May 29, 2024, at 14:13, Miquel Raynal wrote:
> Hi Arnd,
>
> arnd@kernel.org wrote on Wed, 29 May 2024 11:50:39 +0200:
>
>> From: Arnd Bergmann <arnd@arndb.de>
>> 
>> This file gets linked into nine different modules, which causes a warning:
>> 
>> scripts/Makefile.build:236: drivers/mtd/tests/Makefile: mtd_test.o is added to multiple modules: mtd_nandbiterrs mtd_oobtest mtd_pagetest mtd_readtest mtd_speedtest mtd_stresstest mtd_subpagetest mtd_torturetest
>
> I've never experienced this warning myself, how did you produce it?

This warning is currently enabled when building with 'make W=1',
but there are only a handful of drivers that run into it, so
I have sent patches for each one, with the plan to enable it
by default in the future.

>> Make it a separate module instead.
>
> I'm not a total fan of this just because it now requires an additional
> step to insert these test modules (they are likely used for
> debugging/development purposes, so not properly installed in the
> rootfs). Is there any chance we can find another way?

This should only be a problem when using plain 'insmod' instead
of 'modprobe' for loading the modules. Do you think this is
commonly used here?

Another option would be to turn all the helper functions into
static inline versions and just include the header, but
that does not avoid the duplication then.

     Arnd

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

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

* Re: [PATCH] mtd: make mtd_test.c a separate module
  2024-05-29 12:36   ` Arnd Bergmann
@ 2024-05-30 13:45     ` Miquel Raynal
  0 siblings, 0 replies; 5+ messages in thread
From: Miquel Raynal @ 2024-05-30 13:45 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Arnd Bergmann, Richard Weinberger, Vignesh Raghavendra,
	David Woodhouse, Akinobu Mita, Artem Bityutskiy, linux-mtd,
	linux-kernel

Hi Arnd,

arnd@arndb.de wrote on Wed, 29 May 2024 14:36:46 +0200:

> On Wed, May 29, 2024, at 14:13, Miquel Raynal wrote:
> > Hi Arnd,
> >
> > arnd@kernel.org wrote on Wed, 29 May 2024 11:50:39 +0200:
> >  
> >> From: Arnd Bergmann <arnd@arndb.de>
> >> 
> >> This file gets linked into nine different modules, which causes a warning:
> >> 
> >> scripts/Makefile.build:236: drivers/mtd/tests/Makefile: mtd_test.o is added to multiple modules: mtd_nandbiterrs mtd_oobtest mtd_pagetest mtd_readtest mtd_speedtest mtd_stresstest mtd_subpagetest mtd_torturetest  
> >
> > I've never experienced this warning myself, how did you produce it?  
> 
> This warning is currently enabled when building with 'make W=1',

Ok. I didn't pay attention.

> but there are only a handful of drivers that run into it, so
> I have sent patches for each one, with the plan to enable it
> by default in the future.
> 
> >> Make it a separate module instead.  
> >
> > I'm not a total fan of this just because it now requires an additional
> > step to insert these test modules (they are likely used for
> > debugging/development purposes, so not properly installed in the
> > rootfs). Is there any chance we can find another way?  
> 
> This should only be a problem when using plain 'insmod' instead
> of 'modprobe' for loading the modules. Do you think this is
> commonly used here?

These test modules have been slowly deprecated in favor of the user
space tools but when I had to use them, I was often using an initramfs
with the modules just copy/pasted and inserted with insmod. There is no
real point I guess in embedding these modules in a final rootfs.

> Another option would be to turn all the helper functions into
> static inline versions and just include the header, but
> that does not avoid the duplication then.

Indeed. 

Is there any chance to just silence the warning by flagging these
modules as "test" or "development" modules? Because TBH it feels like
the warning is just useless in this case. These modules should not be
enabled in a production environment anyway.

If not, then let's just keep your current patch. As I said, these
modules are kind of deprecated anyway.

Thanks,
Miquèl

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

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

* Re: [PATCH] mtd: make mtd_test.c a separate module
  2024-05-29  9:50 [PATCH] mtd: make mtd_test.c a separate module Arnd Bergmann
  2024-05-29 12:13 ` Miquel Raynal
@ 2024-07-01 12:00 ` Miquel Raynal
  1 sibling, 0 replies; 5+ messages in thread
From: Miquel Raynal @ 2024-07-01 12:00 UTC (permalink / raw)
  To: Arnd Bergmann, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, David Woodhouse, Akinobu Mita,
	Artem Bityutskiy
  Cc: Arnd Bergmann, linux-mtd, linux-kernel

On Wed, 2024-05-29 at 09:50:39 UTC, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> This file gets linked into nine different modules, which causes a warning:
> 
> scripts/Makefile.build:236: drivers/mtd/tests/Makefile: mtd_test.o is added to multiple modules: mtd_nandbiterrs mtd_oobtest mtd_pagetest mtd_readtest mtd_speedtest mtd_stresstest mtd_subpagetest mtd_torturetest
> 
> Make it a separate module instead.
> 
> Fixes: a995c792280d ("mtd: tests: rename sources in order to link a helper object")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

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

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

end of thread, other threads:[~2024-07-01 12:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-29  9:50 [PATCH] mtd: make mtd_test.c a separate module Arnd Bergmann
2024-05-29 12:13 ` Miquel Raynal
2024-05-29 12:36   ` Arnd Bergmann
2024-05-30 13:45     ` Miquel Raynal
2024-07-01 12:00 ` Miquel Raynal

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