Skip to content

Commit ffd3d33

Browse files
committed
drm/radeon/atom: fix bus probes when hw_i2c is set (v2)
When probing the bus, we need to set the byte count to 0 rather than 1. v2: Don't count the first byte. bug: https://bugzilla.kernel.org/show_bug.cgi?id=66241 Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
1 parent 53dc0b0 commit ffd3d33

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

‎drivers/gpu/drm/radeon/atombios_i2c.c‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan,
4444
PROCESS_I2C_CHANNEL_TRANSACTION_PS_ALLOCATION args;
4545
int index = GetIndexIntoMasterTable(COMMAND, ProcessI2cChannelTransaction);
4646
unsigned char *base;
47-
u16 out;
47+
u16 out = cpu_to_le16(0);
4848

4949
memset(&args, 0, sizeof(args));
5050

@@ -55,11 +55,14 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan,
5555
DRM_ERROR("hw i2c: tried to write too many bytes (%d vs 3)\n", num);
5656
return -EINVAL;
5757
}
58-
args.ucRegIndex = buf[0];
59-
if (num > 1) {
58+
if (buf == NULL)
59+
args.ucRegIndex = 0;
60+
else
61+
args.ucRegIndex = buf[0];
62+
if (num)
6063
num--;
64+
if (num)
6165
memcpy(&out, &buf[1], num);
62-
}
6366
args.lpI2CDataOut = cpu_to_le16(out);
6467
} else {
6568
if (num > ATOM_MAX_HW_I2C_READ) {
@@ -96,14 +99,14 @@ int radeon_atom_hw_i2c_xfer(struct i2c_adapter *i2c_adap,
9699
struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap);
97100
struct i2c_msg *p;
98101
int i, remaining, current_count, buffer_offset, max_bytes, ret;
99-
u8 buf = 0, flags;
102+
u8 flags;
100103

101104
/* check for bus probe */
102105
p = &msgs[0];
103106
if ((num == 1) && (p->len == 0)) {
104107
ret = radeon_process_i2c_ch(i2c,
105108
p->addr, HW_I2C_WRITE,
106-
&buf, 1);
109+
NULL, 0);
107110
if (ret)
108111
return ret;
109112
else

0 commit comments

Comments
 (0)