Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

i2c: rtl9300: introduce max length property to driver data

In RTL9607C i2c controller, theoretical maximum the data length
can be is 4 bytes as opposed to 16 bytes on rtl9300 and rtl9310.

Introduce a new property to the driver data struct for that.
Adjust if statement in prepare_xfer function to follow that new
property instead of the hardcoded value.

Signed-off-by: Rustam Adilov <adilov@disroot.org>
Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20260401180648.337834-3-adilov@disroot.org

authored by

Rustam Adilov and committed by
Andi Shyti
98773df6 4c53b2eb

+8 -1
+8 -1
drivers/i2c/busses/i2c-rtl9300.c
··· 64 64 u32 rd_reg; 65 65 u32 wd_reg; 66 66 u8 max_nchan; 67 + u8 max_data_len; 67 68 }; 68 69 69 70 #define RTL9300_I2C_MUX_NCHAN 8 70 71 #define RTL9310_I2C_MUX_NCHAN 12 72 + 73 + #define RTL9300_I2C_MAX_DATA_LEN 16 71 74 72 75 struct rtl9300_i2c { 73 76 struct regmap *regmap; ··· 213 210 214 211 static int rtl9300_i2c_prepare_xfer(struct rtl9300_i2c *i2c, struct rtl9300_i2c_xfer *xfer) 215 212 { 213 + const struct rtl9300_i2c_drv_data *drv_data; 216 214 int ret; 217 215 218 - if (xfer->data_len < 1 || xfer->data_len > 16) 216 + drv_data = device_get_match_data(i2c->dev); 217 + if (xfer->data_len < 1 || xfer->data_len > drv_data->max_data_len) 219 218 return -EINVAL; 220 219 221 220 ret = regmap_field_write(i2c->fields[F_DEV_ADDR], xfer->dev_addr); ··· 510 505 .rd_reg = RTL9300_I2C_MST_DATA_WORD0, 511 506 .wd_reg = RTL9300_I2C_MST_DATA_WORD0, 512 507 .max_nchan = RTL9300_I2C_MUX_NCHAN, 508 + .max_data_len = RTL9300_I2C_MAX_DATA_LEN, 513 509 }; 514 510 515 511 static const struct rtl9300_i2c_drv_data rtl9310_i2c_drv_data = { ··· 532 526 .rd_reg = RTL9310_I2C_MST_DATA_CTRL, 533 527 .wd_reg = RTL9310_I2C_MST_DATA_CTRL, 534 528 .max_nchan = RTL9310_I2C_MUX_NCHAN, 529 + .max_data_len = RTL9300_I2C_MAX_DATA_LEN, 535 530 }; 536 531 537 532 static const struct of_device_id i2c_rtl9300_dt_ids[] = {