Commit 30091404af5a7cd515e7b565df76932e295d8f6f
Committed by
Jean Delvare
1 parent
08e5338d11
Exists in
master
and in
4 other branches
i2c-algo-pcf: Add adapter hooks around xfer begin and end
Some I2C bus implementations need to synchronize with external entities, such as system firmware, which might also be programming the same I2C bus. In order to facilitate this add ->xfer_begin() and ->xfer_end() hooks which are invoked around pcf_xfer(). [JD: Make these hooks optional.] Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Showing 2 changed files with 16 additions and 4 deletions Side-by-side Diff
drivers/i2c/algos/i2c-algo-pcf.c
... | ... | @@ -331,13 +331,16 @@ |
331 | 331 | int i; |
332 | 332 | int ret=0, timeout, status; |
333 | 333 | |
334 | + if (adap->xfer_begin) | |
335 | + adap->xfer_begin(adap->data); | |
334 | 336 | |
335 | 337 | /* Check for bus busy */ |
336 | 338 | timeout = wait_for_bb(adap); |
337 | 339 | if (timeout) { |
338 | 340 | DEB2(printk(KERN_ERR "i2c-algo-pcf.o: " |
339 | 341 | "Timeout waiting for BB in pcf_xfer\n");) |
340 | - return -EIO; | |
342 | + i = -EIO; | |
343 | + goto out; | |
341 | 344 | } |
342 | 345 | |
343 | 346 | for (i = 0;ret >= 0 && i < num; i++) { |
344 | 347 | |
... | ... | @@ -359,12 +362,14 @@ |
359 | 362 | if (timeout) { |
360 | 363 | if (timeout == -EINTR) { |
361 | 364 | /* arbitration lost */ |
362 | - return (-EINTR); | |
365 | + i = -EINTR; | |
366 | + goto out; | |
363 | 367 | } |
364 | 368 | i2c_stop(adap); |
365 | 369 | DEB2(printk(KERN_ERR "i2c-algo-pcf.o: Timeout waiting " |
366 | 370 | "for PIN(1) in pcf_xfer\n");) |
367 | - return (-EREMOTEIO); | |
371 | + i = -EREMOTEIO; | |
372 | + goto out; | |
368 | 373 | } |
369 | 374 | |
370 | 375 | #ifndef STUB_I2C |
... | ... | @@ -372,7 +377,8 @@ |
372 | 377 | if (status & I2C_PCF_LRB) { |
373 | 378 | i2c_stop(adap); |
374 | 379 | DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");) |
375 | - return (-EREMOTEIO); | |
380 | + i = -EREMOTEIO; | |
381 | + goto out; | |
376 | 382 | } |
377 | 383 | #endif |
378 | 384 | |
... | ... | @@ -404,6 +410,9 @@ |
404 | 410 | } |
405 | 411 | } |
406 | 412 | |
413 | +out: | |
414 | + if (adap->xfer_end) | |
415 | + adap->xfer_end(adap->data); | |
407 | 416 | return (i); |
408 | 417 | } |
409 | 418 |
include/linux/i2c-algo-pcf.h
... | ... | @@ -33,6 +33,9 @@ |
33 | 33 | int (*getclock) (void *data); |
34 | 34 | void (*waitforpin) (void *data); |
35 | 35 | |
36 | + void (*xfer_begin) (void *data); | |
37 | + void (*xfer_end) (void *data); | |
38 | + | |
36 | 39 | /* Multi-master lost arbitration back-off delay (msecs) |
37 | 40 | * This should be set by the bus adapter or knowledgable client |
38 | 41 | * if bus is multi-mastered, else zero |