error: implicit declaration of function ‘INIT_DELAYED_WORK_DEFERRABLE’

While working on the nightmare governor for the Xperia XA2 Ultra (sdm660), I ran into this error:

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_nightmare.c:714:3: error: implicit declaration of function ‘INIT_DELAYED_WORK_DEFERRABLE’ [-Werror,-Wimplicit-function-declaration]
INIT_DELAYED_WORK_DEFERRABLE(&this_nightmare_cpuinfo->work, do_nightmare_timer);
^
/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_nightmare.c:714:3: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
2 errors generated.

On that line, I saw this:

INIT_DELAYED_WORK_DEFERRABLE(&this_nightmare_cpuinfo->work, do_nightmare_timer);

So I did a little digging, and found a great Linux resource site: https://elixir.bootlin.com

What makes it so great, is you can search each version of the kernel (back to 2.6.11) up to the latest version, and search for any term in them. A quick perusal found this term was used up to the 2.6.39 kernel in the include/linux/workque.h file. It goes like this:

#define INIT_DELAYED_WORK(_work, _func)				\
	do {							\
		INIT_WORK(&(_work)->work, (_func));		\
		init_timer(&(_work)->timer);			\
	} while (0)

#define INIT_DELAYED_WORK_ONSTACK(_work, _func)			\
	do {							\
		INIT_WORK_ONSTACK(&(_work)->work, (_func));	\
		init_timer_on_stack(&(_work)->timer);		\
	} while (0)

#define INIT_DELAYED_WORK_DEFERRABLE(_work, _func)		\
	do {							\
		INIT_WORK(&(_work)->work, (_func));		\
		init_timer_deferrable(&(_work)->timer);		\
	} while (0)

But it was later changed to be like this in 4.4:

#define INIT_DELAYED_WORK(_work, _func)					\
	__INIT_DELAYED_WORK(_work, _func, 0)

#define INIT_DELAYED_WORK_ONSTACK(_work, _func)				\
	__INIT_DELAYED_WORK_ONSTACK(_work, _func, 0)

#define INIT_DEFERRABLE_WORK(_work, _func)				\
	__INIT_DELAYED_WORK(_work, _func, TIMER_DEFERRABLE)

#define INIT_DEFERRABLE_WORK_ONSTACK(_work, _func)			\
	__INIT_DELAYED_WORK_ONSTACK(_work, _func, TIMER_DEFERRABLE)

So, I edited the gov like by changing to the newer definition which seems to do the same thing:

INIT_DELAYED_WORK_ONSTACK(&this_nightmare_cpuinfo->work, do_nightmare_timer);

And, praise God! It even worked! I love it when you can find good, helpful resources out there. I know I’ve bookmarked elixir! I’ll be using that reference again!

Linux – keep it simple.

Advertisements

error: implicit declaration of function ‘cputime64_sub’ [-Werror,-Wimplicit-function-declaration]

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.

error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes] MODULE_LICENSE(“GPL”);

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.

So here is a funny one. Since I was updating a few governors for a newer kernel, one of the things that must have been previously declared somewhere was to include the “module.h” file that allows modules to have tags. These tags are benign, and are only for reference, since they just state text such as the version number or the license type or title of the module.

However, it will stop your compiler dead in it’s tracks if you run into this, just like it did for me. Here’s a few examples:

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_brazilianwax.c:826:16: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
MODULE_LICENSE (“GPL”);

 

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_smartass.c:751:15: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
MODULE_AUTHOR (“Erasmux”);

 

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_interactivex.c:768:15: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
MODULE_LICENSE(“GPL”);

It’s easy to fix, though, since all you have to do is include the modules.h file, like so:

#include <linux/module.h>

Just put it with the other includes at the beginning of the file, and you should be good to go.

Linux – keep it simple.

error: use of undeclared identifier ‘pm_idle’

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.

Another error that I’ve had pop up numerous times is this whole “pm_idle” issue:

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_asswax.c:765:4: error: use of undeclared identifier ‘pm_idle’
pm_idle = pm_idle_old;

 

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_brazilianwax.c:712:39: error: use of undeclared identifier ‘pm_idle’
pm_idle_old = pm_idle;

 

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_smartass.c:602:18: error: use of undeclared identifier ‘pm_idle’
pm_idle_old = pm_idle;

 

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_smartass2.c error: use of undeclared identifier ‘pm_idle’
pm_idle_old = pm_idle;

It appears that somewhere in the older kernel, “pm_idle” was declared somewhere, but it no longer is declared in the newer 4.4 kernel. So, I just declared it in each governor by adding these lines at the beginning:

static void (*pm_idle)(void); // WJH

Now that it is declared (statically, so it stays here), it can be used in the formulas to calculate the needed values for adjusting the CPU frequencies. I’m honestly not sure that this was the best fix, but it certainly did work and now the compiling finished and the governors did function. At least, as far as I could tell….

Linux – keep it simple.

field designator ‘suspend’ does not refer to any field in type ‘struct early_suspend’

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.

I received a series of errors while compiling, complaining about early suspend. Here are some examples:

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_smartass2.c: undefined reference to `register_early_suspend’

 

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_smartass.c:739: undefined reference to `register_early_suspend’

 

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_interactivex.c:641: undefined reference to `register_early_suspend’
/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_interactivex.c:670: undefined reference to `unregister_early_suspend’

 

field designator ‘suspend’ does not refer to any field in type ‘struct early_suspend’

All of these errors came after I had received an error about the compiler being unable to find linux/early_suspend.h. So I downloaded that file from the internet and put it in the include directory, only to realize that I needed the c file as well! Again, I downloaded the c file and put it in, only to find that the header and code file didn’t match. They were from different kernels and didn’t match up. Anyhow, once I found the most up to date version of the file, then I could actually use it! Here’s my commit if you want to check it out.

Either way, if you run into a similar message, make sure you have set “CONFIG_HAS_EARLYSUSPEND=Y” in your defconfig, or when you compile your kernel, it wont actually get turned on or built!

Linux – keep it simple.

cpufreq_interactivex.c:239:9: error: implicit declaration of function ‘strict_strtoul’ [-Werror,-Wimplicit-function-declaration]

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, specific to this post, is the interactiveX governor.

That’s when I ran into this error:

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_interactivex.c:239:9: error: implicit declaration of function ‘strict_strtoul’ [-Werror,-Wimplicit-function-declaration]
return strict_strtoul(buf, 0, &min_sample_time);

It took me a while to find an answer for it, but once I did, I saw it over and over again as I added more govs to the kernel:

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_brazilianwax.c:406:15: error: implicit declaration of function ‘strict_strtoul’ [-Werror,-Wimplicit-function-declaration]
res = strict_strtoul(buf, 0, &input);

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_skywalker.c:723:5: error: implicit declaration of function ‘strict_strtoul’ [-Werror,-Wimplicit-function-declaration]
if(strict_strtoul(buf, 0, &inc_cpu_load)==-EINVAL) return -EINVAL;

 

/home/alaskalinuxuser/aokp_pie/kernel/sony/sdm660/drivers/cpufreq/cpufreq_smartass2.c: error: implicit declaration of function ‘strict_strtoul’ [-Werror,-Wimplicit-function-declaration]
if(strict_strtoul(buf, 0, &inc_cpu_load)==-EINVAL) return -EINVAL;

 

etc…..

With about half of the governors that I added, this error popped up, mainly because I was taking the govs from an older 3.10 kernel and trying to apply them to a 4.4 kernel. That’s a pretty big jump, and several parts of the code gave me interesting errors to hunt down, but this one was so simple to fix, just hard to find. I can’t take the credit, though, since I found this thread where a guy had a similar issue and fixed it.

According to Vasiliy Tolstov:

strict_strtoul() was just a redefinition of kstrtoul() for a long
time. From kernel version of 3.18, strict_strtoul() will not be
defined at all. A compile time kernel version check is needed to
decide which function or macro can be used for a specific version of
kernel.

Fortunately, the fix was pretty simple. Using gedit, I replaced every instance of “strict_strtoul” with “kstrtoul” in each of these governors. After that, the error not only went away, but the govs actually worked!

Linux – keep it simple.

BLOX2: KCAL – Sovoca’s Color Calibration

This is my OnePlus One with my KPPD control app.

Another update to the BLOX2 (BLU Life One X2) kernel, I just added Sovoca’s KCAL color calibration for the screen! You can check out the commit on GitLab, but unfortunately, while it builds without error, it doesn’t function quite right. I am looking into the commits further and considering KPPD as well. It’s all part of my video series for modifying 64 bit kernels, which you can check out on my YouTube channel: https://www.youtube.com/channel/UCnGqG_jyyXmTzdamBpKfeHA

Linux – keep it simple.

BLOX2: Voltage Control for the Little Cores!

littlecores

Another update to the BLOX2 (BLU Life One X2) kernel, I just extended the voltage control from the big cores to the little cores as well! You can check out the commit on GitLab, but essentially we saw that the “bc” in the code stood for “big cores” and we made a duplicate of the code, labeled “lc” for “little cores”. It’s all part of my video series for modifying 64 bit kernels, which you can check out on my YouTube channel: https://www.youtube.com/channel/UCnGqG_jyyXmTzdamBpKfeHA

Linux – keep it simple.

BLOX2: “Wakey, Wakey, Mouse!”

sleep2wake

That quote is from one of my son’s favorite books, “Max the Brave”!

Another update to the BLOX2 (BLU Life One X2) kernel, I just added Sweep2Wake and DoubleTap2Wake! You can check out the commit on GitLab, but my phone’s screen and proximity sensor are smashed, so I’m not sure it all works properly. It’s all part of my video series for modifying 64 bit kernels, which you can check out on my YouTube channel: https://www.youtube.com/channel/UCnGqG_jyyXmTzdamBpKfeHA

Linux – keep it simple.

BLOX2: Voltage Control for the CPU!

cpuvolt

Another update to the BLOX2 (BLU Life One X2) kernel, I just added the ability to adjust the voltage of the CPU on the fly! You can check out the commit on GitLab, but it currently only controls the voltage on the “big” 4 CPU’s, not on the “small” 4 CPU’s. It’s all part of my video series for modifying 64 bit kernels, which you can check out on my YouTube channel: https://www.youtube.com/channel/UCnGqG_jyyXmTzdamBpKfeHA

Linux – keep it simple.