diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-27 11:09:48 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-27 11:09:48 -0400 |
commit | a5b08073a0b512d75fa1a7f82ee850e5c105cce9 (patch) | |
tree | 3e609b471ae2ca1f200f974fc65eaf242673db71 /drivers/i2c/busses/i2c-stub.c | |
parent | ff0972c26bbf209da6f6d244cce60e695df863f6 (diff) | |
parent | 6d3aae9d74221b00e2cbf50a353527e5a71a58ba (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/i2c-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/i2c-2.6: (30 commits)
i2c: Drop unimplemented slave functions
i2c: Constify i2c_algorithm declarations, part 2
i2c: Constify i2c_algorithm declarations, part 1
i2c: Let drivers constify i2c_algorithm data
i2c-isa: Restore driver owner
i2c-viapro: Add support for the VT8237A and VT8251
i2c: Warn on i2c client creation failure
i2c-core: Drop useless bitmaskings
i2c-algo-pcf: Discard the mdelay data struct member
i2c-algo-bit: Cleanups
i2c-isa: Fail adding driver on attach_adapter error
i2c: __must_check fixes (chip drivers)
i2c-dev: attach/detach_adapter cleanups
i2c-stub: Chip address as a module parameter
i2c: Plan i2c-isa for removal
i2c: New bus driver for TI OMAP boards
i2c-algo-bit: Discard the mdelay data struct member
i2c-matroxfb: Struct init conversion
i2c: Fix copy-n-paste in subsystem Kconfig
i2c-au1550: Add I2C support for Au1200
...
Diffstat (limited to 'drivers/i2c/busses/i2c-stub.c')
-rw-r--r-- | drivers/i2c/busses/i2c-stub.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c index 73f481e93a36..a54adc50d162 100644 --- a/drivers/i2c/busses/i2c-stub.c +++ b/drivers/i2c/busses/i2c-stub.c | |||
@@ -27,6 +27,10 @@ | |||
27 | #include <linux/errno.h> | 27 | #include <linux/errno.h> |
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | 29 | ||
30 | static unsigned short chip_addr; | ||
31 | module_param(chip_addr, ushort, S_IRUGO); | ||
32 | MODULE_PARM_DESC(chip_addr, "Chip address (between 0x03 and 0x77)\n"); | ||
33 | |||
30 | static u8 stub_pointer; | 34 | static u8 stub_pointer; |
31 | static u8 stub_bytes[256]; | 35 | static u8 stub_bytes[256]; |
32 | static u16 stub_words[256]; | 36 | static u16 stub_words[256]; |
@@ -37,6 +41,9 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags, | |||
37 | { | 41 | { |
38 | s32 ret; | 42 | s32 ret; |
39 | 43 | ||
44 | if (addr != chip_addr) | ||
45 | return -ENODEV; | ||
46 | |||
40 | switch (size) { | 47 | switch (size) { |
41 | 48 | ||
42 | case I2C_SMBUS_QUICK: | 49 | case I2C_SMBUS_QUICK: |
@@ -108,7 +115,7 @@ static u32 stub_func(struct i2c_adapter *adapter) | |||
108 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA; | 115 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA; |
109 | } | 116 | } |
110 | 117 | ||
111 | static struct i2c_algorithm smbus_algorithm = { | 118 | static const struct i2c_algorithm smbus_algorithm = { |
112 | .functionality = stub_func, | 119 | .functionality = stub_func, |
113 | .smbus_xfer = stub_xfer, | 120 | .smbus_xfer = stub_xfer, |
114 | }; | 121 | }; |
@@ -122,7 +129,17 @@ static struct i2c_adapter stub_adapter = { | |||
122 | 129 | ||
123 | static int __init i2c_stub_init(void) | 130 | static int __init i2c_stub_init(void) |
124 | { | 131 | { |
125 | printk(KERN_INFO "i2c-stub loaded\n"); | 132 | if (!chip_addr) { |
133 | printk(KERN_ERR "i2c-stub: Please specify a chip address\n"); | ||
134 | return -ENODEV; | ||
135 | } | ||
136 | if (chip_addr < 0x03 || chip_addr > 0x77) { | ||
137 | printk(KERN_ERR "i2c-stub: Invalid chip address 0x%02x\n", | ||
138 | chip_addr); | ||
139 | return -EINVAL; | ||
140 | } | ||
141 | |||
142 | printk(KERN_INFO "i2c-stub: Virtual chip at 0x%02x\n", chip_addr); | ||
126 | return i2c_add_adapter(&stub_adapter); | 143 | return i2c_add_adapter(&stub_adapter); |
127 | } | 144 | } |
128 | 145 | ||