Commit 38f41f28 authored by Jean Delvare's avatar Jean Delvare

i2c-stub: Allow user to disable some commands

Add a module parameter to override the functionality bitfield. This
lets the user disable some commands. This can be used to force a chip
driver to take different code paths.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent 47103178
...@@ -33,6 +33,12 @@ PARAMETERS: ...@@ -33,6 +33,12 @@ PARAMETERS:
int chip_addr[10]: int chip_addr[10]:
The SMBus addresses to emulate chips at. The SMBus addresses to emulate chips at.
unsigned long functionality:
Functionality override, to disable some commands. See I2C_FUNC_*
constants in <linux/i2c.h> for the suitable values. For example,
value 0x1f0000 would only enable the quick, byte and byte data
commands.
CAVEATS: CAVEATS:
If your target driver polls some byte or word waiting for it to change, the If your target driver polls some byte or word waiting for it to change, the
......
...@@ -35,6 +35,10 @@ module_param_array(chip_addr, ushort, NULL, S_IRUGO); ...@@ -35,6 +35,10 @@ module_param_array(chip_addr, ushort, NULL, S_IRUGO);
MODULE_PARM_DESC(chip_addr, MODULE_PARM_DESC(chip_addr,
"Chip addresses (up to 10, between 0x03 and 0x77)"); "Chip addresses (up to 10, between 0x03 and 0x77)");
static unsigned long functionality = ~0UL;
module_param(functionality, ulong, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(functionality, "Override functionality bitfield");
struct stub_chip { struct stub_chip {
u8 pointer; u8 pointer;
u16 words[256]; /* Byte operations use the LSB as per SMBus 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,9 +156,9 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags,
static u32 stub_func(struct i2c_adapter *adapter) static u32 stub_func(struct i2c_adapter *adapter)
{ {
return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | return (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
I2C_FUNC_SMBUS_I2C_BLOCK; I2C_FUNC_SMBUS_I2C_BLOCK) & functionality;
} }
static const struct i2c_algorithm smbus_algorithm = { static const struct i2c_algorithm smbus_algorithm = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment