aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/algos
diff options
context:
space:
mode:
authorAlex Deucher <alexdeucher@gmail.com>2011-04-17 04:20:19 -0400
committerJean Delvare <khali@endymion.delvare>2011-04-17 04:20:19 -0400
commitd3b3e15da14ded61c9654db05863b04a2435f4cc (patch)
treec683f167f9e8049201773e4b2884d40cc30a4fd3 /drivers/i2c/algos
parenta920ff41cb3d2b03da095c4fa1a11b71417ae2a4 (diff)
i2c-algo-bit: Call pre/post_xfer for bit_test
Apparently some distros set i2c-algo-bit.bit_test to 1 by default. In some cases this causes i2c_bit_add_bus to fail and prevents the i2c bus from being added. In the radeon case, we fail to add the ddc i2c buses which prevents the driver from being able to detect attached monitors. The i2c bus works fine even if bit_test fails. This is likely due to gpio switching that is required and handled in the pre/post_xfer hooks, so call the pre/post_xfer hooks in the bit test as well. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=36221 Signed-off-by: Alex Deucher <alexdeucher@gmail.com> Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: stable@kernel.org [.38 down to .34]
Diffstat (limited to 'drivers/i2c/algos')
-rw-r--r--drivers/i2c/algos/i2c-algo-bit.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index 38319a69bd0a..d6d58684712b 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -232,9 +232,17 @@ static int i2c_inb(struct i2c_adapter *i2c_adap)
232 * Sanity check for the adapter hardware - check the reaction of 232 * Sanity check for the adapter hardware - check the reaction of
233 * the bus lines only if it seems to be idle. 233 * the bus lines only if it seems to be idle.
234 */ 234 */
235static int test_bus(struct i2c_algo_bit_data *adap, char *name) 235static int test_bus(struct i2c_adapter *i2c_adap)
236{ 236{
237 int scl, sda; 237 struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
238 const char *name = i2c_adap->name;
239 int scl, sda, ret;
240
241 if (adap->pre_xfer) {
242 ret = adap->pre_xfer(i2c_adap);
243 if (ret < 0)
244 return -ENODEV;
245 }
238 246
239 if (adap->getscl == NULL) 247 if (adap->getscl == NULL)
240 pr_info("%s: Testing SDA only, SCL is not readable\n", name); 248 pr_info("%s: Testing SDA only, SCL is not readable\n", name);
@@ -297,11 +305,19 @@ static int test_bus(struct i2c_algo_bit_data *adap, char *name)
297 "while pulling SCL high!\n", name); 305 "while pulling SCL high!\n", name);
298 goto bailout; 306 goto bailout;
299 } 307 }
308
309 if (adap->post_xfer)
310 adap->post_xfer(i2c_adap);
311
300 pr_info("%s: Test OK\n", name); 312 pr_info("%s: Test OK\n", name);
301 return 0; 313 return 0;
302bailout: 314bailout:
303 sdahi(adap); 315 sdahi(adap);
304 sclhi(adap); 316 sclhi(adap);
317
318 if (adap->post_xfer)
319 adap->post_xfer(i2c_adap);
320
305 return -ENODEV; 321 return -ENODEV;
306} 322}
307 323
@@ -607,7 +623,7 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap,
607 int ret; 623 int ret;
608 624
609 if (bit_test) { 625 if (bit_test) {
610 ret = test_bus(bit_adap, adap->name); 626 ret = test_bus(adap);
611 if (ret < 0) 627 if (ret < 0)
612 return -ENODEV; 628 return -ENODEV;
613 } 629 }