views:

58

answers:

1

I am currently dealing with two devices connected to the I2C bus within an embedded system running Linux. I am using an exisiting driver for the first device, a camera. For the second device, I have successfully implemented a userspace program with which I can communicate with the second device. So far, both devices seem to coexist happily. However, almost all I2C devices have their own driver module. Thus, I am wondering what the advantages of a driver module are. I had a look at the following thread...

http://stackoverflow.com/questions/149032/when-should-i-write-a-linux-kernel-module

... but without conclusion.

Thus, what would be the advantage of writing a I2C driver module over a userspace implementation?

Regards, Stefan

A: 

In your situation, you probably don't have much use for a I2C driver module. If it ain't broke....

The main reason I would include a kernel module driver is when another kernel mode driver is a I2C client, or benefits from tight integration with the kernel. One example of this is the WM8350 audio codec, which is communicates audio data over an audio bus (I2S or AC97) and configuration (e.g. volume level) over I2C.

A power management IC is another example of a chip that you would want the kernel to directly control.

Finally, I will note that there are multiple kinds of I2C drivers. (See Documentation/i2c/summary.) In some cases your hardware might require an I2C bus adapter driver, to teach how to communicate over I2C. That would require a kernel mode driver.

jbarlow
Thanks for the clarification.
stefangachter