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.

E AndroidRuntime: java.lang.RuntimeException: Unable to create service com.android.systemui.keyguard.KeyguardService

Oh boy! I finally got AOKP to boot up in an Engineering build for the XA2 Ultra (discovery). However, once you get through the setup pages, it crashes at the home screen. Here’s the logcat output:

——— beginning of crash
08-21 04:12:30.094 3050 3050 E AndroidRuntime: FATAL EXCEPTION: main
08-21 04:12:30.094 3050 3050 E AndroidRuntime: Process: com.android.systemui, PID: 3050
08-21 04:12:30.094 3050 3050 E AndroidRuntime: java.lang.RuntimeException: Unable to create service com.android.systemui.keyguard.KeyguardService: java.lang.NullPointerException: Attempt to invoke interface method ‘android.service.gesture.IEdgeGestureHostCallback android.service.gesture.IEdgeGestureService.registerEdgeGestureActivationListener(android.service.gesture.IEdgeGestureActivationListener)’ on a null object reference
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:3582)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.app.ActivityThread.access$1300(ActivityThread.java:200)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1672)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6718)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke interface method ‘android.service.gesture.IEdgeGestureHostCallback android.service.gesture.IEdgeGestureService.registerEdgeGestureActivationListener(android.service.gesture.IEdgeGestureActivationListener)’ on a null object reference
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.service.gesture.EdgeGestureManager.setEdgeGestureActivationListener(EdgeGestureManager.java:178)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.statusbar.pie.PieController.init(PieController.java:126)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.statusbar.phone.StatusBar.updatePieControls(StatusBar.java:6201)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.statusbar.phone.StatusBar$19.onChange(StatusBar.java:5464)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.statusbar.phone.StatusBar.start(StatusBar.java:886)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.SystemBars.createStatusBarFromConfig(SystemBars.java:71)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.SystemBars.start(SystemBars.java:42)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.SystemUIApplication.startServicesIfNeeded(SystemUIApplication.java:185)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.SystemUIApplication.startServicesIfNeeded(SystemUIApplication.java:129)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at com.android.systemui.keyguard.KeyguardService.onCreate(KeyguardService.java:48)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:3570)
08-21 04:12:30.094 3050 3050 E AndroidRuntime: … 8 more
08-21 04:12:30.100 1445 1478 V RescueParty: Disabled because of eng build

There is a lot in there, but here is the important part:

Caused by: java.lang.NullPointerException: Attempt to invoke interface method ‘android.service.gesture.IEdgeGestureHostCallback android.service.gesture.IEdgeGestureService.registerEdgeGestureActivationListener(android.service.gesture.IEdgeGestureActivationListener)’ on a null object reference

08-21 04:12:30.094 3050 3050 E AndroidRuntime: at android.service.gesture.EdgeGestureManager.setEdgeGestureActivationListener(EdgeGestureManager.java:178)

So, I took a look at EdgeGestureManager.java, around line 178, which is reportedly the problem:

public boolean setEdgeGestureActivationListener(EdgeGestureActivationListener listener) {
if (DEBUG) {
Slog.d(TAG, “Set edge gesture activation listener”);
}
try {
IEdgeGestureHostCallback callback = mPs.registerEdgeGestureActivationListener(listener.mDelegator);
listener.setHostCallback(callback);
return true;
} catch (RemoteException e) {
Slog.e(TAG, “Failed to set edge gesture activation listener: ” + e.getMessage());
return false;
}
}

I took a look at Lineage and RR, and ended up adding new code to my files to fix it. Here’s what I put in, based on what I saw in the other working ROMs:

public void updateEdgeGestureActivationListener(EdgeGestureActivationListener listener, int positions) {
if (DEBUG) {
Slog.d(TAG, “Update edge gesture activation listener: 0x” + Integer.toHexString(positions));
}
if (mPs == null) {
Slog.e(TAG, “Failed to update edge gesture activation listener: Service not present”);
return;
}
try {
mPs.updateEdgeGestureActivationListener(listener.mDelegator.asBinder(), positions);
} catch (RemoteException e) {
Slog.e(TAG, “Failed to update edge gesture activation listener: ” + e.getMessage());
}
}

So now it will check if it is “null” or empty before trying to use it. If it is empty, it exits rather than crashing because it is empty. If it’s not empty, it will use it instead. Praise God! This even worked! After fixing this last piece of the puzzle, AOKP Pie finally booted and worked on my XA2 Ultra!

Linux – keep it simple.

system/bt/stack/btu/btu_hcif.cc:729:22: error: no member named ‘BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED’ in namespace ‘android::util’

Several Bluetooth issues were really giving me the run around while trying to compile AOKP for the Xperia XA2 Ultra. Let’s take a look:

system/bt/stack/btu/btu_hcif.cc:729:22: error: no member named ‘BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED’ in namespace ‘android::util’
android::util::BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED, “”, handle,
~~~~~~~~~~~~~~~^
system/bt/stack/btu/btu_hcif.cc:1698:22: error: no member named ‘BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED’ in namespace ‘android::util’
android::util::BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED, “”, handle,
~~~~~~~~~~~~~~~^
2 errors generated.

I made several changes to the system/bt/stack/btu/btu_hcif.cc file:

Changed: Line 729
static void read_encryption_key_size_complete_after_encryption_change(
uint8_t status, uint16_t handle, uint8_t key_size) {
int ret = 0;
//WJH int ret = android::util::stats_write(
//WJH android::util::BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED, “”, handle,
//WJH HCI_READ_ENCR_KEY_SIZE, HCI_COMMAND_COMPLETE_EVT, status, 0, key_size);
if (ret < 0) {
LOG(WARNING) << __func__ << “: failed to log encryption key size ”
<< std::to_string(key_size);
}

changed line 1698
static void read_encryption_key_size_complete_after_key_refresh(
uint8_t status, uint16_t handle, uint8_t key_size) {
int ret = 0;
//WJH int ret = android::util::stats_write(
//WJH android::util::BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED, “”, handle,
//WJH HCI_READ_ENCR_KEY_SIZE, HCI_COMMAND_COMPLETE_EVT, status, 0, key_size);
if (ret < 0) {
LOG(WARNING) << __func__ << “: failed to log encryption key size ”
<< std::to_string(key_size);
}

At first I was really worried about the outcome of these changes, but the Bluetooth still seems to work properly in all my tests. So I’m not sure what it is that I “removed”. Hopefully it’s nothing important, but it does beg the question: when are we cutting something out that we actually need? How do we know when we get there?

This did “fix” the issue during compile, and since the Bluetooth works, I’m going to go with it is okay…..

Linux – keep it simple.

error: vendor/qcom/opensource/cryptfs_hw/Android.bp:27:37: unrecognized property “product_variables.lineage.uses_metadata_as_fde_key”

Another random error while compiling AOKP pie for the XA2 Ultra. These calls work properly when compiling Lineage, but don’t work in the AOKP source tree, so I did some digging.

error: vendor/qcom/opensource/cryptfs_hw/Android.bp:27:37: unrecognized property “product_variables.lineage.uses_metadata_as_fde_key”

In the end, I found that the only way around it was to remove the unrecognized property, since this isn’t LineageOS, it isn’t declared anywhere in AOKP. So, I edited vendor/qcom/opensource/cryptfs_hw/Android.bp at line 27, like so:

//WJH uses_metadata_as_fde_key: {
//WJH cflags: [“-DUSE_METADATA_FOR_KEY”],
//WJH },

By commenting them out, they are basically deleted. This seemed to work well, and so far, hasn’t hampered any of the rom functions.

Linux – keep it simple.

system.com/vold/Ext4Crypt.cpp:204:12: error: use of undeclared identifier ‘fs_mgr_is_wrapped_key_supported’

Another strange set of errors while compiling AOKP. It seems like they are in the middle of merging some Lineage commits, but didn’t finish them. Either way, I ran into this problem with Ext3Crypt:

compile system.com/vold/Ext4Crypt.cpp:204:12: error: use of undeclared identifier ‘fs_mgr_is_wrapped_key_supported’

So, I took a look at line 204 from system.com/vold/Ext4Crypt.cpp, and this is what I saw:

bool is_wrapped_key_supported() {
return fs_mgr_is_wrapped_key_supported(
fs_mgr_get_entry_for_mount_point(fstab_default, DATA_MNT_POINT));
}

This didn’t make sense to me, since the call is for a bool, the answer must be true or false, zero or one. Instead it is trying to grab some information and determine if it is true or false based on that. I spent hours trying to crack down on it, but I couldn’t find how this all washed out. In the end, I made this edit to get through this error:

bool is_wrapped_key_supported() {
//return fs_mgr_is_wrapped_key_supported(
// fs_mgr_get_entry_for_mount_point(fstab_default, DATA_MNT_POINT)); //WJH
return false; //WJH
}

Essentially, I returned false. I debated about what to return, but I don’t want it to use it, since I can’t correctly fix it, so I decided false was my best bet. Sure enough, that worked.

Linux – keep it simple.