diff options
Diffstat (limited to 'drivers/i2c/algos/i2c-algo-bit.c')
-rw-r--r-- | drivers/i2c/algos/i2c-algo-bit.c | 22 |
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 | */ |
235 | static int test_bus(struct i2c_algo_bit_data *adap, char *name) | 235 | static 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; |
302 | bailout: | 314 | bailout: |
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 | } |