aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses
diff options
context:
space:
mode:
authorNicholas Mc Guire <hofrat@osadl.org>2015-03-17 03:51:13 -0400
committerWolfram Sang <wsa@the-dreams.de>2015-03-27 11:53:42 -0400
commitd9e1f4417a43cd0871253b2158eae07a48d656b5 (patch)
tree99773d332d038a1e01762d7163d83fbf6537322b /drivers/i2c/busses
parent9c836d0c44798227a75c410cf33a76992cf93437 (diff)
i2c: davinci: fixup wait_for_completion_timeout handling
wait_for_completion_timeout return 0 (timeout) or >=1 (completion) so the check for >= 0 is always true and can be dropped implying that r==-EREMOTEIO and thus the return of -EREMOTEIO can be done in the if (dev->buf_len) branch. As wait_for_completion_timeout returns unsigned long not int, and int r is exclusively used for wait_for_completion_timeout it is renamed and the type changed to unsigned long. Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Acked-by: Alexander Sverdlin <alexander.sverdlin@nokia.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/busses')
-rw-r--r--drivers/i2c/busses/i2c-davinci.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 6dc7ff5d3d9a..120a4ef36ef5 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -304,7 +304,7 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
304 struct davinci_i2c_platform_data *pdata = dev->pdata; 304 struct davinci_i2c_platform_data *pdata = dev->pdata;
305 u32 flag; 305 u32 flag;
306 u16 w; 306 u16 w;
307 int r; 307 unsigned long time_left;
308 308
309 /* Introduce a delay, required for some boards (e.g Davinci EVM) */ 309 /* Introduce a delay, required for some boards (e.g Davinci EVM) */
310 if (pdata->bus_delay) 310 if (pdata->bus_delay)
@@ -368,8 +368,9 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
368 flag |= DAVINCI_I2C_MDR_STP; 368 flag |= DAVINCI_I2C_MDR_STP;
369 davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag); 369 davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag);
370 370
371 r = wait_for_completion_timeout(&dev->cmd_complete, dev->adapter.timeout); 371 time_left = wait_for_completion_timeout(&dev->cmd_complete,
372 if (r == 0) { 372 dev->adapter.timeout);
373 if (!time_left) {
373 dev_err(dev->dev, "controller timed out\n"); 374 dev_err(dev->dev, "controller timed out\n");
374 davinci_i2c_recover_bus(dev); 375 davinci_i2c_recover_bus(dev);
375 i2c_davinci_init(dev); 376 i2c_davinci_init(dev);
@@ -380,17 +381,13 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
380 /* This should be 0 if all bytes were transferred 381 /* This should be 0 if all bytes were transferred
381 * or dev->cmd_err denotes an error. 382 * or dev->cmd_err denotes an error.
382 */ 383 */
383 if (r >= 0) { 384 dev_err(dev->dev, "abnormal termination buf_len=%i\n",
384 dev_err(dev->dev, "abnormal termination buf_len=%i\n", 385 dev->buf_len);
385 dev->buf_len);
386 r = -EREMOTEIO;
387 }
388 dev->terminate = 1; 386 dev->terminate = 1;
389 wmb(); 387 wmb();
390 dev->buf_len = 0; 388 dev->buf_len = 0;
389 return -EREMOTEIO;
391 } 390 }
392 if (r < 0)
393 return r;
394 391
395 /* no error */ 392 /* no error */
396 if (likely(!dev->cmd_err)) 393 if (likely(!dev->cmd_err))