diff --git a/index.html b/index.html index b5e4eaa..2d0973d 100644 --- a/index.html +++ b/index.html @@ -4,8 +4,8 @@ - - + +
@@ -298,10 +298,10 @@ to use tabs, not spaces.
1obj-m += hello-1.o 
 2 
 3all: 
-4              make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules 
+4    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules 
 5 
 6clean: 
-7              make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
+7    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

And finally just:

1make
@@ -433,10 +433,10 @@ is as simple as this: 2obj-m += hello-2.o 3 4all: -5 make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules +5    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules 6 7clean: -8 make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean +8    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

Now have a look at linux/drivers/char/Makefile for a real world example. As you can see, some things get hardwired into the kernel (obj-y) but where are all those obj-m gone? Those familiar with shell scripts will easily be able to spot them. @@ -729,10 +729,10 @@ files. 7startstop-objs := start.o stop.o 8 9all: -10 make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules +10    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules 11 12clean: -13 make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean +13    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

This is the complete makefile for all the examples we have seen so far. The first five lines are nothing special, but for the last example we will need two lines. First we invent an object name for our combined module, second we tell make what object @@ -1192,10 +1192,10 @@ new way of assigning to the structure looks like:

1struct file_operations fops = { 
-2              read: device_read, 
-3              write: device_write, 
-4              open: device_open, 
-5              release: device_release 
+2    read: device_read, 
+3    write: device_write, 
+4    open: device_open, 
+5    release: device_release 
 6};

However, there is also a C99 way of assigning to elements of a structure, designated initializers, and this is definitely preferred over using the GNU extension. @@ -1204,10 +1204,10 @@ with compatibility:

1struct file_operations fops = { 
-2              .read = device_read, 
-3              .write = device_write, 
-4              .open = device_open, 
-5              .release = device_release 
+2    .read = device_read, 
+3    .write = device_write, 
+4    .open = device_open, 
+5    .release = device_release 
 6};

The meaning is clear, and you should be aware that any member of the structure which you do not explicitly assign will be initialized to NULL by @@ -1491,7 +1491,7 @@ multiple kernel versions, you will find yourself having to code conditional comp directives. The way to do this to compare the macro LINUX_VERSION_CODE to the macro KERNEL_VERSION. In version a.b.c of the kernel, the value of this macro would be  16    8
-2 a + 2 b+ c  . +2 a + 2 b+ c ' class='math' src='lkmpg-for-ht0x.svg' />.

While previous versions of this guide showed how you can write backward compatible code with such constructs in great detail, we decided to break with this tradition for the better. People interested in doing such might now use a LKMPG @@ -1942,7 +1942,7 @@ Figure 1

srYrsNNYtaeenetoooertusetupstrxr((ntn))( tis)istrr teeaNreNatUaUtmLtLmeLmLen?e?ntntt  +

srYrsNNYtaeenetoooertusetupstrxr((ntn))( tis)istrr teeaNreNatUaUtmLtLmeLmLen?e?ntntt

Figure 1:How seq_file works
diff --git a/lkmpg.css b/lkmpg-for-ht.css similarity index 99% rename from lkmpg.css rename to lkmpg-for-ht.css index 35c608c..e4de8be 100644 --- a/lkmpg.css +++ b/lkmpg-for-ht.css @@ -173,9 +173,9 @@ html { width: 100vw; overflow-x: hidden; } body { max-width: 50rem; box-sizing: border-box; padding: 1rem; margin: 0 auto; overflow-x: hidden; } div.author { white-space: normal; } img.math { height: 1rem; vertical-align: top; } +pre.fancyvrb, { white-space: pre; } figure, .fancyvrb, .verbatim { margin-inline: 0; overflow-x: auto; } -.ecrm-0500 { font-size: 70%; font-style: italic; color: gray; -webkit-user-select: none; -moz-user-select: none; -o-user-select: none; user-select: none; } -.ecrm-0500:after { content:" "; white-space: pre; -webkit-user-select: none; -moz-user-select: none; -o-user-select: none; user-select: none; } +.ecrm-0500 { font-size: 70%; font-style: italic; color: gray; width: 1.5rem; display: inline-block; -webkit-user-select: none; -moz-user-select: none; -o-user-select: none; user-select: none; } pre#fancyvrb1{padding:5.69054pt;} pre#fancyvrb1{ border-top: solid 0.4pt; } pre#fancyvrb1{ border-left: solid 0.4pt; } diff --git a/lkmpg.html b/lkmpg-for-ht.html similarity index 99% rename from lkmpg.html rename to lkmpg-for-ht.html index b5e4eaa..2d0973d 100644 --- a/lkmpg.html +++ b/lkmpg-for-ht.html @@ -4,8 +4,8 @@ - - + +
@@ -298,10 +298,10 @@ to use tabs, not spaces.
1obj-m += hello-1.o 
 2 
 3all: 
-4              make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules 
+4    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules 
 5 
 6clean: 
-7              make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
+7    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

And finally just:

1make
@@ -433,10 +433,10 @@ is as simple as this: 2obj-m += hello-2.o 3 4all: -5 make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules +5    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules 6 7clean: -8 make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean +8    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

Now have a look at linux/drivers/char/Makefile for a real world example. As you can see, some things get hardwired into the kernel (obj-y) but where are all those obj-m gone? Those familiar with shell scripts will easily be able to spot them. @@ -729,10 +729,10 @@ files. 7startstop-objs := start.o stop.o 8 9all: -10 make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules +10    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules 11 12clean: -13 make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean +13    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

This is the complete makefile for all the examples we have seen so far. The first five lines are nothing special, but for the last example we will need two lines. First we invent an object name for our combined module, second we tell make what object @@ -1192,10 +1192,10 @@ new way of assigning to the structure looks like:

1struct file_operations fops = { 
-2              read: device_read, 
-3              write: device_write, 
-4              open: device_open, 
-5              release: device_release 
+2    read: device_read, 
+3    write: device_write, 
+4    open: device_open, 
+5    release: device_release 
 6};

However, there is also a C99 way of assigning to elements of a structure, designated initializers, and this is definitely preferred over using the GNU extension. @@ -1204,10 +1204,10 @@ with compatibility:

1struct file_operations fops = { 
-2              .read = device_read, 
-3              .write = device_write, 
-4              .open = device_open, 
-5              .release = device_release 
+2    .read = device_read, 
+3    .write = device_write, 
+4    .open = device_open, 
+5    .release = device_release 
 6};

The meaning is clear, and you should be aware that any member of the structure which you do not explicitly assign will be initialized to NULL by @@ -1491,7 +1491,7 @@ multiple kernel versions, you will find yourself having to code conditional comp directives. The way to do this to compare the macro LINUX_VERSION_CODE to the macro KERNEL_VERSION. In version a.b.c of the kernel, the value of this macro would be  16    8
-2 a + 2 b+ c  . +2 a + 2 b+ c ' class='math' src='lkmpg-for-ht0x.svg' />.

While previous versions of this guide showed how you can write backward compatible code with such constructs in great detail, we decided to break with this tradition for the better. People interested in doing such might now use a LKMPG @@ -1942,7 +1942,7 @@ Figure 1

srYrsNNYtaeenetoooertusetupstrxr((ntn))( tis)istrr teeaNreNatUaUtmLtLmeLmLen?e?ntntt  +

srYrsNNYtaeenetoooertusetupstrxr((ntn))( tis)istrr teeaNreNatUaUtmLtLmeLmLen?e?ntntt

Figure 1:How seq_file works
diff --git a/lkmpg0x.svg b/lkmpg-for-ht0x.svg similarity index 100% rename from lkmpg0x.svg rename to lkmpg-for-ht0x.svg diff --git a/lkmpg1x.svg b/lkmpg-for-ht1x.svg similarity index 100% rename from lkmpg1x.svg rename to lkmpg-for-ht1x.svg