Commit 8a52c6b4 authored by Jean Delvare's avatar Jean Delvare

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: default avatarJean Delvare <khali@linux-fr.org>
Cc: Clifford Wolf <clifford@clifford.at>
Acked-by: default avatarSean MacLennan <smaclennan@pikatech.com>
Cc: Stefan Roese <sr@denx.de>
Acked-by: default avatarLennert Buytenhek <kernel@wantstofly.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Acked-by: default avatarMark A. Greer <mgreer@mvista.com>
parent 8fcfef6e
...@@ -415,7 +415,7 @@ static int iic_wait_for_tc(struct ibm_iic_private* dev){ ...@@ -415,7 +415,7 @@ static int iic_wait_for_tc(struct ibm_iic_private* dev){
if (dev->irq >= 0){ if (dev->irq >= 0){
/* Interrupt mode */ /* Interrupt mode */
ret = wait_event_interruptible_timeout(dev->wq, ret = wait_event_interruptible_timeout(dev->wq,
!(in_8(&iic->sts) & STS_PT), dev->adap.timeout * HZ); !(in_8(&iic->sts) & STS_PT), dev->adap.timeout);
if (unlikely(ret < 0)) if (unlikely(ret < 0))
DBG("%d: wait interrupted\n", dev->idx); DBG("%d: wait interrupted\n", dev->idx);
...@@ -426,7 +426,7 @@ static int iic_wait_for_tc(struct ibm_iic_private* dev){ ...@@ -426,7 +426,7 @@ static int iic_wait_for_tc(struct ibm_iic_private* dev){
} }
else { else {
/* Polling mode */ /* Polling mode */
unsigned long x = jiffies + dev->adap.timeout * HZ; unsigned long x = jiffies + dev->adap.timeout;
while (in_8(&iic->sts) & STS_PT){ while (in_8(&iic->sts) & STS_PT){
if (unlikely(time_after(jiffies, x))){ if (unlikely(time_after(jiffies, x))){
...@@ -748,7 +748,7 @@ static int __devinit iic_probe(struct of_device *ofdev, ...@@ -748,7 +748,7 @@ static int __devinit iic_probe(struct of_device *ofdev,
i2c_set_adapdata(adap, dev); i2c_set_adapdata(adap, dev);
adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
adap->algo = &iic_algo; adap->algo = &iic_algo;
adap->timeout = 1; adap->timeout = HZ;
ret = i2c_add_adapter(adap); ret = i2c_add_adapter(adap);
if (ret < 0) { if (ret < 0) {
......
...@@ -488,7 +488,7 @@ iop3xx_i2c_probe(struct platform_device *pdev) ...@@ -488,7 +488,7 @@ iop3xx_i2c_probe(struct platform_device *pdev)
/* /*
* Default values...should these come in from board code? * Default values...should these come in from board code?
*/ */
new_adapter->timeout = 100; new_adapter->timeout = HZ;
new_adapter->algo = &iop3xx_i2c_algo; new_adapter->algo = &iop3xx_i2c_algo;
init_waitqueue_head(&adapter_data->waitq); init_waitqueue_head(&adapter_data->waitq);
......
...@@ -116,7 +116,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing) ...@@ -116,7 +116,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
} else { } else {
/* Interrupt mode */ /* Interrupt mode */
result = wait_event_interruptible_timeout(i2c->queue, result = wait_event_interruptible_timeout(i2c->queue,
(i2c->interrupt & CSR_MIF), timeout * HZ); (i2c->interrupt & CSR_MIF), timeout);
if (unlikely(result < 0)) { if (unlikely(result < 0)) {
pr_debug("I2C: wait interrupted\n"); pr_debug("I2C: wait interrupted\n");
...@@ -311,7 +311,7 @@ static struct i2c_adapter mpc_ops = { ...@@ -311,7 +311,7 @@ static struct i2c_adapter mpc_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "MPC adapter", .name = "MPC adapter",
.algo = &mpc_algo, .algo = &mpc_algo,
.timeout = 1, .timeout = HZ,
}; };
static int __devinit fsl_i2c_probe(struct of_device *op, const struct of_device_id *match) static int __devinit fsl_i2c_probe(struct of_device *op, const struct of_device_id *match)
......
...@@ -358,7 +358,7 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data) ...@@ -358,7 +358,7 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
char abort = 0; char abort = 0;
time_left = wait_event_interruptible_timeout(drv_data->waitq, time_left = wait_event_interruptible_timeout(drv_data->waitq,
!drv_data->block, msecs_to_jiffies(drv_data->adapter.timeout)); !drv_data->block, drv_data->adapter.timeout);
spin_lock_irqsave(&drv_data->lock, flags); spin_lock_irqsave(&drv_data->lock, flags);
if (!time_left) { /* Timed out */ if (!time_left) { /* Timed out */
...@@ -374,8 +374,7 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data) ...@@ -374,8 +374,7 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
spin_unlock_irqrestore(&drv_data->lock, flags); spin_unlock_irqrestore(&drv_data->lock, flags);
time_left = wait_event_timeout(drv_data->waitq, time_left = wait_event_timeout(drv_data->waitq,
!drv_data->block, !drv_data->block, drv_data->adapter.timeout);
msecs_to_jiffies(drv_data->adapter.timeout));
if ((time_left <= 0) && drv_data->block) { if ((time_left <= 0) && drv_data->block) {
drv_data->state = MV64XXX_I2C_STATE_IDLE; drv_data->state = MV64XXX_I2C_STATE_IDLE;
...@@ -530,7 +529,7 @@ mv64xxx_i2c_probe(struct platform_device *pd) ...@@ -530,7 +529,7 @@ mv64xxx_i2c_probe(struct platform_device *pd)
drv_data->adapter.algo = &mv64xxx_i2c_algo; drv_data->adapter.algo = &mv64xxx_i2c_algo;
drv_data->adapter.owner = THIS_MODULE; drv_data->adapter.owner = THIS_MODULE;
drv_data->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; drv_data->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
drv_data->adapter.timeout = pdata->timeout; drv_data->adapter.timeout = msecs_to_jiffies(pdata->timeout);
drv_data->adapter.nr = pd->id; drv_data->adapter.nr = pd->id;
platform_set_drvdata(pd, drv_data); platform_set_drvdata(pd, drv_data);
i2c_set_adapdata(&drv_data->adapter, drv_data); i2c_set_adapdata(&drv_data->adapter, drv_data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment