Skip to contentSkip to conversation

net: sunhme: move asm includes to below linux includes

PATCH Applied Simon Horman 6 participants 9 messages Apr 5, 2023 – Apr 7, 2023

Subsystems (4)
lore
Share & tools
lore

Simon Horman

author reviewer
#0 lore raw

PATCH 1/1 net: sunhme: move asm includes to below linux includes

A recent rearrangement of includes has lead to a problem on m68k as flagged by the kernel test robot.

Resolve this by moving the block asm includes to below linux includes. A side effect i that non-Sparc asm includes are now immediately before Sparc asm includes, which seems nice.

Using sparse v0.6.4 I was able to reproduce this problem as follows using the config provided by the kernel test robot:

$ wget https://download.01.org/0day-ci/archive/20230404/[email protected]/config
$ cp config .config
$ make ARCH=m68k oldconfig
$ make ARCH=m68k C=2 M=drivers/net/ethernet/sun
   CC [M]  drivers/net/ethernet/sun/sunhme.o
 In file included from drivers/net/ethernet/sun/sunhme.c:19:
 ./arch/m68k/include/asm/irq.h:78:11: error: expected ‘;’ before ‘void’
    78 | asmlinkage void do_IRQ(int irq, struct pt_regs *regs);
       |           ^~~~~
       |           ;
 ./arch/m68k/include/asm/irq.h:78:40: warning: ‘struct pt_regs’ declared inside parameter list will not be visible outside of this definition or declaration
    78 | asmlinkage void do_IRQ(int irq, struct pt_regs *regs);
       |                                        ^~~~~~~

Compile tested only.

---
 drivers/net/ethernet/sun/sunhme.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/sun/sunhme.c +4 -3
index ec85aef35bf9..b93613cd1994 100644
@@ -14,9 +14,6 @@
  *     argument : macaddr=0x00,0x10,0x20,0x30,0x40,0x50
  */
 
-#include <asm/byteorder.h>
-#include <asm/dma.h>
-#include <asm/irq.h>
 #include <linux/bitops.h>
 #include <linux/crc32.h>
 #include <linux/delay.h>
@@ -45,6 +42,10 @@
 #include <linux/types.h>
 #include <linux/uaccess.h>
 
+#include <asm/byteorder.h>
+#include <asm/dma.h>
+#include <asm/irq.h>
+
 #ifdef CONFIG_SPARC
 #include <asm/auxio.h>
 #include <asm/idprom.h>
maintainer
#1 lore raw
Quoted 10 lines · Simon Horman

A recent rearrangement of includes has lead to a problem on m68k as flagged by the kernel test robot.

Resolve this by moving the block asm includes to below linux includes. A side effect i that non-Sparc asm includes are now immediately before Sparc asm includes, which seems nice.

Using sparse v0.6.4 I was able to reproduce this problem as follows using the config provided by the kernel test robot:

Quoted 13 lines
$ wget https://download.01.org/0day-ci/archive/20230404/[email protected]/config
$ cp config .config
$ make ARCH=m68k oldconfig
$ make ARCH=m68k C=2 M=drivers/net/ethernet/sun
    CC [M]  drivers/net/ethernet/sun/sunhme.o
  In file included from drivers/net/ethernet/sun/sunhme.c:19:
  ./arch/m68k/include/asm/irq.h:78:11: error: expected ‘;’ before ‘void’
     78 | asmlinkage void do_IRQ(int irq, struct pt_regs *regs);
        |           ^~~~~
        |           ;
  ./arch/m68k/include/asm/irq.h:78:40: warning: ‘struct pt_regs’ declared inside parameter list will not be visible outside of this definition or declaration
     78 | asmlinkage void do_IRQ(int irq, struct pt_regs *regs);
        |                                        ^~~~~~~

This seems like a problem with the header. m68k's asm/irq.h should include linux/interrupt.h before its declarations.

--Sean

Quoted 36 lines

Compile tested only.

---
  drivers/net/ethernet/sun/sunhme.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/sun/sunhme.c +4 -3
index ec85aef35bf9..b93613cd1994 100644
@@ -14,9 +14,6 @@
   *     argument : macaddr=0x00,0x10,0x20,0x30,0x40,0x50
   */
 
-#include <asm/byteorder.h>
-#include <asm/dma.h>
-#include <asm/irq.h>
  #include <linux/bitops.h>
  #include <linux/crc32.h>
  #include <linux/delay.h>
@@ -45,6 +42,10 @@
  #include <linux/types.h>
  #include <linux/uaccess.h>
 
+#include <asm/byteorder.h>
+#include <asm/dma.h>
+#include <asm/irq.h>
+
  #ifdef CONFIG_SPARC
  #include <asm/auxio.h>
  #include <asm/idprom.h>
author reviewer
#2 lore raw
Quoted 25 lines · Sean Anderson
Quoted 10 lines · Simon Horman

A recent rearrangement of includes has lead to a problem on m68k as flagged by the kernel test robot.

Resolve this by moving the block asm includes to below linux includes. A side effect i that non-Sparc asm includes are now immediately before Sparc asm includes, which seems nice.

Using sparse v0.6.4 I was able to reproduce this problem as follows using the config provided by the kernel test robot:

Quoted 13 lines
$ wget https://download.01.org/0day-ci/archive/20230404/[email protected]/config
$ cp config .config
$ make ARCH=m68k oldconfig
$ make ARCH=m68k C=2 M=drivers/net/ethernet/sun
    CC [M]  drivers/net/ethernet/sun/sunhme.o
  In file included from drivers/net/ethernet/sun/sunhme.c:19:
  ./arch/m68k/include/asm/irq.h:78:11: error: expected ‘;’ before ‘void’
     78 | asmlinkage void do_IRQ(int irq, struct pt_regs *regs);
        |           ^~~~~
        |           ;
  ./arch/m68k/include/asm/irq.h:78:40: warning: ‘struct pt_regs’ declared inside parameter list will not be visible outside of this definition or declaration
     78 | asmlinkage void do_IRQ(int irq, struct pt_regs *regs);
        |                                        ^~~~~~~
Quoted 1 line

This seems like a problem with the header. m68k's asm/irq.h should include linux/interrupt.h before its declarations.

Hi Sean,

I do see your point. But TBH I'm unsure which way to go on this one. Geert, do you have any input?

Quoted 37 lines

--Sean

Quoted 34 lines

Compile tested only.

---
  drivers/net/ethernet/sun/sunhme.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/sun/sunhme.c +4 -3
index ec85aef35bf9..b93613cd1994 100644
@@ -14,9 +14,6 @@
   *     argument : macaddr=0x00,0x10,0x20,0x30,0x40,0x50
   */
-#include <asm/byteorder.h>
-#include <asm/dma.h>
-#include <asm/irq.h>
  #include <linux/bitops.h>
  #include <linux/crc32.h>
  #include <linux/delay.h>
@@ -45,6 +42,10 @@
  #include <linux/types.h>
  #include <linux/uaccess.h>
+#include <asm/byteorder.h>
+#include <asm/dma.h>
+#include <asm/irq.h>
+
  #ifdef CONFIG_SPARC
  #include <asm/auxio.h>
  #include <asm/idprom.h>
 
#3 lore raw
Quoted 26 lines · Simon Horman
Quoted 25 lines · Sean Anderson
Quoted 23 lines · Simon Horman

A recent rearrangement of includes has lead to a problem on m68k as flagged by the kernel test robot.

Resolve this by moving the block asm includes to below linux includes. A side effect i that non-Sparc asm includes are now immediately before Sparc asm includes, which seems nice.

Using sparse v0.6.4 I was able to reproduce this problem as follows using the config provided by the kernel test robot:

$ wget https://download.01.org/0day-ci/archive/20230404/[email protected]/config
$ cp config .config
$ make ARCH=m68k oldconfig
$ make ARCH=m68k C=2 M=drivers/net/ethernet/sun
    CC [M]  drivers/net/ethernet/sun/sunhme.o
  In file included from drivers/net/ethernet/sun/sunhme.c:19:
  ./arch/m68k/include/asm/irq.h:78:11: error: expected ‘;’ before ‘void’
     78 | asmlinkage void do_IRQ(int irq, struct pt_regs *regs);
        |           ^~~~~
        |           ;
  ./arch/m68k/include/asm/irq.h:78:40: warning: ‘struct pt_regs’ declared inside parameter list will not be visible outside of this definition or declaration
     78 | asmlinkage void do_IRQ(int irq, struct pt_regs *regs);
        |                                        ^~~~~~~
Quoted 6 lines
Quoted 1 line

This seems like a problem with the header. m68k's asm/irq.h should include linux/interrupt.h before its declarations.

Hi Sean,

I do see your point. But TBH I'm unsure which way to go on this one. Geert, do you have any input?

We always include linux/* headers before asm/*. The "sorting" of headers in this way was inappropriate.

maintainer
#4 lore raw
Quoted 29 lines · Matthew Wilcox
Quoted 28 lines · Simon Horman
Quoted 26 lines · Sean Anderson
Quoted 10 lines · Simon Horman

A recent rearrangement of includes has lead to a problem on m68k as flagged by the kernel test robot.

Resolve this by moving the block asm includes to below linux includes. A side effect i that non-Sparc asm includes are now immediately before Sparc asm includes, which seems nice.

Using sparse v0.6.4 I was able to reproduce this problem as follows using the config provided by the kernel test robot:

Quoted 13 lines
$ wget https://download.01.org/0day-ci/archive/20230404/[email protected]/config
$ cp config .config
$ make ARCH=m68k oldconfig
$ make ARCH=m68k C=2 M=drivers/net/ethernet/sun
     CC [M]  drivers/net/ethernet/sun/sunhme.o
   In file included from drivers/net/ethernet/sun/sunhme.c:19:
   ./arch/m68k/include/asm/irq.h:78:11: error: expected ‘;’ before ‘void’
      78 | asmlinkage void do_IRQ(int irq, struct pt_regs *regs);
         |           ^~~~~
         |           ;
   ./arch/m68k/include/asm/irq.h:78:40: warning: ‘struct pt_regs’ declared inside parameter list will not be visible outside of this definition or declaration
      78 | asmlinkage void do_IRQ(int irq, struct pt_regs *regs);
         |                                        ^~~~~~~

This seems like a problem with the header. m68k's asm/irq.h should include linux/interrupt.h before its declarations.

Quoted 7 lines
Quoted 4 lines

Hi Sean,

I do see your point. But TBH I'm unsure which way to go on this one. Geert, do you have any input?

We always include linux/* headers before asm/*. The "sorting" of headers in this way was inappropriate.

Is this written down anywhere? I couldn't find it in Documentation/process...

--Sean

#5 lore raw
Quoted 5 lines · Sean Anderson
Quoted 2 lines · Matthew Wilcox

We always include linux/* headers before asm/*. The "sorting" of headers in this way was inappropriate.

Is this written down anywhere? I couldn't find it in Documentation/process...

Feel free to send a patch. Generally, it should be:

#include <linux/foo.h>
#include <linux/bar.h>

#include <asm/baz.h>
#include <asm/quux.h>

#include "local.h"

Some drivers do this a different way with a single local.h that includes all necessary includes.

Also if <linux/foo.h> and <asm/foo.h> both exist, you should include <linux/foo.h> (which almost certainly includes <asm/foo.h>)

maintainer
#6 lore raw
Quoted 8 lines · On Wed, 5 Apr 2023 19:34:38 +0100 Matthew Wilcox wrote:
Quoted 5 lines · Sean Anderson
Quoted 2 lines · Matthew Wilcox

We always include linux/* headers before asm/*. The "sorting" of headers in this way was inappropriate.

Is this written down anywhere? I couldn't find it in Documentation/process...

Feel free to send a patch.

Patch to documentation, checkpatch or both :)

#7 lore raw
In reply to Matthew Wilcox

Hi Willy,

Quoted 15 lines · Matthew Wilcox
Quoted 5 lines · Sean Anderson
Quoted 2 lines · Matthew Wilcox

We always include linux/* headers before asm/*. The "sorting" of headers in this way was inappropriate.

Is this written down anywhere? I couldn't find it in Documentation/process...

Feel free to send a patch. Generally, it should be:

#include <linux/foo.h>
#include <linux/bar.h>

#include <asm/baz.h>
#include <asm/quux.h>

Quoted 7 lines

#include "local.h"

Some drivers do this a different way with a single local.h that includes all necessary includes.

Also if <linux/foo.h> and <asm/foo.h> both exist, you should include <linux/foo.h> (which almost certainly includes <asm/foo.h>)

Indeed. Usually <asm/foo.h> should not be included directly, except for a few exceptions like <asm/irq.h>.

Witness e.g. the (violated a lot) comment at the top of include/linux/irq.h:

/*
* Please do not include this file in generic code. There is currently
* no requirement for any architecture to implement anything held
* within this file.
*
* Thanks. --rmk
*/

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#8 lore raw
In reply to Simon Horman
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Wed, 05 Apr 2023 19:29:48 +0200 you wrote:

A recent rearrangement of includes has lead to a problem on m68k as flagged by the kernel test robot.

Resolve this by moving the block asm includes to below linux includes. A side effect i that non-Sparc asm includes are now immediately before Sparc asm includes, which seems nice.

[...]

Here is the summary with links:
- [net-next] net: sunhme: move asm includes to below linux includes

    https://git.kernel.org/netdev/net-next/c/f8b648bf6628

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html