OSDN Git Service

tp_smapi/hdaps: use timer_setup() with kernel 4.15 and later marshmallow-x86
authorMauro Rossi <issor.oruam@gmail.com>
Wed, 29 Nov 2017 00:04:17 +0000 (01:04 +0100)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 7 Dec 2018 08:47:54 +0000 (16:47 +0800)
Fixes the following building error happening with kernel 4.15:

  CC [M]  .../out/target/product/x86/obj/kmodule/tp_smapi/hdaps.o
.../out/target/product/x86/obj/kmodule/tp_smapi/hdaps.c: In function 'hdaps_init':
.../out/target/product/x86/obj/kmodule/tp_smapi/hdaps.c:782:2:
error: implicit declaration of function 'init_timer' [-Werror=implicit-function-declaration]
  init_timer(&hdaps_timer);
  ^
.../out/target/product/x86/obj/kmodule/tp_smapi/hdaps.c:783:23:
warning: assignment from incompatible pointer type
  hdaps_timer.function = hdaps_mousedev_poll;
                       ^
cc1: some warnings being treated as errors

tp_smapi/hdaps.c

index f54099a..338f551 100644 (file)
@@ -779,8 +779,12 @@ static int __init hdaps_init(void)
                        hdaps_invert = 0; /* default */
 
        /* Init timer before platform_driver_register, in case of suspend */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
+       timer_setup(&hdaps_timer, hdaps_mousedev_poll, 0);
+#else
        init_timer(&hdaps_timer);
        hdaps_timer.function = hdaps_mousedev_poll;
+#endif
        ret = platform_driver_register(&hdaps_driver);
        if (ret)
                goto out;