title: Kernel compiling errors with every modification
body: <p>Whenever I try to work with kernel source (be it upstream to higher Linux stable version, adding features, etc.), it fails on random source files when compiling.</p>
  
  <p>For example, I tried to upstream kernel version from v3.18.110 to 3.18.125 (with one version at a time, of course). I successfully resolved all conflicts which appeared, but when I start building the kernel, the compiler finds error in file which wasn't even in the conflicting files. Solving the error which appears will introduce more errors, either in the same file or in other file.</p>
  
  <p>Other thing I tried is adding a governor. I successfully added the code where it is needed, added the original governor source file, then enabled it in default config and then started compiling. After this, the compiler found some error in the .c file of the governor. Why?</p>
  
  <p>I'm not asking for error resolution, I want to know why errors happen in the first place.</p>
  
  <p>Architecture is arm64, toolchain is:
  <a href="https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9" rel="nofollow noreferrer">https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9</a></p>
  
  <p>Example:
  I'm trying to add governor by editing these files:</p>
  
  <blockquote>
    <p>drivers/cpufreq/Kconfig</p>
    
    <p>drivers/cpufreq/Makefile</p>
    
    <p>include/linux/cpufreq.h</p>
  </blockquote>
  
  <p><strong>Kconfig:</strong></p>
  
  <pre><code>config CPU_FREQ_DEFAULT_GOV_SMARTMAX
  bool "smartmax"
  select CPU_FREQ_GOV_SMARTMAX
  help
    Use the CPUFreq governor 'smartmax' as default
  
  config CPU_FREQ_GOV_SMARTMAX
   tristate "'smartmax' cpufreq policy governor"  
   select CPU_FREQ_TABLE  
   help   
     'smartmax' combined ondemand and smartass2
  </code></pre>
  
  <p><strong>Makefile:</strong></p>
  
  <pre><code>obj-$(CONFIG_CPU_FREQ_GOV_SMARTMAX) += cpufreq_smartmax.o
  </code></pre>
  
  <p><strong>cpufreq.h:</strong></p>
  
  <pre><code>#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_SMARTMAX)
  extern struct cpufreq_governor cpufreq_gov_smartmax;
  #define CPUFREQ_DEFAULT_GOVERNOR    (&amp;cpufreq_gov_smartmax)
  </code></pre>
  
  <p>After that I add the .c file of the governor (which is unmodified and completely original governor code), then add this in default config for my device:</p>
  
  <pre><code>CONFIG_CPU_FREQ_GOV_SMARTMAX=y
  </code></pre>
  
  <p>Then I go to toolchain folder, open terminal and type this:</p>
  
  <pre><code>export CROSS_COMPILE=$(pwd)/bin/aarch64-linux-android-
  export ARCH=arm64 &amp;&amp; export SUBARCH=arm64
  </code></pre>
  
  <p>After this I go to kernel folder and use the following commands:</p>
  
  <pre><code>make clean
  make mrproper
  make *my_device_config_name*
  make -s -j$(nproc --all)
  </code></pre>
  
  <p>Doing all of this results in the following errors in the governor code:</p>
  
  <blockquote>
    <p>drivers/cpufreq/cpufreq_smartmax.c: In function 'cpufreq_smartmax_timer':
    drivers/cpufreq/cpufreq_smartmax.c:522:3: error: implicit declaration of function '__cpufreq_driver_getavg' [-Werror=implicit-function-declaration]
       freq_avg = __cpufreq_driver_getavg(policy, j);</p>
    
    <p>drivers/cpufreq/cpufreq_smartmax.c: In function 'store_debug_mask':
    drivers/cpufreq/cpufreq_smartmax.c:607:2: error: implicit declaration of function 'strict_strtoul' [-Werror=implicit-function-declaration]
      res = strict_strtoul(buf, 0, &amp;input);</p>
  </blockquote>