Commit 8a61bc08 authored by Harry Wentland's avatar Harry Wentland Committed by Alex Deucher

drm/amd/display: Don't return ddc result and read_bytes in same return value

The two ranges overlap.
Signed-off-by: default avatarHarry Wentland <harry.wentland@amd.com>
Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent d6605783
...@@ -83,21 +83,22 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux, ...@@ -83,21 +83,22 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
enum i2c_mot_mode mot = (msg->request & DP_AUX_I2C_MOT) ? enum i2c_mot_mode mot = (msg->request & DP_AUX_I2C_MOT) ?
I2C_MOT_TRUE : I2C_MOT_FALSE; I2C_MOT_TRUE : I2C_MOT_FALSE;
enum ddc_result res; enum ddc_result res;
ssize_t read_bytes; uint32_t read_bytes = msg->size;
if (WARN_ON(msg->size > 16)) if (WARN_ON(msg->size > 16))
return -E2BIG; return -E2BIG;
switch (msg->request & ~DP_AUX_I2C_MOT) { switch (msg->request & ~DP_AUX_I2C_MOT) {
case DP_AUX_NATIVE_READ: case DP_AUX_NATIVE_READ:
read_bytes = dal_ddc_service_read_dpcd_data( res = dal_ddc_service_read_dpcd_data(
TO_DM_AUX(aux)->ddc_service, TO_DM_AUX(aux)->ddc_service,
false, false,
I2C_MOT_UNDEF, I2C_MOT_UNDEF,
msg->address, msg->address,
msg->buffer, msg->buffer,
msg->size); msg->size,
return read_bytes; &read_bytes);
break;
case DP_AUX_NATIVE_WRITE: case DP_AUX_NATIVE_WRITE:
res = dal_ddc_service_write_dpcd_data( res = dal_ddc_service_write_dpcd_data(
TO_DM_AUX(aux)->ddc_service, TO_DM_AUX(aux)->ddc_service,
...@@ -108,14 +109,15 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux, ...@@ -108,14 +109,15 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
msg->size); msg->size);
break; break;
case DP_AUX_I2C_READ: case DP_AUX_I2C_READ:
read_bytes = dal_ddc_service_read_dpcd_data( res = dal_ddc_service_read_dpcd_data(
TO_DM_AUX(aux)->ddc_service, TO_DM_AUX(aux)->ddc_service,
true, true,
mot, mot,
msg->address, msg->address,
msg->buffer, msg->buffer,
msg->size); msg->size,
return read_bytes; &read_bytes);
break;
case DP_AUX_I2C_WRITE: case DP_AUX_I2C_WRITE:
res = dal_ddc_service_write_dpcd_data( res = dal_ddc_service_write_dpcd_data(
TO_DM_AUX(aux)->ddc_service, TO_DM_AUX(aux)->ddc_service,
...@@ -137,7 +139,9 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux, ...@@ -137,7 +139,9 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
r == DDC_RESULT_SUCESSFULL); r == DDC_RESULT_SUCESSFULL);
#endif #endif
return msg->size; if (res != DDC_RESULT_SUCESSFULL)
return -EIO;
return read_bytes;
} }
static enum drm_connector_status static enum drm_connector_status
......
...@@ -629,13 +629,14 @@ bool dal_ddc_service_query_ddc_data( ...@@ -629,13 +629,14 @@ bool dal_ddc_service_query_ddc_data(
return ret; return ret;
} }
ssize_t dal_ddc_service_read_dpcd_data( enum ddc_result dal_ddc_service_read_dpcd_data(
struct ddc_service *ddc, struct ddc_service *ddc,
bool i2c, bool i2c,
enum i2c_mot_mode mot, enum i2c_mot_mode mot,
uint32_t address, uint32_t address,
uint8_t *data, uint8_t *data,
uint32_t len) uint32_t len,
uint32_t *read)
{ {
struct aux_payload read_payload = { struct aux_payload read_payload = {
.i2c_over_aux = i2c, .i2c_over_aux = i2c,
...@@ -652,6 +653,8 @@ ssize_t dal_ddc_service_read_dpcd_data( ...@@ -652,6 +653,8 @@ ssize_t dal_ddc_service_read_dpcd_data(
.mot = mot .mot = mot
}; };
*read = 0;
if (len > DEFAULT_AUX_MAX_DATA_SIZE) { if (len > DEFAULT_AUX_MAX_DATA_SIZE) {
BREAK_TO_DEBUGGER(); BREAK_TO_DEBUGGER();
return DDC_RESULT_FAILED_INVALID_OPERATION; return DDC_RESULT_FAILED_INVALID_OPERATION;
...@@ -661,7 +664,8 @@ ssize_t dal_ddc_service_read_dpcd_data( ...@@ -661,7 +664,8 @@ ssize_t dal_ddc_service_read_dpcd_data(
ddc->ctx->i2caux, ddc->ctx->i2caux,
ddc->ddc_pin, ddc->ddc_pin,
&command)) { &command)) {
return (ssize_t)command.payloads->length; *read = command.payloads->length;
return DDC_RESULT_SUCESSFULL;
} }
return DDC_RESULT_FAILED_OPERATION; return DDC_RESULT_FAILED_OPERATION;
......
...@@ -102,13 +102,14 @@ bool dal_ddc_service_query_ddc_data( ...@@ -102,13 +102,14 @@ bool dal_ddc_service_query_ddc_data(
uint8_t *read_buf, uint8_t *read_buf,
uint32_t read_size); uint32_t read_size);
ssize_t dal_ddc_service_read_dpcd_data( enum ddc_result dal_ddc_service_read_dpcd_data(
struct ddc_service *ddc, struct ddc_service *ddc,
bool i2c, bool i2c,
enum i2c_mot_mode mot, enum i2c_mot_mode mot,
uint32_t address, uint32_t address,
uint8_t *data, uint8_t *data,
uint32_t len); uint32_t len,
uint32_t *read);
enum ddc_result dal_ddc_service_write_dpcd_data( enum ddc_result dal_ddc_service_write_dpcd_data(
struct ddc_service *ddc, struct ddc_service *ddc,
......
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