From fcf649a832c447b22f0ab73a721db1e3503ea2de Mon Sep 17 00:00:00 2001 From: ririyeye <200610237@qq.com> Date: Tue, 22 Oct 2024 17:44:23 +0800 Subject: [PATCH] fix linux-driver build err --- tests/projects/linux/driver/hello/src/add.c | 1 + tests/projects/linux/driver/hello/src/add.h | 2 ++ tests/projects/linux/driver/hello/src/hello.c | 7 +++---- tests/projects/linux/driver/hello_custom/src/add.c | 1 + tests/projects/linux/driver/hello_custom/src/add.h | 2 ++ tests/projects/linux/driver/hello_custom/src/hello.c | 8 +++----- tests/projects/linux/driver/hello_makefile/src/add.c | 1 + tests/projects/linux/driver/hello_makefile/src/add.h | 2 ++ tests/projects/linux/driver/hello_makefile/src/hello.c | 7 +++---- xmake/rules/platform/linux/driver/driver_modules.lua | 4 ++-- 10 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 tests/projects/linux/driver/hello/src/add.h create mode 100644 tests/projects/linux/driver/hello_custom/src/add.h create mode 100644 tests/projects/linux/driver/hello_makefile/src/add.h diff --git a/tests/projects/linux/driver/hello/src/add.c b/tests/projects/linux/driver/hello/src/add.c index 59aab49836d..72c39a6e437 100644 --- a/tests/projects/linux/driver/hello/src/add.c +++ b/tests/projects/linux/driver/hello/src/add.c @@ -1,3 +1,4 @@ +#include "add.h" int add(int a, int b) { return a + b; } diff --git a/tests/projects/linux/driver/hello/src/add.h b/tests/projects/linux/driver/hello/src/add.h new file mode 100644 index 00000000000..ba2df692673 --- /dev/null +++ b/tests/projects/linux/driver/hello/src/add.h @@ -0,0 +1,2 @@ +#pragma once +int add(int a, int b); diff --git a/tests/projects/linux/driver/hello/src/hello.c b/tests/projects/linux/driver/hello/src/hello.c index 414a03bb2b7..c32e48f61c1 100644 --- a/tests/projects/linux/driver/hello/src/hello.c +++ b/tests/projects/linux/driver/hello/src/hello.c @@ -1,20 +1,19 @@ #include #include +#include "add.h" MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("Ruki"); MODULE_DESCRIPTION("A simple Hello World Module"); MODULE_ALIAS("a simplest module"); -int add(int a, int b); - -int hello_init(void) +static int hello_init(void) { printk(KERN_INFO "Hello World: %d\n", add(1, 2)); return 0; } -void hello_exit(void) +static void hello_exit(void) { printk(KERN_INFO "Goodbye World\n"); } diff --git a/tests/projects/linux/driver/hello_custom/src/add.c b/tests/projects/linux/driver/hello_custom/src/add.c index 59aab49836d..72c39a6e437 100644 --- a/tests/projects/linux/driver/hello_custom/src/add.c +++ b/tests/projects/linux/driver/hello_custom/src/add.c @@ -1,3 +1,4 @@ +#include "add.h" int add(int a, int b) { return a + b; } diff --git a/tests/projects/linux/driver/hello_custom/src/add.h b/tests/projects/linux/driver/hello_custom/src/add.h new file mode 100644 index 00000000000..ba2df692673 --- /dev/null +++ b/tests/projects/linux/driver/hello_custom/src/add.h @@ -0,0 +1,2 @@ +#pragma once +int add(int a, int b); diff --git a/tests/projects/linux/driver/hello_custom/src/hello.c b/tests/projects/linux/driver/hello_custom/src/hello.c index 414a03bb2b7..c1cead11df3 100644 --- a/tests/projects/linux/driver/hello_custom/src/hello.c +++ b/tests/projects/linux/driver/hello_custom/src/hello.c @@ -1,20 +1,18 @@ #include #include - +#include "add.h" MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("Ruki"); MODULE_DESCRIPTION("A simple Hello World Module"); MODULE_ALIAS("a simplest module"); -int add(int a, int b); - -int hello_init(void) +static int hello_init(void) { printk(KERN_INFO "Hello World: %d\n", add(1, 2)); return 0; } -void hello_exit(void) +static void hello_exit(void) { printk(KERN_INFO "Goodbye World\n"); } diff --git a/tests/projects/linux/driver/hello_makefile/src/add.c b/tests/projects/linux/driver/hello_makefile/src/add.c index 59aab49836d..72c39a6e437 100644 --- a/tests/projects/linux/driver/hello_makefile/src/add.c +++ b/tests/projects/linux/driver/hello_makefile/src/add.c @@ -1,3 +1,4 @@ +#include "add.h" int add(int a, int b) { return a + b; } diff --git a/tests/projects/linux/driver/hello_makefile/src/add.h b/tests/projects/linux/driver/hello_makefile/src/add.h new file mode 100644 index 00000000000..ba2df692673 --- /dev/null +++ b/tests/projects/linux/driver/hello_makefile/src/add.h @@ -0,0 +1,2 @@ +#pragma once +int add(int a, int b); diff --git a/tests/projects/linux/driver/hello_makefile/src/hello.c b/tests/projects/linux/driver/hello_makefile/src/hello.c index 414a03bb2b7..c32e48f61c1 100644 --- a/tests/projects/linux/driver/hello_makefile/src/hello.c +++ b/tests/projects/linux/driver/hello_makefile/src/hello.c @@ -1,20 +1,19 @@ #include #include +#include "add.h" MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("Ruki"); MODULE_DESCRIPTION("A simple Hello World Module"); MODULE_ALIAS("a simplest module"); -int add(int a, int b); - -int hello_init(void) +static int hello_init(void) { printk(KERN_INFO "Hello World: %d\n", add(1, 2)); return 0; } -void hello_exit(void) +static void hello_exit(void) { printk(KERN_INFO "Goodbye World\n"); } diff --git a/xmake/rules/platform/linux/driver/driver_modules.lua b/xmake/rules/platform/linux/driver/driver_modules.lua index 25acc65810d..45ee30c6869 100644 --- a/xmake/rules/platform/linux/driver/driver_modules.lua +++ b/xmake/rules/platform/linux/driver/driver_modules.lua @@ -75,12 +75,12 @@ MODULE_AUTHOR("Ruki"); MODULE_DESCRIPTION("A simple Hello World Module"); MODULE_ALIAS("a simplest module"); -int hello_init(void) { +static int hello_init(void) { printk(KERN_INFO "Hello World\n"); return 0; } -void hello_exit(void) { +static void hello_exit(void) { printk(KERN_INFO "Goodbye World\n"); }