PageRenderTime 24ms CodeModel.GetById 18ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

#! | 38 lines | 27 code | 11 blank | 0 comment | 0 complexity | 0db17d8e14eb951225e46669339cfb85 MD5 | raw file
 1MODULE: i2c-stub
 5This module is a very simple fake I2C/SMBus driver.  It implements four
 6types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, and
 7(r/w) word data.
 9No hardware is needed nor associated with this module.  It will accept write
10quick commands to all addresses; it will respond to the other commands (also
11to all addresses) by reading from or writing to an array in memory.  It will
12also spam the kernel logs for every command it handles.
14A pointer register with auto-increment is implemented for all byte
15operations.  This allows for continuous byte reads like those supported by
16EEPROMs, among others.
18The typical use-case is like this:
19	1. load this module
20	2. use i2cset (from lm_sensors project) to pre-load some data
21	3. load the target sensors chip driver module
22	4. observe its behavior in the kernel log
26There are independent arrays for byte/data and word/data commands.  Depending
27on if/how a target driver mixes them, you'll need to be careful.
29If your target driver polls some byte or word waiting for it to change, the
30stub could lock it up.  Use i2cset to unlock it.
32If the hardware for your driver has banked registers (e.g. Winbond sensors
33chips) this module will not work well - although it could be extended to
34support that pretty easily.
36If you spam it hard enough, printk can be lossy.  This module really wants
37something like relayfs.