Skip to content

Commit 8fcfef6

Browse files
author
Jean Delvare
committed
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. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Wolfram Sang <w.sang@pengutronix.de>
1 parent 154d22b commit 8fcfef6

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎drivers/i2c/algos/i2c-algo-bit.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,7 @@ static int i2c_bit_prepare_bus(struct i2c_adapter *adap)
604604

605605
/* register new adapter to i2c module... */
606606
adap->algo = &i2c_bit_algo;
607-
608-
adap->timeout = 100; /* default values, should */
609-
adap->retries = 3; /* be replaced by defines */
607+
adap->retries = 3;
610608

611609
return 0;
612610
}

‎drivers/i2c/algos/i2c-algo-pcf.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
423423

424424
/* register new adapter to i2c module... */
425425
adap->algo = &pcf_algo;
426-
adap->timeout = 100;
427426

428427
if ((rval = pcf_init_8584(pcf_adap)))
429428
return rval;

‎drivers/i2c/i2c-core.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
459459
pr_debug("I2C adapter driver [%s] forgot to specify "
460460
"physical device\n", adap->name);
461461
}
462+
463+
/* Set default timeout to 1 second if not already set */
464+
if (adap->timeout == 0)
465+
adap->timeout = HZ;
466+
462467
dev_set_name(&adap->dev, "i2c-%d", adap->nr);
463468
adap->dev.release = &i2c_adapter_dev_release;
464469
adap->dev.class = &i2c_adapter_class;

0 commit comments

Comments
 (0)