From f9b4963d4d670dcb912cc3ee749dc3addc6eb0b3 Mon Sep 17 00:00:00 2001 From: xizx Date: Sun, 9 May 2021 13:55:04 +0800 Subject: [PATCH] mmi_annotate: support build in kernel-5.10 build error: make[2]: Entering directory '/home/xizx/work/moto/8450/pine_20210507_08_userdebug/out/msm-waipio-waipio-gki/common' CC [M] /home/xizx/work/moto/8450/pine_20210507_08_userdebug/motorola/kernel/modules/drivers/mmi_annotate/mmi_annotate.o /home/xizx/work/moto/8450/pine_20210507_08_userdebug/motorola/kernel/modules/drivers/mmi_annotate/mmi_annotate.c:229:15: error: incompatible pointer types passing 'const struct file_operations *' to parameter of type 'const struct proc_ops *' [-Werror,-Wincompatible-pointer-types] 0444, NULL, &mmi_annotate_operations); ^~~~~~~~~~~~~~~~~~~~~~~~ /home/xizx/work/moto/8450/pine_20210507_08_userdebug/kernel_platform/common/include/linux/proc_fs.h:109:122: note: passing argument to parameter 'proc_ops' here struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct proc_ops *proc_ops); ^ 1 error generated. Change-Id: I6bc25e9e74cae7582862b83b29796538271e9406 Reviewed-on: https://gerrit.mot.com/1949924 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Xianshan Wang Reviewed-by: Guobin Zhang Submit-Approved: Jira Key --- drivers/mmi_annotate/Makefile | 14 +++++++++----- drivers/mmi_annotate/mmi_annotate.c | 14 +++++++++++++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/mmi_annotate/Makefile b/drivers/mmi_annotate/Makefile index 34b09dd815a7..bfbdc14740ef 100644 --- a/drivers/mmi_annotate/Makefile +++ b/drivers/mmi_annotate/Makefile @@ -1,10 +1,14 @@ -KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build +all: modules -all: - $(MAKE) -C $(KERNEL_SRC) M=$(shell pwd) modules $(KBUILD_OPTIONS) +modules: + $(MAKE) -C $(KERNEL_SRC) M=$(M) modules $(KBUILD_OPTIONS) modules_install: - $(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(shell pwd) modules_install + $(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(M) modules_install + +%: + $(MAKE) -C $(KERNEL_SRC) M=$(M) $@ $(KBUILD_OPTIONS) clean: - $(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean \ No newline at end of file + rm -f *.o *.ko *.mod.c *.mod.o *~ .*.cmd Module.symvers + rm -rf .tmp_versions diff --git a/drivers/mmi_annotate/mmi_annotate.c b/drivers/mmi_annotate/mmi_annotate.c index 9de3eb0ec459..dbc5589135a7 100644 --- a/drivers/mmi_annotate/mmi_annotate.c +++ b/drivers/mmi_annotate/mmi_annotate.c @@ -23,12 +23,14 @@ #include #include #include +#include +#if KERNEL_VERSION(5, 10, 0) > LINUX_VERSION_CODE #include +#endif #include #include #include #include -#include #define MAX_USER_STR 1024 #define DEFAULT_MEM_SIZE 4096 @@ -92,6 +94,15 @@ static ssize_t mmi_annotate_write(struct file *file, const char __user *buf, return count; } +#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE +static const struct proc_ops mmi_annotate_operations = { + .proc_open = mmi_annotate_open, + .proc_read = seq_read, + .proc_write = mmi_annotate_write, + .proc_lseek = seq_lseek, + .proc_release = single_release, +}; +#else static const struct file_operations mmi_annotate_operations = { .open = mmi_annotate_open, .read = seq_read, @@ -99,6 +110,7 @@ static const struct file_operations mmi_annotate_operations = { .llseek = seq_lseek, .release = single_release, }; +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) static void* mmi_annotate_ram_vmap(phys_addr_t start, size_t size)