Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 320063
b: refs/heads/master
c: b37d2a3
h: refs/heads/master
i:
  320061: 333c605
  320059: 4d08077
  320055: 0e5a86b
  320047: 9dd434e
  320031: 186bcf4
  319999: 0a16c7c
v: v3
  • Loading branch information
Jean Delvare authored and Mauro Carvalho Chehab committed Jun 29, 2012
1 parent 0b2d789 commit 0c9ad7c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a99817ca60d206be3645d156f755cf065e949c58
refs/heads/master: b37d2a3a75cb0e72e18c29336cb2095b63dabfc8
44 changes: 33 additions & 11 deletions trunk/drivers/i2c/i2c-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,37 @@ module_exit(i2c_exit);
* ----------------------------------------------------
*/

/**
* __i2c_transfer - unlocked flavor of i2c_transfer
* @adap: Handle to I2C bus
* @msgs: One or more messages to execute before STOP is issued to
* terminate the operation; each message begins with a START.
* @num: Number of messages to be executed.
*
* Returns negative errno, else the number of messages executed.
*
* Adapter lock must be held when calling this function. No debug logging
* takes place. adap->algo->master_xfer existence isn't checked.
*/
int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
{
unsigned long orig_jiffies;
int ret, try;

/* Retry automatically on arbitration loss */
orig_jiffies = jiffies;
for (ret = 0, try = 0; try <= adap->retries; try++) {
ret = adap->algo->master_xfer(adap, msgs, num);
if (ret != -EAGAIN)
break;
if (time_after(jiffies, orig_jiffies + adap->timeout))
break;
}

return ret;
}
EXPORT_SYMBOL(__i2c_transfer);

/**
* i2c_transfer - execute a single or combined I2C message
* @adap: Handle to I2C bus
Expand All @@ -1308,8 +1339,7 @@ module_exit(i2c_exit);
*/
int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
{
unsigned long orig_jiffies;
int ret, try;
int ret;

/* REVISIT the fault reporting model here is weak:
*
Expand Down Expand Up @@ -1347,15 +1377,7 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
i2c_lock_adapter(adap);
}

/* Retry automatically on arbitration loss */
orig_jiffies = jiffies;
for (ret = 0, try = 0; try <= adap->retries; try++) {
ret = adap->algo->master_xfer(adap, msgs, num);
if (ret != -EAGAIN)
break;
if (time_after(jiffies, orig_jiffies + adap->timeout))
break;
}
ret = __i2c_transfer(adap, msgs, num);
i2c_unlock_adapter(adap);

return ret;
Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ extern int i2c_master_recv(const struct i2c_client *client, char *buf,
*/
extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
int num);
/* Unlocked flavor */
extern int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
int num);

/* This is the very generalized SMBus access routine. You probably do not
want to use this, though; one of the functions below may be much easier,
Expand Down

0 comments on commit 0c9ad7c

Please sign in to comment.