Skip to contentSkip to conversation

i2c: Set a default timeout value for all adapters

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

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

PATCH 1/1 i2c: Set a default timeout value for all adapters

Setting a default timeout value on a per-algo basis doesn't make any sense. Move the default value setting to i2c-core. Individual adapter drivers can specify a different (non-zero) value if they wish.

Also express the timeout value in a way which results in the same duration regarless of the value of HZ.

---
 drivers/i2c/algos/i2c-algo-bit.c |    4 +---
 drivers/i2c/algos/i2c-algo-pcf.c |    1 -
 drivers/i2c/i2c-core.c           |    5 +++++
 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/i2c/algos/i2c-algo-bit.c +1 -3
@@ -604,9 +604,7 @@ static int i2c_bit_prepare_bus(struct i2
 
 	/* register new adapter to i2c module... */
 	adap->algo = &i2c_bit_algo;
-
-	adap->timeout = 100;	/* default values, should	*/
-	adap->retries = 3;	/* be replaced by defines	*/
+	adap->retries = 3;
 
 	return 0;
 }
drivers/i2c/algos/i2c-algo-pcf.c +0 -1
@@ -441,7 +441,6 @@ int i2c_pcf_add_bus(struct i2c_adapter *
 
 	/* register new adapter to i2c module... */
 	adap->algo = &pcf_algo;
-	adap->timeout = 100;
 
 	if ((rval = pcf_init_8584(pcf_adap)))
 		return rval;
drivers/i2c/i2c-core.c +5 -0
@@ -459,6 +459,11 @@ static int i2c_register_adapter(struct i
 		pr_debug("I2C adapter driver [%s] forgot to specify "
 			 "physical device\n", adap->name);
 	}
+
+	/* Set default timeout to 1 second if not already set */
+	if (adap->timeout == 0)
+		adap->timeout = HZ;
+
 	dev_set_name(&adap->dev, "i2c-%d", adap->nr);
 	adap->dev.release = &i2c_adapter_dev_release;
 	adap->dev.class = &i2c_adapter_class;
Signature · 1 line
Jean Delvare

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

Acked-by
#2 lore raw
Quoted 8 lines · Jean Delvare

Setting a default timeout value on a per-algo basis doesn't make any sense. Move the default value setting to i2c-core. Individual adapter drivers can specify a different (non-zero) value if they wish.

Also express the timeout value in a way which results in the same duration regarless of the value of HZ.

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |