Skip to content

Commit

Permalink
i2c-algo-bit: Call pre/post_xfer for bit_test
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
agd5f authored and Jean Delvare committed Apr 17, 2011
1 parent a920ff4 commit d3b3e15
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions drivers/i2c/algos/i2c-algo-bit.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,17 @@ static int i2c_inb(struct i2c_adapter *i2c_adap)
* Sanity check for the adapter hardware - check the reaction of
* the bus lines only if it seems to be idle.
*/
static int test_bus(struct i2c_algo_bit_data *adap, char *name)
static int test_bus(struct i2c_adapter *i2c_adap)
{
int scl, sda;
struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
const char *name = i2c_adap->name;
int scl, sda, ret;

if (adap->pre_xfer) {
ret = adap->pre_xfer(i2c_adap);
if (ret < 0)
return -ENODEV;
}

if (adap->getscl == NULL)
pr_info("%s: Testing SDA only, SCL is not readable\n", name);
Expand Down Expand Up @@ -297,11 +305,19 @@ static int test_bus(struct i2c_algo_bit_data *adap, char *name)
"while pulling SCL high!\n", name);
goto bailout;
}

if (adap->post_xfer)
adap->post_xfer(i2c_adap);

pr_info("%s: Test OK\n", name);
return 0;
bailout:
sdahi(adap);
sclhi(adap);

if (adap->post_xfer)
adap->post_xfer(i2c_adap);

return -ENODEV;
}

Expand Down Expand Up @@ -607,7 +623,7 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap,
int ret;

if (bit_test) {
ret = test_bus(bit_adap, adap->name);
ret = test_bus(adap);
if (ret < 0)
return -ENODEV;
}
Expand Down

0 comments on commit d3b3e15

Please sign in to comment.