mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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>
This commit is contained in:
parent
252fa60e70
commit
8927fbf481
2 changed files with 21 additions and 2 deletions
|
@ -603,6 +603,23 @@ bailout:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We print a warning when we are not flagged to support atomic transfers but
|
||||||
|
* will try anyhow. That's what the I2C core would do as well. Sadly, we can't
|
||||||
|
* modify the algorithm struct at probe time because this struct is exported
|
||||||
|
* 'const'.
|
||||||
|
*/
|
||||||
|
static int bit_xfer_atomic(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[],
|
||||||
|
int num)
|
||||||
|
{
|
||||||
|
struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
|
||||||
|
|
||||||
|
if (!adap->can_do_atomic)
|
||||||
|
dev_warn(&i2c_adap->dev, "not flagged for atomic transfers\n");
|
||||||
|
|
||||||
|
return bit_xfer(i2c_adap, msgs, num);
|
||||||
|
}
|
||||||
|
|
||||||
static u32 bit_func(struct i2c_adapter *adap)
|
static u32 bit_func(struct i2c_adapter *adap)
|
||||||
{
|
{
|
||||||
return I2C_FUNC_I2C | I2C_FUNC_NOSTART | I2C_FUNC_SMBUS_EMUL |
|
return I2C_FUNC_I2C | I2C_FUNC_NOSTART | I2C_FUNC_SMBUS_EMUL |
|
||||||
|
@ -616,6 +633,7 @@ static u32 bit_func(struct i2c_adapter *adap)
|
||||||
|
|
||||||
const struct i2c_algorithm i2c_bit_algo = {
|
const struct i2c_algorithm i2c_bit_algo = {
|
||||||
.master_xfer = bit_xfer,
|
.master_xfer = bit_xfer,
|
||||||
|
.master_xfer_atomic = bit_xfer_atomic,
|
||||||
.functionality = bit_func,
|
.functionality = bit_func,
|
||||||
};
|
};
|
||||||
EXPORT_SYMBOL(i2c_bit_algo);
|
EXPORT_SYMBOL(i2c_bit_algo);
|
||||||
|
|
|
@ -33,6 +33,7 @@ struct i2c_algo_bit_data {
|
||||||
minimum 5 us for standard-mode I2C and SMBus,
|
minimum 5 us for standard-mode I2C and SMBus,
|
||||||
maximum 50 us for SMBus */
|
maximum 50 us for SMBus */
|
||||||
int timeout; /* in jiffies */
|
int timeout; /* in jiffies */
|
||||||
|
bool can_do_atomic; /* callbacks don't sleep, we can be atomic */
|
||||||
};
|
};
|
||||||
|
|
||||||
int i2c_bit_add_bus(struct i2c_adapter *);
|
int i2c_bit_add_bus(struct i2c_adapter *);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue