diff options
Diffstat (limited to 'drivers/gpu/drm/radeon/atombios_i2c.c')
-rw-r--r-- | drivers/gpu/drm/radeon/atombios_i2c.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/gpu/drm/radeon/atombios_i2c.c b/drivers/gpu/drm/radeon/atombios_i2c.c index 0652ee0a2098..f685035dbe39 100644 --- a/drivers/gpu/drm/radeon/atombios_i2c.c +++ b/drivers/gpu/drm/radeon/atombios_i2c.c | |||
@@ -44,7 +44,7 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan, | |||
44 | PROCESS_I2C_CHANNEL_TRANSACTION_PS_ALLOCATION args; | 44 | PROCESS_I2C_CHANNEL_TRANSACTION_PS_ALLOCATION args; |
45 | int index = GetIndexIntoMasterTable(COMMAND, ProcessI2cChannelTransaction); | 45 | int index = GetIndexIntoMasterTable(COMMAND, ProcessI2cChannelTransaction); |
46 | unsigned char *base; | 46 | unsigned char *base; |
47 | u16 out; | 47 | u16 out = cpu_to_le16(0); |
48 | 48 | ||
49 | memset(&args, 0, sizeof(args)); | 49 | memset(&args, 0, sizeof(args)); |
50 | 50 | ||
@@ -55,11 +55,14 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan, | |||
55 | DRM_ERROR("hw i2c: tried to write too many bytes (%d vs 3)\n", num); | 55 | DRM_ERROR("hw i2c: tried to write too many bytes (%d vs 3)\n", num); |
56 | return -EINVAL; | 56 | return -EINVAL; |
57 | } | 57 | } |
58 | args.ucRegIndex = buf[0]; | 58 | if (buf == NULL) |
59 | if (num > 1) { | 59 | args.ucRegIndex = 0; |
60 | else | ||
61 | args.ucRegIndex = buf[0]; | ||
62 | if (num) | ||
60 | num--; | 63 | num--; |
64 | if (num) | ||
61 | memcpy(&out, &buf[1], num); | 65 | memcpy(&out, &buf[1], num); |
62 | } | ||
63 | args.lpI2CDataOut = cpu_to_le16(out); | 66 | args.lpI2CDataOut = cpu_to_le16(out); |
64 | } else { | 67 | } else { |
65 | if (num > ATOM_MAX_HW_I2C_READ) { | 68 | if (num > ATOM_MAX_HW_I2C_READ) { |
@@ -96,14 +99,14 @@ int radeon_atom_hw_i2c_xfer(struct i2c_adapter *i2c_adap, | |||
96 | struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); | 99 | struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); |
97 | struct i2c_msg *p; | 100 | struct i2c_msg *p; |
98 | int i, remaining, current_count, buffer_offset, max_bytes, ret; | 101 | int i, remaining, current_count, buffer_offset, max_bytes, ret; |
99 | u8 buf = 0, flags; | 102 | u8 flags; |
100 | 103 | ||
101 | /* check for bus probe */ | 104 | /* check for bus probe */ |
102 | p = &msgs[0]; | 105 | p = &msgs[0]; |
103 | if ((num == 1) && (p->len == 0)) { | 106 | if ((num == 1) && (p->len == 0)) { |
104 | ret = radeon_process_i2c_ch(i2c, | 107 | ret = radeon_process_i2c_ch(i2c, |
105 | p->addr, HW_I2C_WRITE, | 108 | p->addr, HW_I2C_WRITE, |
106 | &buf, 1); | 109 | NULL, 0); |
107 | if (ret) | 110 | if (ret) |
108 | return ret; | 111 | return ret; |
109 | else | 112 | else |