Skip to contentSkip to conversation

drivers/cpufreq: delete non-required instances of include <linux/init.h>

PATCH In review Paul Gortmaker 2 participants 5 messages Jan 9, 2014

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

PATCH 1/1 drivers/cpufreq: delete non-required instances of include <linux/init.h>

None of these files are actually using any __init type directives and hence don't need to include <linux/init.h>. Most are just a left over from __devinit and __cpuinit removal, or simply due to code getting copied from one driver to the next.

---
 drivers/cpufreq/omap-cpufreq.c    | 1 -
 drivers/cpufreq/powernow-k8.c     | 1 -
 drivers/cpufreq/s3c2412-cpufreq.c | 1 -
 drivers/cpufreq/s3c2440-cpufreq.c | 1 -
 drivers/cpufreq/spear-cpufreq.c   | 1 -
 drivers/cpufreq/speedstep-lib.c   | 1 -
 6 files changed, 6 deletions(-)
drivers/cpufreq/omap-cpufreq.c +0 -1
index a0acd0bfba40..ba2fcad17941 100644
@@ -18,7 +18,6 @@
 #include <linux/sched.h>
 #include <linux/cpufreq.h>
 #include <linux/delay.h>
-#include <linux/init.h>
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
drivers/cpufreq/powernow-k8.c +0 -1
index 0023c7d40a51..4b85ecbc81b1 100644
@@ -30,7 +30,6 @@
 #include <linux/kernel.h>
 #include <linux/smp.h>
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/cpufreq.h>
 #include <linux/slab.h>
 #include <linux/string.h>
drivers/cpufreq/s3c2412-cpufreq.c +0 -1
index 4645b4898996..8f42bacbe21b 100644
@@ -10,7 +10,6 @@
  * published by the Free Software Foundation.
 */
 
-#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
drivers/cpufreq/s3c2440-cpufreq.c +0 -1
index 72b2cc8a5a85..91d6efb92feb 100644
@@ -11,7 +11,6 @@
  * published by the Free Software Foundation.
 */
 
-#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
drivers/cpufreq/spear-cpufreq.c +0 -1
index d02ccd19c9c4..8bdd46905c4c 100644
@@ -16,7 +16,6 @@
 #include <linux/clk.h>
 #include <linux/cpufreq.h>
 #include <linux/err.h>
-#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
 #include <linux/slab.h>
drivers/cpufreq/speedstep-lib.c +0 -1
index 7047821a7f8a..1ef6fb65281b 100644
@@ -11,7 +11,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
-#include <linux/init.h>
 #include <linux/cpufreq.h>
 
 #include <asm/msr.h>
Signature · 1 line
1.8.5.2
maintainer
#1 lore raw
Quoted 4 lines · Paul Gortmaker

None of these files are actually using any __init type directives and hence don't need to include <linux/init.h>. Most are just a left over from __devinit and __cpuinit removal, or simply due to code getting copied from one driver to the next.

Are you sure? Its not only about devinit or cpuinit but module_init() and others as well. And they are pretty much used by most of them.

#2 lore raw
Quoted 9 lines · Viresh Kumar
Quoted 4 lines · Paul Gortmaker

None of these files are actually using any __init type directives and hence don't need to include <linux/init.h>. Most are just a left over from __devinit and __cpuinit removal, or simply due to code getting copied from one driver to the next.

Are you sure? Its not only about devinit or cpuinit but module_init() and others as well. And they are pretty much used by most of them.

Yes I am sure. I start with this:

-------------
#!/bin/bash

if [ "$1" = "" ]; then
echo must supply path name
exit 1
fi

for i in git grep -l linux/init.h $1 ; do

        grep -q '__ref\|__init\|__cpuinit\|__meminit\|__MEMINIT\|__CPUINIT\|__INIT\|__REF\|__HEAD' $i
        if [ $? != 0 ] ; then
                echo $i
                sed -i '/linux\/init.h/d' $i
        fi

done
--------------

which as you can see whitelists any real users, and then I follow up with build testing to double check. I will note that in this particular case, I couldn't find an ARM defconfig that actually enabled any CONFIG_ARM_S3C24xx options though.

Paul.

maintainer
#3 lore raw
Quoted 5 lines · Paul Gortmaker

Yes I am sure. I start with this:

-------------
#!/bin/bash

Quoted 7 lines

if [ "$1" = "" ]; then
echo must supply path name
exit 1
fi

for i in git grep -l linux/init.h $1 ; do

        grep -q '__ref\|__init\|__cpuinit\|__meminit\|__MEMINIT\|__CPUINIT\|__INIT\|__REF\|__HEAD' $i

You missed all initcalls here.

Quoted 9 lines
        if [ $? != 0 ] ; then
                echo $i
                sed -i '/linux\/init.h/d' $i
        fi

done
--------------

which as you can see whitelists any real users, and then I follow up with build testing to double check.

That might have passed because init.h is still included indirectly.

These are the usages which I can see easily, there might be others too..

drivers/cpufreq/powernow-k8.c: late_initcall and module_exit drivers/cpufreq/s3c2412-cpufreq.c: arch_initcall drivers/cpufreq/s3c2440-cpufreq.c: subsys_initcall drivers/cpufreq/spear-cpufreq.c: late_initcall

Quoted 3 lines

I will note that
in this particular case, I couldn't find an ARM defconfig that actually enabled any CONFIG_ARM_S3C24xx options though.

Haven't looked into this for now :(

#4 lore raw
In reply to Viresh Kumar
Quoted 9 lines · Viresh Kumar
Quoted 4 lines · Paul Gortmaker

None of these files are actually using any __init type directives and hence don't need to include <linux/init.h>. Most are just a left over from __devinit and __cpuinit removal, or simply due to code getting copied from one driver to the next.

Are you sure? Its not only about devinit or cpuinit but module_init() and others as well. And they are pretty much used by most of them.

Actually, module_init is an interesting point; we are implicitly getting init.h in module.h -- but (1) that should be explicit, and (2) module_init should/could really be in module.h and not stuck in init.h

I'll add that to my queue and do some testing.

Thanks for the comments,
Paul.