Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+9 -10
+3 -3
drivers/i2c/busses/i2c-ibm_iic.c
··· 415 415 if (dev->irq >= 0){ 416 416 /* Interrupt mode */ 417 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 420 if (unlikely(ret < 0)) 421 421 DBG("%d: wait interrupted\n", dev->idx); ··· 426 426 } 427 427 else { 428 428 /* Polling mode */ 429 - unsigned long x = jiffies + dev->adap.timeout * HZ; 429 + unsigned long x = jiffies + dev->adap.timeout; 430 430 431 431 while (in_8(&iic->sts) & STS_PT){ 432 432 if (unlikely(time_after(jiffies, x))){ ··· 748 748 i2c_set_adapdata(adap, dev); 749 749 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 750 750 adap->algo = &iic_algo; 751 - adap->timeout = 1; 751 + adap->timeout = HZ; 752 752 753 753 ret = i2c_add_adapter(adap); 754 754 if (ret < 0) {
+1 -1
drivers/i2c/busses/i2c-iop3xx.c
··· 488 488 /* 489 489 * Default values...should these come in from board code? 490 490 */ 491 - new_adapter->timeout = 100; 491 + new_adapter->timeout = HZ; 492 492 new_adapter->algo = &iop3xx_i2c_algo; 493 493 494 494 init_waitqueue_head(&adapter_data->waitq);
+2 -2
drivers/i2c/busses/i2c-mpc.c
··· 116 116 } else { 117 117 /* Interrupt mode */ 118 118 result = wait_event_interruptible_timeout(i2c->queue, 119 - (i2c->interrupt & CSR_MIF), timeout * HZ); 119 + (i2c->interrupt & CSR_MIF), timeout); 120 120 121 121 if (unlikely(result < 0)) { 122 122 pr_debug("I2C: wait interrupted\n"); ··· 311 311 .owner = THIS_MODULE, 312 312 .name = "MPC adapter", 313 313 .algo = &mpc_algo, 314 - .timeout = 1, 314 + .timeout = HZ, 315 315 }; 316 316 317 317 static int __devinit fsl_i2c_probe(struct of_device *op, const struct of_device_id *match)
+3 -4
drivers/i2c/busses/i2c-mv64xxx.c
··· 358 358 char abort = 0; 359 359 360 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 363 spin_lock_irqsave(&drv_data->lock, flags); 364 364 if (!time_left) { /* Timed out */ ··· 374 374 spin_unlock_irqrestore(&drv_data->lock, flags); 375 375 376 376 time_left = wait_event_timeout(drv_data->waitq, 377 - !drv_data->block, 378 - msecs_to_jiffies(drv_data->adapter.timeout)); 377 + !drv_data->block, drv_data->adapter.timeout); 379 378 380 379 if ((time_left <= 0) && drv_data->block) { 381 380 drv_data->state = MV64XXX_I2C_STATE_IDLE; ··· 529 530 drv_data->adapter.algo = &mv64xxx_i2c_algo; 530 531 drv_data->adapter.owner = THIS_MODULE; 531 532 drv_data->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 532 - drv_data->adapter.timeout = pdata->timeout; 533 + drv_data->adapter.timeout = msecs_to_jiffies(pdata->timeout); 533 534 drv_data->adapter.nr = pd->id; 534 535 platform_set_drvdata(pd, drv_data); 535 536 i2c_set_adapdata(&drv_data->adapter, drv_data);