diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-07-24 08:13:59 -0400 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2012-07-24 08:13:59 -0400 |
commit | 72fc2c7f78b0c365454e60ad33b0e74aea43e3ab (patch) | |
tree | b4416754f881f49b0e4cdb3585ed1f598c5a6c56 /drivers/i2c/i2c-core.c | |
parent | d47726c52122d64253ae56e0fafdb7d0b954e97c (diff) |
i2c: Fall back to emulated SMBus if the operation isn't supported natively
Adapter drivers might support only a subset of the SMBus operations
natively. Those drivers currently have to manually emulate unsupported
operations using I2C.
Make the i2c_smbus_xfer() function fall back to
i2c_smbus_xfer_emulated() when the adapter's .smbus_xfer() operation
returns -EOPNOTSUPP, like it already does when the .smbus_xfer()
operation isn't available at all.
[JD: Minor optimization.]
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 361978a8485a..26488aa893d5 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -2140,11 +2140,17 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags, | |||
2140 | break; | 2140 | break; |
2141 | } | 2141 | } |
2142 | i2c_unlock_adapter(adapter); | 2142 | i2c_unlock_adapter(adapter); |
2143 | } else | ||
2144 | res = i2c_smbus_xfer_emulated(adapter, addr, flags, read_write, | ||
2145 | command, protocol, data); | ||
2146 | 2143 | ||
2147 | return res; | 2144 | if (res != -EOPNOTSUPP || !adapter->algo->master_xfer) |
2145 | return res; | ||
2146 | /* | ||
2147 | * Fall back to i2c_smbus_xfer_emulated if the adapter doesn't | ||
2148 | * implement native support for the SMBus operation. | ||
2149 | */ | ||
2150 | } | ||
2151 | |||
2152 | return i2c_smbus_xfer_emulated(adapter, addr, flags, read_write, | ||
2153 | command, protocol, data); | ||
2148 | } | 2154 | } |
2149 | EXPORT_SYMBOL(i2c_smbus_xfer); | 2155 | EXPORT_SYMBOL(i2c_smbus_xfer); |
2150 | 2156 | ||