[HN Gopher] The Linux Kernel Module Programming Guide
       ___________________________________________________________________
        
       The Linux Kernel Module Programming Guide
        
       Author : eating555
       Score  : 105 points
       Date   : 2021-08-02 14:00 UTC (9 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | nrclark wrote:
       | A semi-related question: do kernel modules play nicely with
       | device-tree instantiations?
       | 
       | Like let's say I wanted to instantiate an I2C with a custom
       | driver in my device-tree. Can I put the controller's driver in a
       | kernel module that lives in /lib/modules? Or do I need to compile
       | it into the kernel?
        
         | csoete wrote:
         | I just did that recently you can load a kernel module the
         | driver will start working and the device will appear (if
         | compatibility is setup correctly). You can remove the module
         | and the device will stop and be removed from /dev.
        
         | dexterhaslem wrote:
         | yes ive done this recently with both spi and i2c. it works with
         | modules, the hardest part for me was finding the right way to
         | create the device tree so eg, my module got the spi bus over
         | spidev. same with i2cdev if you are not using userspace
        
       | sprc86 wrote:
       | can you update the Makefile so it generate a PDF only? Also, the
       | "make all" doesn't seems to be working as expected here. Probably
       | missing some dependency.
        
       | fmntf wrote:
       | In my opinion the best way to do kernel development is to just
       | look at device drivers in kernel sources, study what current
       | drivers do and write your own driver. The kernel supports su much
       | heterogeneous devices and its APIs change continuously that it is
       | practically impossible to write a complete guide on this topic.
        
       | joezydeco wrote:
       | Just a warning if you do embedded work with Linux (RPi,
       | Beaglebone, etc)... this guide doesn't cover the Devicetree APIs.
       | Doesn't even acknowledge their existence.
        
         | [deleted]
        
         | tajustice1 wrote:
         | RPi is barely embedded work. It's almost always micro-desktop
         | Linux.
        
           | joezydeco wrote:
           | True. But there _are_ some of us working on ARM platforms
           | that aren 't RPi that need to hack drivers.
           | 
           | Anyone working with a SOM, for example, will want to
           | customize the DT for their carrier board. And then your EE
           | finds a cheaper controller chip somewhere. And then your
           | display supplier switches captouch parts on you mid-
           | production.
           | 
           | Sorry, was I venting there?
           | 
           | (And just a tip, don't break bad on the Pi here. For many
           | people this is the only ARM platform worth working with. And
           | _definitely_ don 't make fun of the lack of peripherals on
           | the thing)
        
             | tajustice1 wrote:
             | >True. But there are some of us working on ARM platforms
             | that aren't RPi that need to hack drivers.
             | 
             | Which has nothing to do with RPi or embedded systems... Not
             | sure if I understand.
             | 
             | >And just a tip, don't break bad on the Pi here. For many
             | people this is the only ARM platform worth working with.
             | 
             | Ugh... Cell phones? Or any of the zillion of ARM
             | development boards out there.
        
             | ndesaulniers wrote:
             | You're right. I was trying to write up a cpufreq driver for
             | the Nintendo 3DS and found that LKMPG's complete lack of DT
             | info astounding.
        
         | eating555 wrote:
         | The author is pretty open to any kind of criticisms and
         | suggestions. It would be great if you open an issue to inform
         | him the missing contents.
        
           | joezydeco wrote:
           | Already did
        
       ___________________________________________________________________
       (page generated 2021-08-02 23:01 UTC)