Skip to contentSkip to conversation

i2c-davinci: Fix timeout handling

PATCH In review Jean Delvare 2 participants 2 messages Feb 23, 2009 – Feb 24, 2009 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c-davinci: Fix timeout handling

Properly set the adapter timeout value in jiffies, and then use that value in the driver, rather than a hard-coded constant.

Cc Troy Kisky <[email protected]>
Cc Kevin Hilman <[email protected]>

---
Troy, Kevin, can either of you please review, build test and run test this patch? Thanks.

 drivers/i2c/busses/i2c-davinci.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-davinci.c +3 -5
@@ -216,7 +216,7 @@ static int i2c_davinci_wait_bus_not_busy
 {
 	unsigned long timeout;
 
-	timeout = jiffies + DAVINCI_I2C_TIMEOUT;
+	timeout = jiffies + dev->adapter.timeout;
 	while (davinci_i2c_read_reg(dev, DAVINCI_I2C_STR_REG)
 	       & DAVINCI_I2C_STR_BB) {
 		if (time_after(jiffies, timeout)) {
@@ -289,7 +289,7 @@ i2c_davinci_xfer_msg(struct i2c_adapter
 	davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag);
 
 	r = wait_for_completion_interruptible_timeout(&dev->cmd_complete,
-						      DAVINCI_I2C_TIMEOUT);
+						      dev->adapter.timeout);
 	if (r == 0) {
 		dev_err(dev->dev, "controller timed out\n");
 		i2c_davinci_init(dev);
@@ -546,9 +546,7 @@ static int davinci_i2c_probe(struct plat
 	strlcpy(adap->name, "DaVinci I2C adapter", sizeof(adap->name));
 	adap->algo = &i2c_davinci_algo;
 	adap->dev.parent = &pdev->dev;
-
-	/* FIXME */
-	adap->timeout = 1;
+	adap->timeout = DAVINCI_I2C_TIMEOUT;
 
 	adap->nr = pdev->id;
 	r = i2c_add_numbered_adapter(adap);
Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 35 lines · Jean Delvare

Properly set the adapter timeout value in jiffies, and then use that value in the driver, rather than a hard-coded constant.

Cc Troy Kisky <[email protected]>
Cc Kevin Hilman <[email protected]>

---
Troy, Kevin, can either of you please review, build test and run test this patch? Thanks.

 drivers/i2c/busses/i2c-davinci.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-davinci.c +2 -2
@@ -216,7 +216,7 @@ static int i2c_davinci_wait_bus_not_busy
 {
 	unsigned long timeout;
 
-	timeout = jiffies + DAVINCI_I2C_TIMEOUT;
+	timeout = jiffies + dev->adapter.timeout;
 	while (davinci_i2c_read_reg(dev, DAVINCI_I2C_STR_REG)
 	       & DAVINCI_I2C_STR_BB) {
 		if (time_after(jiffies, timeout)) {
@@ -289,7 +289,7 @@ i2c_davinci_xfer_msg(struct i2c_adapter
 	davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag);
 
 	r = wait_for_completion_interruptible_timeout(&dev->cmd_complete,
-						      DAVINCI_I2C_TIMEOUT);
+						      dev->adapter.timeout);
 	if (r == 0) {
 		dev_err(dev->dev, "controller timed out\n");
 		i2c_davinci_init(dev);

drivers/i2c/busses/i2c-davinci.c static int davinci_i2c_probe(struct plat · line 552

Quoted 10 lines
drivers/i2c/busses/i2c-davinci.c +1 -3
@@ -546,9 +546,7 @@ static int davinci_i2c_probe(struct plat
 	strlcpy(adap->name, "DaVinci I2C adapter", sizeof(adap->name));
 	adap->algo = &i2c_davinci_algo;
 	adap->dev.parent = &pdev->dev;
-
-	/* FIXME */
-	adap->timeout = 1;
+	adap->timeout = DAVINCI_I2C_TIMEOUT;
 
 	adap->nr = pdev->id;
 	r = i2c_add_numbered_adapter(adap);

I tested this without issues.

Thanks
Troy