Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

内核5.7.7编译报错 #207

Closed
zhengbucuo opened this issue Nov 3, 2020 · 0 comments
Closed

内核5.7.7编译报错 #207

zhengbucuo opened this issue Nov 3, 2020 · 0 comments

Comments

@zhengbucuo
Copy link

zhengbucuo commented Nov 3, 2020

   ~/bbswitch  on   master  make  ✔  at 05:45:39 下午 
make -C /lib/modules/5.7.7-amd64-desktop/build M="$(pwd)" modules
make[1]: 进入目录“/usr/src/linux-headers-5.7.7-amd64-desktop”
CC [M] /home/xiaoxi/bbswitch/bbswitch.o
/home/xiaoxi/bbswitch/bbswitch.c: In function ‘bbswitch_init’:
/home/xiaoxi/bbswitch/bbswitch.c:460:18: error: implicit declaration of function ‘proc_create’; did you mean ‘vfs_create’? [-Werror=implicit-function-declaration]
acpi_entry = proc_create("bbswitch", 0664, acpi_root_dir, &bbswitch_fops);
^~~~~~~~~~~
vfs_create
/home/xiaoxi/bbswitch/bbswitch.c:460:16: warning: assignment to ‘struct proc_dir_entry *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
acpi_entry = proc_create("bbswitch", 0664, acpi_root_dir, &bbswitch_fops);
^
/home/xiaoxi/bbswitch/bbswitch.c: In function ‘bbswitch_exit’:
/home/xiaoxi/bbswitch/bbswitch.c:490:5: error: implicit declaration of function ‘remove_proc_entry’; did you mean ‘remove_memory’? [-Werror=implicit-function-declaration]
remove_proc_entry("bbswitch", acpi_root_dir);
^~~~~~~~~~~~~~~~~
remove_memory
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:267:/home/xiaoxi/bbswitch/bbswitch.o] 错误 1
make[1]: *** [Makefile:1732:/home/xiaoxi/bbswitch] 错误 2
make[1]: 离开目录“/usr/src/linux-headers-5.7.7-amd64-desktop”
make: *** [Makefile:13:default] 错误 2
   ~/bbswitch  on   master ?1 


解决办法:
#198 #196

diff --git a/bbswitch.c b/bbswitch.c
index 341608f..c81769d 100644
--- a/bbswitch.c
+++ b/bbswitch.c
@@ -35,6 +35,10 @@
 #include <linux/suspend.h>
 #include <linux/seq_file.h>
 #include <linux/pm_runtime.h>
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
+#include <linux/proc_fs.h>
+#endif
 
 #define BBSWITCH_VERSION "0.8"
 
@@ -375,6 +379,15 @@ static int bbswitch_pm_handler(struct notifier_block *nbp,
     return 0;
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
+static struct proc_ops bbswitch_fops = {
+    .proc_open   = bbswitch_proc_open,
+    .proc_read   = seq_read,
+    .proc_write  = bbswitch_proc_write,
+    .proc_lseek = seq_lseek,
+    .proc_release= single_release
+};
+#else
 static struct file_operations bbswitch_fops = {
     .open   = bbswitch_proc_open,
     .read   = seq_read,
@@ -382,6 +395,7 @@ static struct file_operations bbswitch_fops = {
     .llseek = seq_lseek,
     .release= single_release
 };
+#endif
 
 static struct notifier_block nb = {
     .notifier_call = &bbswitch_pm_handler
(END)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant