I see codes to make i2c device (e.g. i2c sensors) work in user space, just need kernel to support /dev/i2c-0 or /dev/i2c-1. But whether do we need to put the codes into Linux kernel? For example, if i2c interrupt is applied, how to know when should we read the i2c device in user space?
I am confusing. Like display driver, it is totally put into kernel space. Then for i2c driver, why some part is in kernel (i2c bus code) while some part is in user space? Which part is the real driver?
More: Give an example below. I find that Linux kernel contains driver for sht21, it is here below:
linux-rpi-3.18.y/drivers/hwmon$ ls -al sht21.c
-rw-rw-r-- 1 tomxue tomxue 6454 Jan 2 00:07 sht21.c
In fact, we could find a lot of drivers in kernel source code.
And also I find that someone makes user space driver for sht21, like this: http://www.emsystech.de/raspi-sht21/ I tried the code, and it works in user space.
My question is that which one is better? To put the driver into kernel or just call the GPIO/i2c bus API to communicate with the sensor in user space?
Thanks!