Commit ffd3d336 authored by Alex Deucher's avatar Alex Deucher

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=66241Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
parent 53dc0b0c
...@@ -44,7 +44,7 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan, ...@@ -44,7 +44,7 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan,
PROCESS_I2C_CHANNEL_TRANSACTION_PS_ALLOCATION args; PROCESS_I2C_CHANNEL_TRANSACTION_PS_ALLOCATION args;
int index = GetIndexIntoMasterTable(COMMAND, ProcessI2cChannelTransaction); int index = GetIndexIntoMasterTable(COMMAND, ProcessI2cChannelTransaction);
unsigned char *base; unsigned char *base;
u16 out; u16 out = cpu_to_le16(0);
memset(&args, 0, sizeof(args)); memset(&args, 0, sizeof(args));
...@@ -55,11 +55,14 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan, ...@@ -55,11 +55,14 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan,
DRM_ERROR("hw i2c: tried to write too many bytes (%d vs 3)\n", num); DRM_ERROR("hw i2c: tried to write too many bytes (%d vs 3)\n", num);
return -EINVAL; return -EINVAL;
} }
if (buf == NULL)
args.ucRegIndex = 0;
else
args.ucRegIndex = buf[0]; args.ucRegIndex = buf[0];
if (num > 1) { if (num)
num--; num--;
if (num)
memcpy(&out, &buf[1], num); memcpy(&out, &buf[1], num);
}
args.lpI2CDataOut = cpu_to_le16(out); args.lpI2CDataOut = cpu_to_le16(out);
} else { } else {
if (num > ATOM_MAX_HW_I2C_READ) { if (num > ATOM_MAX_HW_I2C_READ) {
...@@ -96,14 +99,14 @@ int radeon_atom_hw_i2c_xfer(struct i2c_adapter *i2c_adap, ...@@ -96,14 +99,14 @@ int radeon_atom_hw_i2c_xfer(struct i2c_adapter *i2c_adap,
struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap);
struct i2c_msg *p; struct i2c_msg *p;
int i, remaining, current_count, buffer_offset, max_bytes, ret; int i, remaining, current_count, buffer_offset, max_bytes, ret;
u8 buf = 0, flags; u8 flags;
/* check for bus probe */ /* check for bus probe */
p = &msgs[0]; p = &msgs[0];
if ((num == 1) && (p->len == 0)) { if ((num == 1) && (p->len == 0)) {
ret = radeon_process_i2c_ch(i2c, ret = radeon_process_i2c_ch(i2c,
p->addr, HW_I2C_WRITE, p->addr, HW_I2C_WRITE,
&buf, 1); NULL, 0);
if (ret) if (ret)
return ret; return ret;
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment