Skip to content

Commit 3dd2207

Browse files
author
Wolfram Sang
committed
Merge tag 'i2c-host-fixes-6.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux into i2c/for-current
i2c-host-fixes for v6.17-rc3 - hisi: update maintainership - rtl9300: fix several issues in xfer - check message length boundaries - correct multi-byte value composition on write - increase polling timeout - fix block transfer protocol
2 parents c17b750 + 82b350d commit 3dd2207

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11013,7 +11013,7 @@ F: Documentation/admin-guide/perf/hns3-pmu.rst
1101311013
F: drivers/perf/hisilicon/hns3_pmu.c
1101411014

1101511015
HISILICON I2C CONTROLLER DRIVER
11016-
M: Yicong Yang <yangyicong@hisilicon.com>
11016+
M: Devyn Liu <liudingyuan@h-partners.com>
1101711017
1101811018
S: Maintained
1101911019
W: https://www.hisilicon.com

drivers/i2c/busses/i2c-rtl9300.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ static int rtl9300_i2c_write(struct rtl9300_i2c *i2c, u8 *buf, int len)
143143
return -EIO;
144144

145145
for (i = 0; i < len; i++) {
146-
if (i % 4 == 0)
147-
vals[i/4] = 0;
148-
vals[i/4] <<= 8;
149-
vals[i/4] |= buf[i];
146+
unsigned int shift = (i % 4) * 8;
147+
unsigned int reg = i / 4;
148+
149+
vals[reg] |= buf[i] << shift;
150150
}
151151

152152
return regmap_bulk_write(i2c->regmap, i2c->reg_base + RTL9300_I2C_MST_DATA_WORD0,
@@ -175,7 +175,7 @@ static int rtl9300_i2c_execute_xfer(struct rtl9300_i2c *i2c, char read_write,
175175
return ret;
176176

177177
ret = regmap_read_poll_timeout(i2c->regmap, i2c->reg_base + RTL9300_I2C_MST_CTRL1,
178-
val, !(val & RTL9300_I2C_MST_CTRL1_I2C_TRIG), 100, 2000);
178+
val, !(val & RTL9300_I2C_MST_CTRL1_I2C_TRIG), 100, 100000);
179179
if (ret)
180180
return ret;
181181

@@ -281,15 +281,19 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s
281281
ret = rtl9300_i2c_reg_addr_set(i2c, command, 1);
282282
if (ret)
283283
goto out_unlock;
284-
ret = rtl9300_i2c_config_xfer(i2c, chan, addr, data->block[0]);
284+
if (data->block[0] < 1 || data->block[0] > I2C_SMBUS_BLOCK_MAX) {
285+
ret = -EINVAL;
286+
goto out_unlock;
287+
}
288+
ret = rtl9300_i2c_config_xfer(i2c, chan, addr, data->block[0] + 1);
285289
if (ret)
286290
goto out_unlock;
287291
if (read_write == I2C_SMBUS_WRITE) {
288-
ret = rtl9300_i2c_write(i2c, &data->block[1], data->block[0]);
292+
ret = rtl9300_i2c_write(i2c, &data->block[0], data->block[0] + 1);
289293
if (ret)
290294
goto out_unlock;
291295
}
292-
len = data->block[0];
296+
len = data->block[0] + 1;
293297
break;
294298

295299
default:

0 commit comments

Comments
 (0)