You might be getting tired of these by now, but I really do use this website as my scratchpad, so I can jump back to something that I worked on before. I also hope that people who are searching for an error can find it here, possibly with an answer…. And today is no different. Another kernel compiling error….

Lately I’ve been going through the Xperia XA2 Ultra kernel (sdm660) and trying to add new features. Today I was adding in some governors, and several of them had the same underlying issues. Part of the problem was that I got the governors from a 3.10 kernel and put them into a 4.4 kernel, so understandably some things have changed.

This error popped up in a few of the governors that I was editing, here’s a few examples of the error code before the compiler would grind to a halt:

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_smartass.c:206:15: error: implicit declaration of function ‘cputime64_sub’ [-Werror,-Wimplicit-function-declaration]
delta_idle = cputime64_sub(now_idle, this_smartass->time_in_idle);

 

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_interactivex.c:141:29: error: implicit declaration of function ‘cputime64_sub’ [-Werror,-Wimplicit-function-declaration]
delta_idle = (unsigned int) cputime64_sub(now_idle, time_in_idle);

 

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_brazilianwax.c:217:22: error: implicit declaration of function ‘cputime64_sub’ [-Werror,-Wimplicit-function-declaration]
delta_idle = cputime64_sub(now_idle, this_brazilianwax->time_in_idle);

This was a bit odd. Inside of these governors, there were several adding and subtracting functions. This particular call wants to subtract the second item from the first item. Apparently, this function used to be hosted somewhere that these govs could draw from. So, since it was lacking, I added it in:

// WJH because it is not defined elsewhere
#ifndef cputime64_sub
#define cputime64_sub(__a, __b) ((__a) – (__b))
#endif

By adding the #ifndef tag, it will only add my local definition if it is not positively defined somewhere else first. This avoids any sort of conflict if the gov was later put into a kernel where it was defined for them. I like simple fixes!

Linux – keep it simple.

Leave a Reply

Your email address will not be published. Required fields are marked *