[PATCH 5.1 41/70] i2c: xiic: Add max_read_len quirk

From: Greg Kroah-Hartman
Date: Sun Jun 09 2019 - 12:51:25 EST

From: Robert Hancock <hancock@xxxxxxxxxxxxx>

commit 49b809586730a77b57ce620b2f9689de765d790b upstream.

This driver does not support reading more than 255 bytes at once because
the register for storing the number of bytes to read is only 8 bits. Add
a max_read_len quirk to enforce this.

This was found when using this driver with the SFP driver, which was
previously reading all 256 bytes in the SFP EEPROM in one transaction.
This caused a bunch of hard-to-debug errors in the xiic driver since the
driver/logic was treating the number of bytes to read as zero.
Rejecting transactions that aren't supported at least allows the problem
to be diagnosed more easily.

Signed-off-by: Robert Hancock <hancock@xxxxxxxxxxxxx>
Reviewed-by: Michal Simek <michal.simek@xxxxxxxxxx>
Signed-off-by: Wolfram Sang <wsa@xxxxxxxxxxxxx>
Cc: stable@xxxxxxxxxx
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

drivers/i2c/busses/i2c-xiic.c | 5 +++++
1 file changed, 5 insertions(+)

--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -718,11 +718,16 @@ static const struct i2c_algorithm xiic_a
.functionality = xiic_func,

+static const struct i2c_adapter_quirks xiic_quirks = {
+ .max_read_len = 255,
static const struct i2c_adapter xiic_adapter = {
.owner = THIS_MODULE,
.name = DRIVER_NAME,
.algo = &xiic_algorithm,
+ .quirks = &xiic_quirks,