i2c: quirks: add zero length checks

Some adapters do not support a message length of 0. Add this as a quirk
so drivers don't have to open code it.

Signed-off-by: Wolfram Sang <[email protected]>
Reviewed-by: Niklas Söderlund <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Tested-by: Jarkko Nikula <[email protected]>
Acked-by: Jarkko Nikula <[email protected]>
Signed-off-by: Wolfram Sang <[email protected]>
This commit is contained in:
Wolfram Sang 2018-07-23 22:26:05 +02:00 • committed by Wolfram Sang
commit d9cfe2ce24
2 changed files with 10 additions and 0 deletions

View file

@ -1839,9 +1839,15 @@ static int i2c_check_for_quirks(struct i2c_adapter *adap, struct i2c_msg *msgs,
if (msgs[i].flags & I2C_M_RD) {
if (do_len_check && i2c_quirk_exceeded(len, q->max_read_len))
return i2c_quirk_error(adap, &msgs[i], "msg too long");
if (q->flags & I2C_AQ_NO_ZERO_LEN_READ && len == 0)
return i2c_quirk_error(adap, &msgs[i], "no zero length");
} else {
if (do_len_check && i2c_quirk_exceeded(len, q->max_write_len))
return i2c_quirk_error(adap, &msgs[i], "msg too long");
if (q->flags & I2C_AQ_NO_ZERO_LEN_WRITE && len == 0)
return i2c_quirk_error(adap, &msgs[i], "no zero length");
}
}