2013-04-10 09:20:37

by Eugene Krasnikov

[permalink] [raw]
Subject: include/linux/device.h:715:38: error: 'THIS_MODULE' undeclared

Hi All,

I have tried to build latest compat-drivers for android/cyanogenmod
kernel version 3.0.60 but it fails with the following error:

/cyanogenmod/kernel/sony/msm8x60/include/linux/device.h: In function
'root_device_register':
/cyanogenmod/kernel/sony/msm8x60/include/linux/device.h:715:38: error:
'THIS_MODULE' undeclared (first use in this function)

Command line that is used to build compat-drivers is:

make KLIB=/cyanogenmod/out/target/product/mint/obj/KERNEL_OBJ
KLIB_BUILD=/cyanogenmod/out/target/product/mint/obj/KERNEL_OBJ
ARCH=arm CROSS_COMPILE=/cyanogenmod/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-

Did anybody meet such an error?
Patch bellow was used as a workaround to this error, but i would like
to find a proper solution.

>From c059e8b803550c7b76cc102d6c1fb1d8a0fa6fa9 Mon Sep 17 00:00:00 2001
From: Eugene Krasnikov <[email protected]>
Date: Tue, 9 Apr 2013 18:28:38 +0200
Subject: [PATCH] Use export.h from CM location

Signed-off-by: Eugene Krasnikov <[email protected]>
---
include/linux/compat-2.6.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h
index 1e9effb..47f7434 100644
--- a/include/linux/compat-2.6.h
+++ b/include/linux/compat-2.6.h
@@ -43,6 +43,7 @@ void backport_dependency_symbol(void);
* Each compat file represents compatibility code for new kernel
* code introduced for *that* kernel revision.
*/
+#include </cyanogenmod/kernel/sony/msm8x60/include/linux/export.h>

#include <linux/compat-2.6.22.h>
#include <linux/compat-2.6.23.h>
--
1.7.10


--
Best regards,
Eugene


2013-04-10 14:21:58

by Eugene Krasnikov

[permalink] [raw]
Subject: Re: include/linux/device.h:715:38: error: 'THIS_MODULE' undeclared

Thanx for reply. That also works.
But is it a solution or workaround? May be there should be smarter
check than just a kernel version?

2013/4/10 Szymon Janc <[email protected]>:
> On Wednesday 10 of April 2013 12:20:37 Eugene Krasnikov wrote:
> Hi Eugene,
>
>> I have tried to build latest compat-drivers for android/cyanogenmod
>> kernel version 3.0.60 but it fails with the following error:
>>
>> /cyanogenmod/kernel/sony/msm8x60/include/linux/device.h: In function
>> 'root_device_register':
>> /cyanogenmod/kernel/sony/msm8x60/include/linux/device.h:715:38: error:
>> 'THIS_MODULE' undeclared (first use in this function)
>>
>> Command line that is used to build compat-drivers is:
>>
>> make KLIB=/cyanogenmod/out/target/product/mint/obj/KERNEL_OBJ
>> KLIB_BUILD=/cyanogenmod/out/target/product/mint/obj/KERNEL_OBJ
>> ARCH=arm CROSS_COMPILE=/cyanogenmod/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
>>
>> Did anybody meet such an error?
>> Patch bellow was used as a workaround to this error, but i would like
>> to find a proper solution.
>
> I had similar issue with grouper (nexus7) 3.1 kernel. This was due to DMA_BUF
> stuff being backported to that kernel (and that pulled also export.h change).
> Maybe it is same with CM kernel?
>
> This fixed build for me:
> ---
> include/linux/export.h | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/export.h b/include/linux/export.h
> index f7842b7..5ef58c5 100644
> --- a/include/linux/export.h
> +++ b/include/linux/export.h
> @@ -3,10 +3,10 @@
>
> #include <linux/version.h>
>
> -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
> +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
> #include_next <linux/export.h>
> #else
> #include <linux/module.h>
> -#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */
> +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) */
>
> #endif /* _COMPAT_LINUX_EXPORT_H */
>
>
> You can check if enabling this for kernel >=3.0.0 works for you:)
>
> --
> BR
> Szymon Janc



--
Best regards,
Eugene

2013-04-11 09:17:20

by Szymon Janc

[permalink] [raw]
Subject: Re: include/linux/device.h:715:38: error: 'THIS_MODULE' undeclared

On Wednesday 10 of April 2013 17:21:57 Eugene Krasnikov wrote:

Hi,

> Thanx for reply. That also works.
> But is it a solution or workaround? May be there should be smarter
> check than just a kernel version?

Note that android kernel is not vanilla kernel.

If you have custom kernel (e.g android kernel) with extra features backported
you need to enable support for those features in compat-drivers for
your kernel i.e. mark it as applicable for lower kernel version (comparing to
vanilla kernel which introduced this feature)

The 'proper' solution would be to have support for Android (or CM) kernel in
compat-drivers (same as eg. RH kernel would). But Android kernels varies
heavily among devices and it could be hard to support all of them. It is also
worth noting that often custom non-mainlined code doesn't even build when
configured as module e.g. bluesleep driver from grouper kernel. This is extra
obstacle as one would have to fix or disable such offending code.

--
BR
Szymon Janc

2013-04-10 11:56:59

by Szymon Janc

[permalink] [raw]
Subject: Re: include/linux/device.h:715:38: error: 'THIS_MODULE' undeclared

On Wednesday 10 of April 2013 12:20:37 Eugene Krasnikov wrote:
Hi Eugene,

> I have tried to build latest compat-drivers for android/cyanogenmod
> kernel version 3.0.60 but it fails with the following error:
>
> /cyanogenmod/kernel/sony/msm8x60/include/linux/device.h: In function
> 'root_device_register':
> /cyanogenmod/kernel/sony/msm8x60/include/linux/device.h:715:38: error:
> 'THIS_MODULE' undeclared (first use in this function)
>
> Command line that is used to build compat-drivers is:
>
> make KLIB=/cyanogenmod/out/target/product/mint/obj/KERNEL_OBJ
> KLIB_BUILD=/cyanogenmod/out/target/product/mint/obj/KERNEL_OBJ
> ARCH=arm CROSS_COMPILE=/cyanogenmod/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
>
> Did anybody meet such an error?
> Patch bellow was used as a workaround to this error, but i would like
> to find a proper solution.

I had similar issue with grouper (nexus7) 3.1 kernel. This was due to DMA_BUF
stuff being backported to that kernel (and that pulled also export.h change).
Maybe it is same with CM kernel?

This fixed build for me:
---
include/linux/export.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/export.h b/include/linux/export.h
index f7842b7..5ef58c5 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -3,10 +3,10 @@

#include <linux/version.h>

-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
#include_next <linux/export.h>
#else
#include <linux/module.h>
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) */

#endif /* _COMPAT_LINUX_EXPORT_H */


You can check if enabling this for kernel >=3.0.0 works for you:)

--
BR
Szymon Janc