aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2009-03-28 16:34:43 -0400
committerJean Delvare <khali@linux-fr.org>2009-03-28 16:34:43 -0400
commit8a52c6b4d55b2960d93a90a7cf6afd252357fa54 (patch)
treebdc87e2591e4aa431389acba6efc45a7b620eb62 /drivers/i2c
parent8fcfef6e65c5b58e6482eae0b793319c8d9efd44 (diff)
i2c: Adapter timeout is in jiffies
i2c_adapter.timeout is in jiffies. Fix all drivers which thought otherwise. It didn't really matter as long as the value was only used inside the driver, but soon i2c-core will use it too so it must have the proper unit. Note: for the i2c-mpc driver, this fixes a bug in polling mode. Timeout would trigger after 1 jiffy, which is most probably not what the author wanted. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Clifford Wolf <clifford@clifford.at> Acked-by: Sean MacLennan <smaclennan@pikatech.com> Cc: Stefan Roese <sr@denx.de> Acked-by: Lennert Buytenhek <kernel@wantstofly.org> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Grant Likely <grant.likely@secretlab.ca> Acked-by: Mark A. Greer <mgreer@mvista.com>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.c6
-rw-r--r--drivers/i2c/busses/i2c-iop3xx.c2
-rw-r--r--drivers/i2c/busses/i2c-mpc.c4
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c7
4 files changed, 9 insertions, 10 deletions
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 88f0db73b364..8b92a4666e02 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -415,7 +415,7 @@ static int iic_wait_for_tc(struct ibm_iic_private* dev){
415 if (dev->irq >= 0){ 415 if (dev->irq >= 0){
416 /* Interrupt mode */ 416 /* Interrupt mode */
417 ret = wait_event_interruptible_timeout(dev->wq, 417 ret = wait_event_interruptible_timeout(dev->wq,
418 !(in_8(&iic->sts) & STS_PT), dev->adap.timeout * HZ); 418 !(in_8(&iic->sts) & STS_PT), dev->adap.timeout);
419 419
420 if (unlikely(ret < 0)) 420 if (unlikely(ret < 0))
421 DBG("%d: wait interrupted\n", dev->idx); 421 DBG("%d: wait interrupted\n", dev->idx);
@@ -426,7 +426,7 @@ static int iic_wait_for_tc(struct ibm_iic_private* dev){
426 } 426 }
427 else { 427 else {
428 /* Polling mode */ 428 /* Polling mode */
429 unsigned long x = jiffies + dev->adap.timeout * HZ; 429 unsigned long x = jiffies + dev->adap.timeout;
430 430
431 while (in_8(&iic->sts) & STS_PT){ 431 while (in_8(&iic->sts) & STS_PT){
432 if (unlikely(time_after(jiffies, x))){ 432 if (unlikely(time_after(jiffies, x))){
@@ -748,7 +748,7 @@ static int __devinit iic_probe(struct of_device *ofdev,
748 i2c_set_adapdata(adap, dev); 748 i2c_set_adapdata(adap, dev);
749 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 749 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
750 adap->algo = &iic_algo; 750 adap->algo = &iic_algo;
751 adap->timeout = 1; 751 adap->timeout = HZ;
752 752
753 ret = i2c_add_adapter(adap); 753 ret = i2c_add_adapter(adap);
754 if (ret < 0) { 754 if (ret < 0) {
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c
index 3190690c26ce..a75c75e77b92 100644
--- a/drivers/i2c/busses/i2c-iop3xx.c
+++ b/drivers/i2c/busses/i2c-iop3xx.c
@@ -488,7 +488,7 @@ iop3xx_i2c_probe(struct platform_device *pdev)
488 /* 488 /*
489 * Default values...should these come in from board code? 489 * Default values...should these come in from board code?
490 */ 490 */
491 new_adapter->timeout = 100; 491 new_adapter->timeout = HZ;
492 new_adapter->algo = &iop3xx_i2c_algo; 492 new_adapter->algo = &iop3xx_i2c_algo;
493 493
494 init_waitqueue_head(&adapter_data->waitq); 494 init_waitqueue_head(&adapter_data->waitq);
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index aedbbe6618db..2b847d875946 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -116,7 +116,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
116 } else { 116 } else {
117 /* Interrupt mode */ 117 /* Interrupt mode */
118 result = wait_event_interruptible_timeout(i2c->queue, 118 result = wait_event_interruptible_timeout(i2c->queue,
119 (i2c->interrupt & CSR_MIF), timeout * HZ); 119 (i2c->interrupt & CSR_MIF), timeout);
120 120
121 if (unlikely(result < 0)) { 121 if (unlikely(result < 0)) {
122 pr_debug("I2C: wait interrupted\n"); 122 pr_debug("I2C: wait interrupted\n");
@@ -311,7 +311,7 @@ static struct i2c_adapter mpc_ops = {
311 .owner = THIS_MODULE, 311 .owner = THIS_MODULE,
312 .name = "MPC adapter", 312 .name = "MPC adapter",
313 .algo = &mpc_algo, 313 .algo = &mpc_algo,
314 .timeout = 1, 314 .timeout = HZ,
315}; 315};
316 316
317static int __devinit fsl_i2c_probe(struct of_device *op, const struct of_device_id *match) 317static int __devinit fsl_i2c_probe(struct of_device *op, const struct of_device_id *match)
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index 7f186bbcb99d..5a4945d1dba4 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -358,7 +358,7 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
358 char abort = 0; 358 char abort = 0;
359 359
360 time_left = wait_event_interruptible_timeout(drv_data->waitq, 360 time_left = wait_event_interruptible_timeout(drv_data->waitq,
361 !drv_data->block, msecs_to_jiffies(drv_data->adapter.timeout)); 361 !drv_data->block, drv_data->adapter.timeout);
362 362
363 spin_lock_irqsave(&drv_data->lock, flags); 363 spin_lock_irqsave(&drv_data->lock, flags);
364 if (!time_left) { /* Timed out */ 364 if (!time_left) { /* Timed out */
@@ -374,8 +374,7 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
374 spin_unlock_irqrestore(&drv_data->lock, flags); 374 spin_unlock_irqrestore(&drv_data->lock, flags);
375 375
376 time_left = wait_event_timeout(drv_data->waitq, 376 time_left = wait_event_timeout(drv_data->waitq,
377 !drv_data->block, 377 !drv_data->block, drv_data->adapter.timeout);
378 msecs_to_jiffies(drv_data->adapter.timeout));
379 378
380 if ((time_left <= 0) && drv_data->block) { 379 if ((time_left <= 0) && drv_data->block) {
381 drv_data->state = MV64XXX_I2C_STATE_IDLE; 380 drv_data->state = MV64XXX_I2C_STATE_IDLE;
@@ -530,7 +529,7 @@ mv64xxx_i2c_probe(struct platform_device *pd)
530 drv_data->adapter.algo = &mv64xxx_i2c_algo; 529 drv_data->adapter.algo = &mv64xxx_i2c_algo;
531 drv_data->adapter.owner = THIS_MODULE; 530 drv_data->adapter.owner = THIS_MODULE;
532 drv_data->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 531 drv_data->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
533 drv_data->adapter.timeout = pdata->timeout; 532 drv_data->adapter.timeout = msecs_to_jiffies(pdata->timeout);
534 drv_data->adapter.nr = pd->id; 533 drv_data->adapter.nr = pd->id;
535 platform_set_drvdata(pd, drv_data); 534 platform_set_drvdata(pd, drv_data);
536 i2c_set_adapdata(&drv_data->adapter, drv_data); 535 i2c_set_adapdata(&drv_data->adapter, drv_data);