Welcome to the Linux Foundation Forum!

Kernel Driver - Best practises

Options

Hi All,

I am currently writing a kernel module driver for a Texas Instruments DAC16S997 SPI based device using IIO (class?). I have successfully created something that works for me but was wondering if anyone out there can comment on best practices regarding drivers and user space. The intention would be to create a pull request on the main branch. Before I do this I would like some insight as this is my first rodeo.

Main questions/ areas of concern:

  1. Register access
    How much access should I give the user space. Do i create an interface for every register and let the user space configure anything at will? or not at all. Or somewhere in between?

  2. Persistent Configuration - Should configuration be persistent across reboot. i.e Do i reset to a default state on boot or just pickup where it was left.

  3. Hotswap. It is reasonable to not support hotswapping considering this is an SPI device not USB - right?

Regarding Q1 I see a potential solution being to wrap a config around the registers so the user space only has access to configuration parameters which under the hood deal with registers.

Any insights or thoughts will be appreciated.

Thanks

Categories

Upcoming Training