diff options
author | Felipe Cardoso Resende <felipecardoso.fcr@gmail.com> | 2020-01-16 21:42:14 -0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-01-22 09:44:43 +0100 |
commit | 27f391a5d628f860e2245f59f97461cbd22433f1 (patch) | |
tree | 6835b36d2dde229390332e12d2148d4327680ac4 /drivers/staging | |
parent | c318f074d9fdeae16e19cbb2ed53b50d2bcdfdb8 (diff) |
Staging: kpc2000: Remove warning: "dubious: x | !y" detected by sparse
Sparse complains about "dubious: x | !y".
This patch adds some macros to make it clear if a flag will be enabled or
not so Sparse stops complaining about dubious code construct.
Signed-off-by: Felipe Cardoso Resende <felipecardoso.fcr@gmail.com>
Link: https://lore.kernel.org/r/20200117004214.GA1800@felipe-pc
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/kpc2000/kpc2000_i2c.c | 80 |
1 files changed, 44 insertions, 36 deletions
diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index 5460bf973c9c..10b9cee9bffd 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -572,6 +572,10 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, return 0; } +#define enable_flag(x) (x) +#define disable_flag(x) 0 +#define enable_flag_if(x, cond) ((cond) ? (x) : 0) + static u32 i801_func(struct i2c_adapter *adapter) { struct i2c_device *priv = i2c_get_adapdata(adapter); @@ -588,42 +592,42 @@ static u32 i801_func(struct i2c_adapter *adapter) // http://lxr.free-electrons.com/source/include/uapi/linux/i2c.h#L85 u32 f = - I2C_FUNC_I2C | /* 0x00000001(I enabled this - * one) - */ - !I2C_FUNC_10BIT_ADDR | /* 0x00000002 */ - !I2C_FUNC_PROTOCOL_MANGLING | /* 0x00000004 */ - ((priv->features & FEATURE_SMBUS_PEC) ? - I2C_FUNC_SMBUS_PEC : 0) | /* 0x00000008 */ - !I2C_FUNC_SMBUS_BLOCK_PROC_CALL | /* 0x00008000 */ - I2C_FUNC_SMBUS_QUICK | /* 0x00010000 */ - !I2C_FUNC_SMBUS_READ_BYTE | /* 0x00020000 */ - !I2C_FUNC_SMBUS_WRITE_BYTE | /* 0x00040000 */ - !I2C_FUNC_SMBUS_READ_BYTE_DATA | /* 0x00080000 */ - !I2C_FUNC_SMBUS_WRITE_BYTE_DATA | /* 0x00100000 */ - !I2C_FUNC_SMBUS_READ_WORD_DATA | /* 0x00200000 */ - !I2C_FUNC_SMBUS_WRITE_WORD_DATA | /* 0x00400000 */ - !I2C_FUNC_SMBUS_PROC_CALL | /* 0x00800000 */ - !I2C_FUNC_SMBUS_READ_BLOCK_DATA | /* 0x01000000 */ - !I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | /* 0x02000000 */ - ((priv->features & FEATURE_I2C_BLOCK_READ) ? - I2C_FUNC_SMBUS_READ_I2C_BLOCK : 0) | /* 0x04000000 */ - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK | /* 0x08000000 */ - - I2C_FUNC_SMBUS_BYTE | /* _READ_BYTE _WRITE_BYTE */ - I2C_FUNC_SMBUS_BYTE_DATA | /* _READ_BYTE_DATA - * _WRITE_BYTE_DATA - */ - I2C_FUNC_SMBUS_WORD_DATA | /* _READ_WORD_DATA - * _WRITE_WORD_DATA - */ - I2C_FUNC_SMBUS_BLOCK_DATA | /* _READ_BLOCK_DATA - * _WRITE_BLOCK_DATA - */ - !I2C_FUNC_SMBUS_I2C_BLOCK | /* _READ_I2C_BLOCK - * _WRITE_I2C_BLOCK - */ - !I2C_FUNC_SMBUS_EMUL; /* _QUICK _BYTE + enable_flag(I2C_FUNC_I2C) | /* 0x00000001(I enabled this one) */ + disable_flag(I2C_FUNC_10BIT_ADDR) | /* 0x00000002 */ + disable_flag(I2C_FUNC_PROTOCOL_MANGLING) | /* 0x00000004 */ + enable_flag_if(I2C_FUNC_SMBUS_PEC, + priv->features & FEATURE_SMBUS_PEC) | + /* 0x00000008 */ + disable_flag(I2C_FUNC_SMBUS_BLOCK_PROC_CALL) | /* 0x00008000 */ + enable_flag(I2C_FUNC_SMBUS_QUICK) | /* 0x00010000 */ + disable_flag(I2C_FUNC_SMBUS_READ_BYTE) | /* 0x00020000 */ + disable_flag(I2C_FUNC_SMBUS_WRITE_BYTE) | /* 0x00040000 */ + disable_flag(I2C_FUNC_SMBUS_READ_BYTE_DATA) | /* 0x00080000 */ + disable_flag(I2C_FUNC_SMBUS_WRITE_BYTE_DATA) | /* 0x00100000 */ + disable_flag(I2C_FUNC_SMBUS_READ_WORD_DATA) | /* 0x00200000 */ + disable_flag(I2C_FUNC_SMBUS_WRITE_WORD_DATA) | /* 0x00400000 */ + disable_flag(I2C_FUNC_SMBUS_PROC_CALL) | /* 0x00800000 */ + disable_flag(I2C_FUNC_SMBUS_READ_BLOCK_DATA) | /* 0x01000000 */ + disable_flag(I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) | /* 0x02000000 */ + enable_flag_if(I2C_FUNC_SMBUS_READ_I2C_BLOCK, + priv->features & FEATURE_I2C_BLOCK_READ) | + /* 0x04000000 */ + enable_flag(I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) | /* 0x08000000 */ + + enable_flag(I2C_FUNC_SMBUS_BYTE) | /* _READ_BYTE _WRITE_BYTE */ + enable_flag(I2C_FUNC_SMBUS_BYTE_DATA) | /* _READ_BYTE_DATA + * _WRITE_BYTE_DATA + */ + enable_flag(I2C_FUNC_SMBUS_WORD_DATA) | /* _READ_WORD_DATA + * _WRITE_WORD_DATA + */ + enable_flag(I2C_FUNC_SMBUS_BLOCK_DATA) | /* _READ_BLOCK_DATA + * _WRITE_BLOCK_DATA + */ + disable_flag(I2C_FUNC_SMBUS_I2C_BLOCK) | /* _READ_I2C_BLOCK + * _WRITE_I2C_BLOCK + */ + disable_flag(I2C_FUNC_SMBUS_EMUL); /* _QUICK _BYTE * _BYTE_DATA _WORD_DATA * _PROC_CALL * _WRITE_BLOCK_DATA @@ -632,6 +636,10 @@ static u32 i801_func(struct i2c_adapter *adapter) return f; } +#undef enable_flag +#undef disable_flag +#undef enable_flag_if + static const struct i2c_algorithm smbus_algorithm = { .smbus_xfer = i801_access, .functionality = i801_func, |