Skip to contentSkip to conversation

module: Allow DEFAULT_SYMBOL_NAMESPACE be set after export.h included

PATCH In review David Laight 6 participants 13 messages Dec 28, 2024 – Dec 30, 2024

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

PATCH 1/1 module: Allow DEFAULT_SYMBOL_NAMESPACE be set after export.h included

Commit ceb8bf2ceaa77 ("module: Convert default symbol namespace to string literal") changed DEFAULT_SYMBOL_NAMESPACE to be a string literal. However the conditional definition of _EXPORT_SYMBOL() was left in.

Instead just default DEFAULT_SYMBOL_NAMESPACE to "" and remove the extra _EXPORT_SYMBOL() wrapper.

This lets DEFAULT_SYMBOL_NAMESPACE be defined after export.h is included.

Fixes fd57a3325a779 ("i2c: designware: Move exports to I2C_DW namespaces")

---
 drivers/i2c/busses/i2c-designware-common.c |  1 +
 drivers/i2c/busses/i2c-designware-master.c |  1 +
 drivers/i2c/busses/i2c-designware-slave.c  |  1 +
 include/linux/export.h                     | 10 ++++------
 4 files changed, 7 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-designware-common.c +1 -0
index 183a35038eef..be5850330c75 100644
@@ -29,6 +29,7 @@
 #include <linux/types.h>
 #include <linux/units.h>
 
+#undef DEFAULT_SYMBOL_NAMESPACE
 #define DEFAULT_SYMBOL_NAMESPACE	"I2C_DW_COMMON"
 
 #include "i2c-designware-core.h"
drivers/i2c/busses/i2c-designware-master.c +1 -0
index c8cbe5b1aeb1..083c5961d189 100644
@@ -22,6 +22,7 @@
 #include <linux/regmap.h>
 #include <linux/reset.h>
 
+#undef DEFAULT_SYMBOL_NAMESPACE
 #define DEFAULT_SYMBOL_NAMESPACE	"I2C_DW"
 
 #include "i2c-designware-core.h"
drivers/i2c/busses/i2c-designware-slave.c +1 -0
index dc2b788eac5b..72b973afb0ec 100644
@@ -16,6 +16,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 
+#undef DEFAULT_SYMBOL_NAMESPACE
 #define DEFAULT_SYMBOL_NAMESPACE	"I2C_DW"
 
 #include "i2c-designware-core.h"
include/linux/export.h +4 -6
index 2633df4d31e6..6cea1c3982cd 100644
@@ -59,14 +59,12 @@
 
 #endif
 
-#ifdef DEFAULT_SYMBOL_NAMESPACE
-#define _EXPORT_SYMBOL(sym, license)	__EXPORT_SYMBOL(sym, license, DEFAULT_SYMBOL_NAMESPACE)
-#else
-#define _EXPORT_SYMBOL(sym, license)	__EXPORT_SYMBOL(sym, license, "")
+#ifndef DEFAULT_SYMBOL_NAMESPACE
+#define DEFAULT_SYMBOL_NAMESPACE ""
 #endif
 
-#define EXPORT_SYMBOL(sym)		_EXPORT_SYMBOL(sym, "")
-#define EXPORT_SYMBOL_GPL(sym)		_EXPORT_SYMBOL(sym, "GPL")
+#define EXPORT_SYMBOL(sym)		__EXPORT_SYMBOL(sym, "", DEFAULT_SYMBOL_NAMESPACE)
+#define EXPORT_SYMBOL_GPL(sym)		__EXPORT_SYMBOL(sym, "GPL", DEFAULT_SYMBOL_NAMESPACE)
 #define EXPORT_SYMBOL_NS(sym, ns)	__EXPORT_SYMBOL(sym, "", ns)
 #define EXPORT_SYMBOL_NS_GPL(sym, ns)	__EXPORT_SYMBOL(sym, "GPL", ns)
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 10 lines · David Laight

Commit ceb8bf2ceaa77 ("module: Convert default symbol namespace to string literal") changed DEFAULT_SYMBOL_NAMESPACE to be a string literal. However the conditional definition of _EXPORT_SYMBOL() was left in.

Instead just default DEFAULT_SYMBOL_NAMESPACE to "" and remove the extra _EXPORT_SYMBOL() wrapper.

This lets DEFAULT_SYMBOL_NAMESPACE be defined after export.h is included.

Fixes fd57a3325a779 ("i2c: designware: Move exports to I2C_DW namespaces")

Incorrect format, and this should be a tag.

...

This patch in a different form had been already submitted by Uwe. So, guys, fix the documentation or clarify it and when you agree on the approach, choose the patch to review. No Ack till that. Andi, FYI.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 5 lines · On Sat, 28 Dec 2024 23:38:49 +0200 Andy Shevchenko…
Quoted 4 lines · David Laight

Commit ceb8bf2ceaa77 ("module: Convert default symbol namespace to string literal") changed DEFAULT_SYMBOL_NAMESPACE to be a string literal. However the conditional definition of _EXPORT_SYMBOL() was left in.

Quoted 8 lines
Quoted 6 lines

Instead just default DEFAULT_SYMBOL_NAMESPACE to "" and remove the extra _EXPORT_SYMBOL() wrapper.

This lets DEFAULT_SYMBOL_NAMESPACE be defined after export.h is included.

Fixes fd57a3325a779 ("i2c: designware: Move exports to I2C_DW namespaces")

Incorrect format, and this should be a tag.

Except that it doesn't want to be picked up by the back-port bots. At least not in this form - since the changes to export.h that remove the __stringify() don't really want back-porting.

Quoted 4 lines

...

This patch in a different form had been already submitted by Uwe.

Did that move the DEFAULT_SYMBOL_NAMESPACE define to the top of the file? That can be back-ported provided the " are removed.

The simplification to export.h (which is what I was trying to do) can then be done after the other patches.

Quoted 4 lines

So, guys, fix
the documentation or clarify it and when you agree on the approach, choose the patch to review. No Ack till that. Andi, FYI.

I had another thought overnight - which is more changes.
Instead of using DEFAULT_SYMBOL_NAMESPACE in EXPORT_SYMBOL() use it as
a default for EXPORT_SYMBOL_NS().
So you have something like:
#define EXPORT_SYMBOL_NS(sym, ...) _EXPORT_SYMBOL_NS(sym, __VA_ARGS__, DEFAULT_SYMBOL_NAMESPACE) #define _EXPORT_SYMBOL_NS(sym, ns, ...) __EXPORT_SYMBOL(sym, "", ns)

That requires that all the EXPORT_SYMBOL(sym) in files that define DEFAULT_SYMBOL_NAMESPACE be changed to EXPORT_SYMBOL_NS(sym).
But it doesn't require a default definition of DEFAULT_SYMBOL_NAMESPACE and lets it be defined in a more obvious part of the source file.

David

#3 lore raw
In reply to David Laight
Quoted 5 lines · David Laight

Instead just default DEFAULT_SYMBOL_NAMESPACE to "" and remove the extra _EXPORT_SYMBOL() wrapper.

This lets DEFAULT_SYMBOL_NAMESPACE be defined after export.h is included.

Grr. This is horribly ugly.

I think the i2c code should just be fixed to use the proper "define namespace early".

I will also note that 'sparse' has a notion of a "weak define", where you can set a default value for a preprocessor symbol, but if it gets redefined by the user (or already has a definition), sparse won't complain about it, and just use the strong one.

That would have been lovely, and we could have had a

#weak_define DEFAULT_SYMBOL_NAMESPACE ""

and this wouldn't be the ugly mess it is.

I wish the regular C preprocessor could do the same. Oh well. Since it doesn't, I really think i2c should just be fixed, and we shouldn't try to deal with i2c having done things wrong.

Linus

#4 lore raw
Quoted 8 lines · On Sat, 28 Dec 2024 15:29:24 -0800 Linus Torvalds…
Quoted 5 lines · David Laight

Instead just default DEFAULT_SYMBOL_NAMESPACE to "" and remove the extra _EXPORT_SYMBOL() wrapper.

This lets DEFAULT_SYMBOL_NAMESPACE be defined after export.h is included.

Grr. This is horribly ugly.

I thought it was a neater 'ugly' than the current definitions in export.h

Quoted 2 lines

I think the i2c code should just be fixed to use the proper "define namespace early".

The i2c changes were needed because I found the code wouldn't compile. It is pretty easy mistake to make and will happen again.

and does - I missed drivers/pwm/pwm-lpss.c drivers/hwmon/nct6775-core.c and drivers/pwm/pwm-lpss.c

I guess those files could be fixed by moving the definition 'early'.

Quoted 7 lines

I will also note that 'sparse' has a notion of a "weak define", where you can set a default value for a preprocessor symbol, but if it gets redefined by the user (or already has a definition), sparse won't complain about it, and just use the strong one.

That would have been lovely, and we could have had a

Quoted 7 lines

#weak_define DEFAULT_SYMBOL_NAMESPACE ""

and this wouldn't be the ugly mess it is.

I wish the regular C preprocessor could do the same. Oh well. Since it doesn't, I really think i2c should just be fixed, and we shouldn't try to deal with i2c having done things wrong.

What you really need is the preprocessor to support a ?: type operator in an expansion. Then you can have (DEFAULT_SYMBOL_NAMESPACE ?: "") in the expansion of EXPORT_SYMBOL().

Quoted 2 lines

Linus

#5 lore raw
Quoted 12 lines · David Laight
Quoted 8 lines · On Sat, 28 Dec 2024 15:29:24 -0800 Linus Torvalds…
Quoted 5 lines · David Laight

Instead just default DEFAULT_SYMBOL_NAMESPACE to "" and remove the extra _EXPORT_SYMBOL() wrapper.

This lets DEFAULT_SYMBOL_NAMESPACE be defined after export.h is included.

Grr. This is horribly ugly.

Quoted 7 lines

I thought it was a neater 'ugly' than the current definitions in export.h

Quoted 2 lines

I think the i2c code should just be fixed to use the proper "define namespace early".

The i2c changes were needed because I found the code wouldn't compile. It is pretty easy mistake to make and will happen again.

There is
https://lore.kernel.org/linux-i2c/[email protected]
that moves the DEFAULT_SYMBOL_NAMESPACE above the #include block for the i2c driver. Though it seems I missed ...master.c. (I'll address that.)

Quoted 2 lines

and does - I missed drivers/pwm/pwm-lpss.c drivers/hwmon/nct6775-core.c and drivers/pwm/pwm-lpss.c

drivers/pwm/pwm-lpss.c is addressed by
https://lore.kernel.org/linux-pwm/[email protected]

the hwmon driver is addressed by
https://lore.kernel.org/linux-hwmon/[email protected]
(and applied in next)

There is also drivers/gpio/gpio-idio-16.c (which I guess you intended to list instead of the pwm driver twice), which I sent a patch for at
https://lore.kernel.org/linux-gpio/[email protected]
(also already applied in next).

Best regards
Uwe

#6 lore raw
Quoted 32 lines · On Mon, 30 Dec 2024 10:42:55 +0100 Uwe Kleine-König…
Quoted 12 lines · David Laight
Quoted 8 lines · On Sat, 28 Dec 2024 15:29:24 -0800 Linus Torvalds…
Quoted 5 lines · David Laight

Instead just default DEFAULT_SYMBOL_NAMESPACE to "" and remove the extra _EXPORT_SYMBOL() wrapper.

This lets DEFAULT_SYMBOL_NAMESPACE be defined after export.h is included.

Grr. This is horribly ugly.

Quoted 7 lines

I thought it was a neater 'ugly' than the current definitions in export.h

Quoted 2 lines

I think the i2c code should just be fixed to use the proper "define namespace early".

The i2c changes were needed because I found the code wouldn't compile. It is pretty easy mistake to make and will happen again.

There is
https://lore.kernel.org/linux-i2c/[email protected]
that moves the DEFAULT_SYMBOL_NAMESPACE above the #include block for the i2c driver. Though it seems I missed ...master.c. (I'll address that.)

Quoted 2 lines

and does - I missed drivers/pwm/pwm-lpss.c drivers/hwmon/nct6775-core.c and drivers/pwm/pwm-lpss.c

drivers/pwm/pwm-lpss.c is addressed by
https://lore.kernel.org/linux-pwm/[email protected]

Quoted 8 lines

the hwmon driver is addressed by
https://lore.kernel.org/linux-hwmon/[email protected]
(and applied in next)

There is also drivers/gpio/gpio-idio-16.c (which I guess you intended to list instead of the pwm driver twice), which I sent a patch for at
https://lore.kernel.org/linux-gpio/[email protected]
(also already applied in next).

With all those applied it is probably worth applying my change to export.h (which is all I really wanted to do - until the build failures.)

include/linux/export.h +4 -6
index 2633df4d31e6..6cea1c3982cd 100644
@@ -59,14 +59,12 @@
 
 #endif
 
-#ifdef DEFAULT_SYMBOL_NAMESPACE
-#define _EXPORT_SYMBOL(sym, license)   __EXPORT_SYMBOL(sym, license, DEFAULT_SYMBOL_NAMESPACE)
-#else
-#define _EXPORT_SYMBOL(sym, license)   __EXPORT_SYMBOL(sym, license, "")
+#ifndef DEFAULT_SYMBOL_NAMESPACE
+#define DEFAULT_SYMBOL_NAMESPACE ""
 #endif
 
-#define EXPORT_SYMBOL(sym)             _EXPORT_SYMBOL(sym, "")
-#define EXPORT_SYMBOL_GPL(sym)         _EXPORT_SYMBOL(sym, "GPL")
+#define EXPORT_SYMBOL(sym)             __EXPORT_SYMBOL(sym, "", DEFAULT_SYMBOL_NAMESPACE)
+#define EXPORT_SYMBOL_GPL(sym)         __EXPORT_SYMBOL(sym, "GPL", DEFAULT_SYMBOL_NAMESPACE)
 #define EXPORT_SYMBOL_NS(sym, ns)      __EXPORT_SYMBOL(sym, "", ns)
 #define EXPORT_SYMBOL_NS_GPL(sym, ns)  __EXPORT_SYMBOL(sym, "GPL", ns)
 

It would be 'nice' to get that into 6.13 (along with the other changes that remove __stringify()) - but it is getting late in the rc cycle now.

Whether it is better to define DEFAULT_SYMBOL_NAMESPACE at the top of the file or after the includes is another matter.
If the file is a module then it really makes sense to put the definition with all the other module-related definitions.
The fact that it needs a #undef is annoying, but not the end of the world.

David

#7 lore raw

Hello David,

Quoted 53 lines · David Laight
Quoted 32 lines · On Mon, 30 Dec 2024 10:42:55 +0100 Uwe Kleine-König…
Quoted 12 lines · David Laight
Quoted 8 lines · On Sat, 28 Dec 2024 15:29:24 -0800 Linus Torvalds…
Quoted 5 lines · David Laight

Instead just default DEFAULT_SYMBOL_NAMESPACE to "" and remove the extra _EXPORT_SYMBOL() wrapper.

This lets DEFAULT_SYMBOL_NAMESPACE be defined after export.h is included.

Grr. This is horribly ugly.

Quoted 7 lines

I thought it was a neater 'ugly' than the current definitions in export.h

Quoted 2 lines

I think the i2c code should just be fixed to use the proper "define namespace early".

The i2c changes were needed because I found the code wouldn't compile. It is pretty easy mistake to make and will happen again.

There is
https://lore.kernel.org/linux-i2c/[email protected]
that moves the DEFAULT_SYMBOL_NAMESPACE above the #include block for the i2c driver. Though it seems I missed ...master.c. (I'll address that.)

Quoted 2 lines

and does - I missed drivers/pwm/pwm-lpss.c drivers/hwmon/nct6775-core.c and drivers/pwm/pwm-lpss.c

drivers/pwm/pwm-lpss.c is addressed by
https://lore.kernel.org/linux-pwm/[email protected]

Quoted 8 lines

the hwmon driver is addressed by
https://lore.kernel.org/linux-hwmon/[email protected]
(and applied in next)

There is also drivers/gpio/gpio-idio-16.c (which I guess you intended to list instead of the pwm driver twice), which I sent a patch for at
https://lore.kernel.org/linux-gpio/[email protected]
(also already applied in next).

With all those applied it is probably worth applying my change to export.h (which is all I really wanted to do - until the build failures.)

include/linux/export.h +0 -0
index 2633df4d31e6..6cea1c3982cd 100644

include/linux/export.h line 63

Quoted 5 lines
include/linux/export.h +0 -2
@@ -59,14 +59,12 @@
 
 #endif
 
-#ifdef DEFAULT_SYMBOL_NAMESPACE
-#define _EXPORT_SYMBOL(sym, license)   __EXPORT_SYMBOL(sym, license, DEFAULT_SYMBOL_NAMESPACE)

If you keep the above definition (without the #ifdef), you don't need to touch the definitions of EXPORT_SYMBOL and EXPORT_SYMBOL_GPL below. Probably a matter of taste.

Quoted 13 lines
include/linux/export.h +4 -4
-#else
-#define _EXPORT_SYMBOL(sym, license)   __EXPORT_SYMBOL(sym, license, "")
+#ifndef DEFAULT_SYMBOL_NAMESPACE
+#define DEFAULT_SYMBOL_NAMESPACE ""
 #endif
 
-#define EXPORT_SYMBOL(sym)             _EXPORT_SYMBOL(sym, "")
-#define EXPORT_SYMBOL_GPL(sym)         _EXPORT_SYMBOL(sym, "GPL")
+#define EXPORT_SYMBOL(sym)             __EXPORT_SYMBOL(sym, "", DEFAULT_SYMBOL_NAMESPACE)
+#define EXPORT_SYMBOL_GPL(sym)         __EXPORT_SYMBOL(sym, "GPL", DEFAULT_SYMBOL_NAMESPACE)
 #define EXPORT_SYMBOL_NS(sym, ns)      __EXPORT_SYMBOL(sym, "", ns)
 #define EXPORT_SYMBOL_NS_GPL(sym, ns)  __EXPORT_SYMBOL(sym, "GPL", ns)
 
Quoted 2 lines

It would be 'nice' to get that into 6.13 (along with the other changes that remove __stringify()) - but it is getting late in the rc cycle now.

I'm pretty sure we won't get all my changes into v6.13.

Best regards
Uwe

#8 lore raw
Quoted 57 lines · On Mon, 30 Dec 2024 13:54:45 +0100 Uwe Kleine-König…

Hello David,

Quoted 54 lines · David Laight
Quoted 32 lines · On Mon, 30 Dec 2024 10:42:55 +0100 Uwe Kleine-König…
Quoted 12 lines · David Laight
Quoted 8 lines · On Sat, 28 Dec 2024 15:29:24 -0800 Linus Torvalds…
Quoted 5 lines · David Laight

Instead just default DEFAULT_SYMBOL_NAMESPACE to "" and remove the extra _EXPORT_SYMBOL() wrapper.

This lets DEFAULT_SYMBOL_NAMESPACE be defined after export.h is included.

Grr. This is horribly ugly.

Quoted 7 lines

I thought it was a neater 'ugly' than the current definitions in export.h

Quoted 2 lines

I think the i2c code should just be fixed to use the proper "define namespace early".

The i2c changes were needed because I found the code wouldn't compile. It is pretty easy mistake to make and will happen again.

There is
https://lore.kernel.org/linux-i2c/[email protected]
that moves the DEFAULT_SYMBOL_NAMESPACE above the #include block for the i2c driver. Though it seems I missed ...master.c. (I'll address that.)

Quoted 2 lines

and does - I missed drivers/pwm/pwm-lpss.c drivers/hwmon/nct6775-core.c and drivers/pwm/pwm-lpss.c

drivers/pwm/pwm-lpss.c is addressed by
https://lore.kernel.org/linux-pwm/[email protected]

Quoted 8 lines

the hwmon driver is addressed by
https://lore.kernel.org/linux-hwmon/[email protected]
(and applied in next)

There is also drivers/gpio/gpio-idio-16.c (which I guess you intended to list instead of the pwm driver twice), which I sent a patch for at
https://lore.kernel.org/linux-gpio/[email protected]
(also already applied in next).

With all those applied it is probably worth applying my change to export.h (which is all I really wanted to do - until the build failures.)

include/linux/export.h +0 -0
index 2633df4d31e6..6cea1c3982cd 100644
@@ -59,14 +59,12 @@
 
Quoted 8 lines

include/linux/export.h line 63

Quoted 4 lines
include/linux/export.h +0 -2
 #endif
 
-#ifdef DEFAULT_SYMBOL_NAMESPACE
-#define _EXPORT_SYMBOL(sym, license)   __EXPORT_SYMBOL(sym, license, DEFAULT_SYMBOL_NAMESPACE)  

If you keep the above definition (without the #ifdef), you don't need to touch the definitions of EXPORT_SYMBOL and EXPORT_SYMBOL_GPL below. Probably a matter of taste.

The extra wrapper just makes it harder to read (and will be immeasurably slower to compile).

Quoted 13 lines
Quoted 13 lines
include/linux/export.h +4 -4
-#else
-#define _EXPORT_SYMBOL(sym, license)   __EXPORT_SYMBOL(sym, license, "")
+#ifndef DEFAULT_SYMBOL_NAMESPACE
+#define DEFAULT_SYMBOL_NAMESPACE ""
 #endif
 
-#define EXPORT_SYMBOL(sym)             _EXPORT_SYMBOL(sym, "")
-#define EXPORT_SYMBOL_GPL(sym)         _EXPORT_SYMBOL(sym, "GPL")
+#define EXPORT_SYMBOL(sym)             __EXPORT_SYMBOL(sym, "", DEFAULT_SYMBOL_NAMESPACE)
+#define EXPORT_SYMBOL_GPL(sym)         __EXPORT_SYMBOL(sym, "GPL", DEFAULT_SYMBOL_NAMESPACE)
 #define EXPORT_SYMBOL_NS(sym, ns)      __EXPORT_SYMBOL(sym, "", ns)
 #define EXPORT_SYMBOL_NS_GPL(sym, ns)  __EXPORT_SYMBOL(sym, "GPL", ns)
 
Quoted 4 lines
Quoted 2 lines

It would be 'nice' to get that into 6.13 (along with the other changes that remove __stringify()) - but it is getting late in the rc cycle now.

I'm pretty sure we won't get all my changes into v6.13.

Indeed: Linus would have to like them and 'just apply them' :-)

David

Quoted 3 lines

Best regards
Uwe

#9 lore raw
In reply to David Laight
Quoted 13 lines · David Laight
Quoted 8 lines · On Sat, 28 Dec 2024 15:29:24 -0800 Linus Torvalds…
Quoted 5 lines · David Laight

Instead just default DEFAULT_SYMBOL_NAMESPACE to "" and remove the extra _EXPORT_SYMBOL() wrapper.

This lets DEFAULT_SYMBOL_NAMESPACE be defined after export.h is included.

Grr. This is horribly ugly.

Quoted 7 lines

I thought it was a neater 'ugly' than the current definitions in export.h

Quoted 2 lines

I think the i2c code should just be fixed to use the proper "define namespace early".

The i2c changes were needed because I found the code wouldn't compile. It is pretty easy mistake to make and will happen again.

Agree.

Currently, the compilation still succeeds, and the empty string "" is used instead of the specified namespace, silently. It is difficult to notice this mistake.

So, I like the change for include/linux/export.h
since it causes a compile error if
DEFAULT_SYMBOL_NAMESPACE is defined after
the header inclusion.

Perhaps, we can add a comment about how
to fix the issue.

/*
* If you override DEFAULT_SYMBOL_NAMESPACE, please define it at the very top
* of the source file, before any header inclusion.
*/
#ifndef DEFAULT_SYMBOL_NAMESPACE
#define DEFAULT_SYMBOL_NAMESPACE ""
#endif

Quoted 3 lines

and does - I missed drivers/pwm/pwm-lpss.c drivers/hwmon/nct6775-core.c and drivers/pwm/pwm-lpss.c

OK, this patch breaks the compilation, and we can notice the mistake. This is good.

Quoted 24 lines

I guess those files could be fixed by moving the definition 'early'.

Quoted 7 lines

I will also note that 'sparse' has a notion of a "weak define", where you can set a default value for a preprocessor symbol, but if it gets redefined by the user (or already has a definition), sparse won't complain about it, and just use the strong one.

That would have been lovely, and we could have had a

Quoted 7 lines

#weak_define DEFAULT_SYMBOL_NAMESPACE ""

and this wouldn't be the ugly mess it is.

I wish the regular C preprocessor could do the same. Oh well. Since it doesn't, I really think i2c should just be fixed, and we shouldn't try to deal with i2c having done things wrong.

What you really need is the preprocessor to support a ?: type operator in an expansion. Then you can have (DEFAULT_SYMBOL_NAMESPACE ?: "") in the expansion of EXPORT_SYMBOL().

Quoted 2 lines

Linus

Signature · 2 lines
Best Regards
Masahiro Yamada
#10 lore raw
In reply to David Laight
kernel test robot noticed the following build warnings:

Hi David,

kernel test robot noticed the following build warnings:

[auto build test WARNING on andi-shyti/i2c/i2c-host]
[also build test WARNING on linus/master v6.13-rc4 next-20241220] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/David-Laight/module-Allow-DEFAULT_SYMBOL_NAMESPACE-be-set-after-export-h-included/20241229-024441
base:   https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host
patch link:    https://lore.kernel.org/r/20241228184328.5ced280b%40dsl-u17-10
patch subject: [PATCH] module: Allow DEFAULT_SYMBOL_NAMESPACE be set after export.h included
config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20241229/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241229/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/pwm/pwm-lpss.c:22: warning: "DEFAULT_SYMBOL_NAMESPACE" redefined
      22 | #define DEFAULT_SYMBOL_NAMESPACE "PWM_LPSS"
         | 
   In file included from include/linux/linkage.h:7,
                    from arch/x86/include/asm/cache.h:5,
                    from include/linux/cache.h:6,
                    from arch/x86/include/asm/current.h:10,
                    from include/linux/sched.h:12,
                    from include/linux/delay.h:13,
                    from drivers/pwm/pwm-lpss.c:14:

include/linux/export.h:63: note: this is the location of the previous definition
63 | #define DEFAULT_SYMBOL_NAMESPACE ""
|

vim +/DEFAULT_SYMBOL_NAMESPACE +22 drivers/pwm/pwm-lpss.c

093e00bb3f82f3 Alan Cox 2014-04-18 21
ceb8bf2ceaa77f Masahiro Yamada 2024-12-03 @22 #define DEFAULT_SYMBOL_NAMESPACE "PWM_LPSS" a3682d2fe3c36c Andy Shevchenko 2022-09-27 23

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#11 lore raw
In reply to David Laight
kernel test robot noticed the following build warnings:

Hi David,

kernel test robot noticed the following build warnings:

[auto build test WARNING on andi-shyti/i2c/i2c-host]
[also build test WARNING on linus/master v6.13-rc4 next-20241220] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/David-Laight/module-Allow-DEFAULT_SYMBOL_NAMESPACE-be-set-after-export-h-included/20241229-024441
base:   https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host
patch link:    https://lore.kernel.org/r/20241228184328.5ced280b%40dsl-u17-10
patch subject: [PATCH] module: Allow DEFAULT_SYMBOL_NAMESPACE be set after export.h included
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20241229/[email protected]/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241229/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/pwm/pwm-lpss.c:22:9: warning: 'DEFAULT_SYMBOL_NAMESPACE' macro redefined [-Wmacro-redefined]

22 | #define DEFAULT_SYMBOL_NAMESPACE "PWM_LPSS"
| ^
include/linux/export.h:63:9: note: previous definition is here
63 | #define DEFAULT_SYMBOL_NAMESPACE ""
| ^
1 warning generated.

vim +/DEFAULT_SYMBOL_NAMESPACE +22 drivers/pwm/pwm-lpss.c

093e00bb3f82f3 Alan Cox 2014-04-18 21
ceb8bf2ceaa77f Masahiro Yamada 2024-12-03 @22 #define DEFAULT_SYMBOL_NAMESPACE "PWM_LPSS" a3682d2fe3c36c Andy Shevchenko 2022-09-27 23

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#12 lore raw
In reply to David Laight
Quoted 3 lines · David Laight

Commit ceb8bf2ceaa77 ("module: Convert default symbol namespace to string literal") changed DEFAULT_SYMBOL_NAMESPACE to be a string literal.

Why is ceb8bf2ceaa77 related?

Even before ceb8bf2ceaa77, this was broken.

--
Best Regards
Masahiro Yamada