diff options
-rw-r--r-- | Documentation/i2c/i2c-stub | 6 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-stub.c | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/Documentation/i2c/i2c-stub b/Documentation/i2c/i2c-stub index d9c383b30925..326d1ee81e0e 100644 --- a/Documentation/i2c/i2c-stub +++ b/Documentation/i2c/i2c-stub | |||
@@ -33,6 +33,12 @@ PARAMETERS: | |||
33 | int chip_addr[10]: | 33 | int chip_addr[10]: |
34 | The SMBus addresses to emulate chips at. | 34 | The SMBus addresses to emulate chips at. |
35 | 35 | ||
36 | unsigned long functionality: | ||
37 | Functionality override, to disable some commands. See I2C_FUNC_* | ||
38 | constants in <linux/i2c.h> for the suitable values. For example, | ||
39 | value 0x1f0000 would only enable the quick, byte and byte data | ||
40 | commands. | ||
41 | |||
36 | CAVEATS: | 42 | CAVEATS: |
37 | 43 | ||
38 | If your target driver polls some byte or word waiting for it to change, the | 44 | If your target driver polls some byte or word waiting for it to change, the |
diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c index 52ebeda1a64b..0c770eabe85e 100644 --- a/drivers/i2c/busses/i2c-stub.c +++ b/drivers/i2c/busses/i2c-stub.c | |||
@@ -35,6 +35,10 @@ module_param_array(chip_addr, ushort, NULL, S_IRUGO); | |||
35 | MODULE_PARM_DESC(chip_addr, | 35 | MODULE_PARM_DESC(chip_addr, |
36 | "Chip addresses (up to 10, between 0x03 and 0x77)"); | 36 | "Chip addresses (up to 10, between 0x03 and 0x77)"); |
37 | 37 | ||
38 | static unsigned long functionality = ~0UL; | ||
39 | module_param(functionality, ulong, S_IRUGO | S_IWUSR); | ||
40 | MODULE_PARM_DESC(functionality, "Override functionality bitfield"); | ||
41 | |||
38 | struct stub_chip { | 42 | struct stub_chip { |
39 | u8 pointer; | 43 | u8 pointer; |
40 | u16 words[256]; /* Byte operations use the LSB as per SMBus | 44 | u16 words[256]; /* Byte operations use the LSB as per SMBus |
@@ -152,9 +156,9 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags, | |||
152 | 156 | ||
153 | static u32 stub_func(struct i2c_adapter *adapter) | 157 | static u32 stub_func(struct i2c_adapter *adapter) |
154 | { | 158 | { |
155 | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | | 159 | return (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | |
156 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | | 160 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | |
157 | I2C_FUNC_SMBUS_I2C_BLOCK; | 161 | I2C_FUNC_SMBUS_I2C_BLOCK) & functionality; |
158 | } | 162 | } |
159 | 163 | ||
160 | static const struct i2c_algorithm smbus_algorithm = { | 164 | static const struct i2c_algorithm smbus_algorithm = { |