We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 51f0474 commit fc51208Copy full SHA for fc51208
digits_sum/Makefile
@@ -0,0 +1,6 @@
1
+obj-m += digitsum.o
2
+
3
+all:
4
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
5
+clean:
6
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
digits_sum/digitsum.c
@@ -0,0 +1,25 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+static int n = 5;
+module_param(n,int,0);
7
+MODULE_PARM_DESC(n,"given number");
8
9
10
+int init_module(void){
11
12
+ static int sum=0;
13
+ static int temp=n;
14
+ while(temp>0)
15
+ {
16
+ sum+=(temp%10);
17
+ temp/=10;
18
+ }
19
+ printk(KERN_INFO "Sum_of_digits: %d",sum);
20
+ return 0;
21
+}
22
23
+void cleanup_module(void){
24
+ printk(KERN_INFO "goodbye world");
25
0 commit comments