summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2019-04-03 08:40:18 -0400
committerWolfram Sang <wsa@the-dreams.de>2019-04-16 07:08:16 -0400
commit8927fbf481248954ca1fc5e652171936b94905ac (patch)
tree4369d913802a91c0a21ed3d911fa3cf2dfb423b3
parent252fa60e7054d22c039757d3ef72191d4eb58577 (diff)
i2c: algo: bit: add flag to whitelist atomic transfers
Use the new xfer_atomic callback to check a newly introduced flag to whitelist atomic transfers. This will report configurations which worked accidently. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--drivers/i2c/algos/i2c-algo-bit.c22
-rw-r--r--include/linux/i2c-algo-bit.h1
2 files changed, 21 insertions, 2 deletions
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index 5e5990a83da5..913db013fe90 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -603,6 +603,23 @@ bailout:
603 return ret; 603 return ret;
604} 604}
605 605
606/*
607 * We print a warning when we are not flagged to support atomic transfers but
608 * will try anyhow. That's what the I2C core would do as well. Sadly, we can't
609 * modify the algorithm struct at probe time because this struct is exported
610 * 'const'.
611 */
612static int bit_xfer_atomic(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[],
613 int num)
614{
615 struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
616
617 if (!adap->can_do_atomic)
618 dev_warn(&i2c_adap->dev, "not flagged for atomic transfers\n");
619
620 return bit_xfer(i2c_adap, msgs, num);
621}
622
606static u32 bit_func(struct i2c_adapter *adap) 623static u32 bit_func(struct i2c_adapter *adap)
607{ 624{
608 return I2C_FUNC_I2C | I2C_FUNC_NOSTART | I2C_FUNC_SMBUS_EMUL | 625 return I2C_FUNC_I2C | I2C_FUNC_NOSTART | I2C_FUNC_SMBUS_EMUL |
@@ -615,8 +632,9 @@ static u32 bit_func(struct i2c_adapter *adap)
615/* -----exported algorithm data: ------------------------------------- */ 632/* -----exported algorithm data: ------------------------------------- */
616 633
617const struct i2c_algorithm i2c_bit_algo = { 634const struct i2c_algorithm i2c_bit_algo = {
618 .master_xfer = bit_xfer, 635 .master_xfer = bit_xfer,
619 .functionality = bit_func, 636 .master_xfer_atomic = bit_xfer_atomic,
637 .functionality = bit_func,
620}; 638};
621EXPORT_SYMBOL(i2c_bit_algo); 639EXPORT_SYMBOL(i2c_bit_algo);
622 640
diff --git a/include/linux/i2c-algo-bit.h b/include/linux/i2c-algo-bit.h
index 69045df78e2d..7fd5575a368f 100644
--- a/include/linux/i2c-algo-bit.h
+++ b/include/linux/i2c-algo-bit.h
@@ -33,6 +33,7 @@ struct i2c_algo_bit_data {
33 minimum 5 us for standard-mode I2C and SMBus, 33 minimum 5 us for standard-mode I2C and SMBus,
34 maximum 50 us for SMBus */ 34 maximum 50 us for SMBus */
35 int timeout; /* in jiffies */ 35 int timeout; /* in jiffies */
36 bool can_do_atomic; /* callbacks don't sleep, we can be atomic */
36}; 37};
37 38
38int i2c_bit_add_bus(struct i2c_adapter *); 39int i2c_bit_add_bus(struct i2c_adapter *);