Is there a best approach (or at least some advantages and disadvantages) when choosing between the use of kernel space or user space drivers in Linux?
For example, let's say I'm developing a board for sensing humidity built on the Sensirion SHT21 sensor. My application will read a sample from the sensor and then present it in JSON form for a web application to consume.
In order to "talk" with the SHT21 sensor I can either:
echo sht21 0x40 > /sys/class/i2c-adapter/i2c-0/new_device and access the humidity readings via hwmon, parse the output and then use it in my applicationwrite() and read() operations against /dev/i2c-0 and calculate the humidity myself, then use it in my applicationThe first approach makes use of the sht21 kernel driver, the latter works entirely in user space.
Which one should I go for? How should I choose?
Of the top of my head:
Userland approach pros:
Userland approach cons:
In the case of your application, putting that in perspective:
...all in all, I would 200% go with the userland approach.
Kernel space may be technically more "fun" or "rewarding", but engineering put "pragmatic" before "fun". :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With