mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-26 17:55:20 +07:00
greybus: remove status from all responses
This is a pervasive change, but not really a big one. However: ============== Pay attention to this ============== If you're doing any testing with "gbsim" you need to update that program in sync with this change, because it changes the protocol used between them. ============== Pay attention to this ============== The status of a request is now recorded in the header of a response message. The previous patch put that header status byte in place, and this one removes the status byte from all the response messages. And finally, since we're modifying all these files anyway... Use gb_operation_status_map() to come up with a return code to use, given an operation response. Right now most errors simply result in -EIO getting returned. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This commit is contained in:
parent
bc717fcbf6
commit
25d0f81a0e
@ -40,7 +40,6 @@ struct gb_battery {
|
|||||||
#define GB_BATTERY_TYPE_VOLTAGE 0x07
|
#define GB_BATTERY_TYPE_VOLTAGE 0x07
|
||||||
|
|
||||||
struct gb_battery_proto_version_response {
|
struct gb_battery_proto_version_response {
|
||||||
__u8 status;
|
|
||||||
__u8 major;
|
__u8 major;
|
||||||
__u8 minor;
|
__u8 minor;
|
||||||
};
|
};
|
||||||
@ -55,7 +54,6 @@ struct gb_battery_proto_version_response {
|
|||||||
#define GB_BATTERY_TECH_LiMn 0x0006
|
#define GB_BATTERY_TECH_LiMn 0x0006
|
||||||
|
|
||||||
struct gb_battery_technology_response {
|
struct gb_battery_technology_response {
|
||||||
__u8 status;
|
|
||||||
__le32 technology;
|
__le32 technology;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -67,35 +65,25 @@ struct gb_battery_technology_response {
|
|||||||
#define GB_BATTERY_STATUS_FULL 0x0004
|
#define GB_BATTERY_STATUS_FULL 0x0004
|
||||||
|
|
||||||
struct gb_battery_status_response {
|
struct gb_battery_status_response {
|
||||||
__u8 status;
|
|
||||||
__le16 battery_status;
|
__le16 battery_status;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gb_battery_max_voltage_response {
|
struct gb_battery_max_voltage_response {
|
||||||
__u8 status;
|
|
||||||
__le32 max_voltage;
|
__le32 max_voltage;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gb_battery_capacity_response {
|
struct gb_battery_capacity_response {
|
||||||
__u8 status;
|
|
||||||
__le32 capacity;
|
__le32 capacity;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gb_battery_temperature_response {
|
struct gb_battery_temperature_response {
|
||||||
__u8 status;
|
|
||||||
__le32 temperature;
|
__le32 temperature;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gb_battery_voltage_response {
|
struct gb_battery_voltage_response {
|
||||||
__u8 status;
|
|
||||||
__le32 voltage;
|
__le32 voltage;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Generia response structure--prefix for all other responses */
|
|
||||||
struct gb_generic_battery_response {
|
|
||||||
__u8 status;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* None of the battery operation requests have any payload. This
|
* None of the battery operation requests have any payload. This
|
||||||
* function implements all of the requests by allowing the caller to
|
* function implements all of the requests by allowing the caller to
|
||||||
@ -107,7 +95,6 @@ static int battery_operation(struct gb_battery *gb, int type,
|
|||||||
{
|
{
|
||||||
struct gb_connection *connection = gb->connection;
|
struct gb_connection *connection = gb->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_generic_battery_response *fake_response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
operation = gb_operation_create(connection, type, 0, response_size);
|
operation = gb_operation_create(connection, type, 0, response_size);
|
||||||
@ -126,14 +113,13 @@ static int battery_operation(struct gb_battery *gb, int type,
|
|||||||
* layout for where the status is, so cast this to a random request so
|
* layout for where the status is, so cast this to a random request so
|
||||||
* we can see the status easier.
|
* we can see the status easier.
|
||||||
*/
|
*/
|
||||||
fake_response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (fake_response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "version response %hhu",
|
gb_connection_err(connection, "operation result %hhu",
|
||||||
fake_response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
/* Good response, so copy to the caller's buffer */
|
/* Good response, so copy to the caller's buffer */
|
||||||
memcpy(response, fake_response, response_size);
|
memcpy(response, operation->response.payload, response_size);
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
gb_operation_destroy(operation);
|
gb_operation_destroy(operation);
|
||||||
|
@ -55,14 +55,12 @@ struct gb_gpio_controller {
|
|||||||
|
|
||||||
/* version request has no payload */
|
/* version request has no payload */
|
||||||
struct gb_gpio_proto_version_response {
|
struct gb_gpio_proto_version_response {
|
||||||
__u8 status;
|
|
||||||
__u8 major;
|
__u8 major;
|
||||||
__u8 minor;
|
__u8 minor;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* line count request has no payload */
|
/* line count request has no payload */
|
||||||
struct gb_gpio_line_count_response {
|
struct gb_gpio_line_count_response {
|
||||||
__u8 status;
|
|
||||||
__u8 count;
|
__u8 count;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -70,44 +68,35 @@ struct gb_gpio_activate_request {
|
|||||||
__u8 which;
|
__u8 which;
|
||||||
};
|
};
|
||||||
struct gb_gpio_activate_response {
|
struct gb_gpio_activate_response {
|
||||||
__u8 status;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gb_gpio_deactivate_request {
|
struct gb_gpio_deactivate_request {
|
||||||
__u8 which;
|
__u8 which;
|
||||||
};
|
};
|
||||||
struct gb_gpio_deactivate_response {
|
/* deactivate response has no payload */
|
||||||
__u8 status;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct gb_gpio_get_direction_request {
|
struct gb_gpio_get_direction_request {
|
||||||
__u8 which;
|
__u8 which;
|
||||||
};
|
};
|
||||||
struct gb_gpio_get_direction_response {
|
struct gb_gpio_get_direction_response {
|
||||||
__u8 status;
|
|
||||||
__u8 direction;
|
__u8 direction;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gb_gpio_direction_in_request {
|
struct gb_gpio_direction_in_request {
|
||||||
__u8 which;
|
__u8 which;
|
||||||
};
|
};
|
||||||
struct gb_gpio_direction_in_response {
|
/* direction in response has no payload */
|
||||||
__u8 status;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct gb_gpio_direction_out_request {
|
struct gb_gpio_direction_out_request {
|
||||||
__u8 which;
|
__u8 which;
|
||||||
__u8 value;
|
__u8 value;
|
||||||
};
|
};
|
||||||
struct gb_gpio_direction_out_response {
|
/* direction out response has no payload */
|
||||||
__u8 status;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct gb_gpio_get_value_request {
|
struct gb_gpio_get_value_request {
|
||||||
__u8 which;
|
__u8 which;
|
||||||
};
|
};
|
||||||
struct gb_gpio_get_value_response {
|
struct gb_gpio_get_value_response {
|
||||||
__u8 status;
|
|
||||||
__u8 value;
|
__u8 value;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -115,17 +104,13 @@ struct gb_gpio_set_value_request {
|
|||||||
__u8 which;
|
__u8 which;
|
||||||
__u8 value;
|
__u8 value;
|
||||||
};
|
};
|
||||||
struct gb_gpio_set_value_response {
|
/* set value response has no payload */
|
||||||
__u8 status;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct gb_gpio_set_debounce_request {
|
struct gb_gpio_set_debounce_request {
|
||||||
__u8 which;
|
__u8 which;
|
||||||
__le16 usec;
|
__le16 usec;
|
||||||
};
|
};
|
||||||
struct gb_gpio_set_debounce_response {
|
/* debounce response has no payload */
|
||||||
__u8 status;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -153,12 +138,12 @@ static int gb_gpio_proto_version_operation(struct gb_gpio_controller *gb_gpio_co
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "version response %hhu",
|
gb_connection_err(connection, "version result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
|
response = operation->response.payload;
|
||||||
if (response->major > GB_GPIO_VERSION_MAJOR) {
|
if (response->major > GB_GPIO_VERSION_MAJOR) {
|
||||||
pr_err("unsupported major version (%hhu > %hhu)\n",
|
pr_err("unsupported major version (%hhu > %hhu)\n",
|
||||||
response->major, GB_GPIO_VERSION_MAJOR);
|
response->major, GB_GPIO_VERSION_MAJOR);
|
||||||
@ -199,12 +184,12 @@ static int gb_gpio_line_count_operation(struct gb_gpio_controller *gb_gpio_contr
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "line count response %hhu",
|
gb_connection_err(connection, "line count result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
|
response = operation->response.payload;
|
||||||
gb_gpio_controller->line_max = response->count;
|
gb_gpio_controller->line_max = response->count;
|
||||||
|
|
||||||
pr_debug("%s: count = %u\n", __func__,
|
pr_debug("%s: count = %u\n", __func__,
|
||||||
@ -222,7 +207,6 @@ static int gb_gpio_activate_operation(struct gb_gpio_controller *gb_gpio_control
|
|||||||
struct gb_connection *connection = gb_gpio_controller->connection;
|
struct gb_connection *connection = gb_gpio_controller->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_gpio_activate_request *request;
|
struct gb_gpio_activate_request *request;
|
||||||
struct gb_gpio_activate_response *response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (which > gb_gpio_controller->line_max)
|
if (which > gb_gpio_controller->line_max)
|
||||||
@ -231,7 +215,7 @@ static int gb_gpio_activate_operation(struct gb_gpio_controller *gb_gpio_control
|
|||||||
/* activate response has no payload */
|
/* activate response has no payload */
|
||||||
operation = gb_operation_create(connection,
|
operation = gb_operation_create(connection,
|
||||||
GB_GPIO_TYPE_ACTIVATE,
|
GB_GPIO_TYPE_ACTIVATE,
|
||||||
sizeof(*request), sizeof(*response));
|
sizeof(*request), 0);
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -244,11 +228,10 @@ static int gb_gpio_activate_operation(struct gb_gpio_controller *gb_gpio_control
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "activate response %hhu",
|
gb_connection_err(connection, "activate result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
gb_gpio_controller->lines[which].active = true;
|
gb_gpio_controller->lines[which].active = true;
|
||||||
|
|
||||||
@ -266,7 +249,6 @@ static int gb_gpio_deactivate_operation(struct gb_gpio_controller *gb_gpio_contr
|
|||||||
struct gb_connection *connection = gb_gpio_controller->connection;
|
struct gb_connection *connection = gb_gpio_controller->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_gpio_deactivate_request *request;
|
struct gb_gpio_deactivate_request *request;
|
||||||
struct gb_gpio_deactivate_response *response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (which > gb_gpio_controller->line_max)
|
if (which > gb_gpio_controller->line_max)
|
||||||
@ -275,7 +257,7 @@ static int gb_gpio_deactivate_operation(struct gb_gpio_controller *gb_gpio_contr
|
|||||||
/* deactivate response has no payload */
|
/* deactivate response has no payload */
|
||||||
operation = gb_operation_create(connection,
|
operation = gb_operation_create(connection,
|
||||||
GB_GPIO_TYPE_DEACTIVATE,
|
GB_GPIO_TYPE_DEACTIVATE,
|
||||||
sizeof(*request), sizeof(*response));
|
sizeof(*request), 0);
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -288,11 +270,10 @@ static int gb_gpio_deactivate_operation(struct gb_gpio_controller *gb_gpio_contr
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "deactivate response %hhu",
|
gb_connection_err(connection, "deactivate result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
gb_gpio_controller->lines[which].active = false;
|
gb_gpio_controller->lines[which].active = false;
|
||||||
pr_debug("%s: %u is now inactive\n", __func__, which);
|
pr_debug("%s: %u is now inactive\n", __func__, which);
|
||||||
@ -330,14 +311,15 @@ static int gb_gpio_get_direction_operation(struct gb_gpio_controller *gb_gpio_co
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "get direction response %hhu",
|
gb_connection_err(connection, "get direction result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
u8 direction = response->direction;
|
u8 direction;
|
||||||
|
|
||||||
|
response = operation->response.payload;
|
||||||
|
direction = response->direction;
|
||||||
if (direction && direction != 1)
|
if (direction && direction != 1)
|
||||||
pr_warn("gpio %u direction was %u (should be 0 or 1)\n",
|
pr_warn("gpio %u direction was %u (should be 0 or 1)\n",
|
||||||
which, direction);
|
which, direction);
|
||||||
@ -357,7 +339,6 @@ static int gb_gpio_direction_in_operation(struct gb_gpio_controller *gb_gpio_con
|
|||||||
struct gb_connection *connection = gb_gpio_controller->connection;
|
struct gb_connection *connection = gb_gpio_controller->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_gpio_direction_in_request *request;
|
struct gb_gpio_direction_in_request *request;
|
||||||
struct gb_gpio_direction_in_response *response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (which > gb_gpio_controller->line_max)
|
if (which > gb_gpio_controller->line_max)
|
||||||
@ -366,7 +347,7 @@ static int gb_gpio_direction_in_operation(struct gb_gpio_controller *gb_gpio_con
|
|||||||
/* direction_in response has no payload */
|
/* direction_in response has no payload */
|
||||||
operation = gb_operation_create(connection,
|
operation = gb_operation_create(connection,
|
||||||
GB_GPIO_TYPE_DIRECTION_IN,
|
GB_GPIO_TYPE_DIRECTION_IN,
|
||||||
sizeof(*request), sizeof(*response));
|
sizeof(*request), 0);
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -379,11 +360,10 @@ static int gb_gpio_direction_in_operation(struct gb_gpio_controller *gb_gpio_con
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "direction in response %hhu",
|
gb_connection_err(connection, "direction in result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
gb_gpio_controller->lines[which].direction = 1;
|
gb_gpio_controller->lines[which].direction = 1;
|
||||||
pr_debug("%s: direction of %u is now in\n", __func__, which);
|
pr_debug("%s: direction of %u is now in\n", __func__, which);
|
||||||
@ -400,7 +380,6 @@ static int gb_gpio_direction_out_operation(struct gb_gpio_controller *gb_gpio_co
|
|||||||
struct gb_connection *connection = gb_gpio_controller->connection;
|
struct gb_connection *connection = gb_gpio_controller->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_gpio_direction_out_request *request;
|
struct gb_gpio_direction_out_request *request;
|
||||||
struct gb_gpio_direction_out_response *response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (which > gb_gpio_controller->line_max)
|
if (which > gb_gpio_controller->line_max)
|
||||||
@ -409,7 +388,7 @@ static int gb_gpio_direction_out_operation(struct gb_gpio_controller *gb_gpio_co
|
|||||||
/* direction_out response has no payload */
|
/* direction_out response has no payload */
|
||||||
operation = gb_operation_create(connection,
|
operation = gb_operation_create(connection,
|
||||||
GB_GPIO_TYPE_DIRECTION_OUT,
|
GB_GPIO_TYPE_DIRECTION_OUT,
|
||||||
sizeof(*request), sizeof(*response));
|
sizeof(*request), 0);
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -423,11 +402,10 @@ static int gb_gpio_direction_out_operation(struct gb_gpio_controller *gb_gpio_co
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "direction out response %hhu",
|
gb_connection_err(connection, "direction out result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
gb_gpio_controller->lines[which].direction = 0;
|
gb_gpio_controller->lines[which].direction = 0;
|
||||||
pr_debug("%s: direction of %u is now out, value %s\n", __func__,
|
pr_debug("%s: direction of %u is now out, value %s\n", __func__,
|
||||||
@ -466,14 +444,15 @@ static int gb_gpio_get_value_operation(struct gb_gpio_controller *gb_gpio_contro
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "get value response %hhu",
|
gb_connection_err(connection, "get value result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
u8 value = response->value;
|
u8 value;
|
||||||
|
|
||||||
|
response = operation->response.payload;
|
||||||
|
value = response->value;
|
||||||
if (value && value != 1)
|
if (value && value != 1)
|
||||||
pr_warn("gpio %u value was %u (should be 0 or 1)\n",
|
pr_warn("gpio %u value was %u (should be 0 or 1)\n",
|
||||||
which, value);
|
which, value);
|
||||||
@ -495,7 +474,6 @@ static int gb_gpio_set_value_operation(struct gb_gpio_controller *gb_gpio_contro
|
|||||||
struct gb_connection *connection = gb_gpio_controller->connection;
|
struct gb_connection *connection = gb_gpio_controller->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_gpio_set_value_request *request;
|
struct gb_gpio_set_value_request *request;
|
||||||
struct gb_gpio_set_value_response *response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (which > gb_gpio_controller->line_max)
|
if (which > gb_gpio_controller->line_max)
|
||||||
@ -504,7 +482,7 @@ static int gb_gpio_set_value_operation(struct gb_gpio_controller *gb_gpio_contro
|
|||||||
/* set_value response has no payload */
|
/* set_value response has no payload */
|
||||||
operation = gb_operation_create(connection,
|
operation = gb_operation_create(connection,
|
||||||
GB_GPIO_TYPE_SET_VALUE,
|
GB_GPIO_TYPE_SET_VALUE,
|
||||||
sizeof(*request), sizeof(*response));
|
sizeof(*request), 0);
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -518,11 +496,10 @@ static int gb_gpio_set_value_operation(struct gb_gpio_controller *gb_gpio_contro
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "set value response %hhu",
|
gb_connection_err(connection, "set value result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
/* XXX should this set direction to out? */
|
/* XXX should this set direction to out? */
|
||||||
gb_gpio_controller->lines[which].value = request->value;
|
gb_gpio_controller->lines[which].value = request->value;
|
||||||
@ -542,7 +519,6 @@ static int gb_gpio_set_debounce_operation(struct gb_gpio_controller *gb_gpio_con
|
|||||||
struct gb_connection *connection = gb_gpio_controller->connection;
|
struct gb_connection *connection = gb_gpio_controller->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_gpio_set_debounce_request *request;
|
struct gb_gpio_set_debounce_request *request;
|
||||||
struct gb_gpio_set_debounce_response *response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (which > gb_gpio_controller->line_max)
|
if (which > gb_gpio_controller->line_max)
|
||||||
@ -551,7 +527,7 @@ static int gb_gpio_set_debounce_operation(struct gb_gpio_controller *gb_gpio_con
|
|||||||
/* set_debounce response has no payload */
|
/* set_debounce response has no payload */
|
||||||
operation = gb_operation_create(connection,
|
operation = gb_operation_create(connection,
|
||||||
GB_GPIO_TYPE_SET_DEBOUNCE,
|
GB_GPIO_TYPE_SET_DEBOUNCE,
|
||||||
sizeof(*request), sizeof(*response));
|
sizeof(*request), 0);
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -565,11 +541,10 @@ static int gb_gpio_set_debounce_operation(struct gb_gpio_controller *gb_gpio_con
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "set debounce response %hhu",
|
gb_connection_err(connection, "set debounce result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
gb_gpio_controller->lines[which].debounce_usec = le16_to_cpu(request->usec);
|
gb_gpio_controller->lines[which].debounce_usec = le16_to_cpu(request->usec);
|
||||||
pr_debug("%s: debounce of %u is now %hu usec\n", __func__, which,
|
pr_debug("%s: debounce of %u is now %hu usec\n", __func__, which,
|
||||||
|
@ -43,30 +43,24 @@ struct gb_i2c_device {
|
|||||||
|
|
||||||
/* version request has no payload */
|
/* version request has no payload */
|
||||||
struct gb_i2c_proto_version_response {
|
struct gb_i2c_proto_version_response {
|
||||||
__u8 status;
|
|
||||||
__u8 major;
|
__u8 major;
|
||||||
__u8 minor;
|
__u8 minor;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* functionality request has no payload */
|
/* functionality request has no payload */
|
||||||
struct gb_i2c_functionality_response {
|
struct gb_i2c_functionality_response {
|
||||||
__u8 status;
|
|
||||||
__le32 functionality;
|
__le32 functionality;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gb_i2c_timeout_request {
|
struct gb_i2c_timeout_request {
|
||||||
__le16 msec;
|
__le16 msec;
|
||||||
};
|
};
|
||||||
struct gb_i2c_timeout_response {
|
/* timeout response has no payload */
|
||||||
__u8 status;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct gb_i2c_retries_request {
|
struct gb_i2c_retries_request {
|
||||||
__u8 retries;
|
__u8 retries;
|
||||||
};
|
};
|
||||||
struct gb_i2c_retries_response {
|
/* retries response has no payload */
|
||||||
__u8 status;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Outgoing data immediately follows the op count and ops array.
|
* Outgoing data immediately follows the op count and ops array.
|
||||||
@ -89,7 +83,6 @@ struct gb_i2c_transfer_request {
|
|||||||
struct gb_i2c_transfer_op ops[0]; /* op_count of these */
|
struct gb_i2c_transfer_op ops[0]; /* op_count of these */
|
||||||
};
|
};
|
||||||
struct gb_i2c_transfer_response {
|
struct gb_i2c_transfer_response {
|
||||||
__u8 status;
|
|
||||||
__u8 data[0]; /* inbound data */
|
__u8 data[0]; /* inbound data */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -118,12 +111,12 @@ static int gb_i2c_proto_version_operation(struct gb_i2c_device *gb_i2c_dev)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "version response %hhu",
|
gb_connection_err(connection, "version result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
|
response = operation->response.payload;
|
||||||
if (response->major > GB_I2C_VERSION_MAJOR) {
|
if (response->major > GB_I2C_VERSION_MAJOR) {
|
||||||
pr_err("unsupported major version (%hhu > %hhu)\n",
|
pr_err("unsupported major version (%hhu > %hhu)\n",
|
||||||
response->major, GB_I2C_VERSION_MAJOR);
|
response->major, GB_I2C_VERSION_MAJOR);
|
||||||
@ -170,12 +163,12 @@ static int gb_i2c_functionality_operation(struct gb_i2c_device *gb_i2c_dev)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "functionality response %hhu",
|
gb_connection_err(connection, "functionality result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
|
response = operation->response.payload;
|
||||||
functionality = le32_to_cpu(response->functionality);
|
functionality = le32_to_cpu(response->functionality);
|
||||||
gb_i2c_dev->functionality =
|
gb_i2c_dev->functionality =
|
||||||
gb_i2c_functionality_map(functionality);
|
gb_i2c_functionality_map(functionality);
|
||||||
@ -191,11 +184,10 @@ static int gb_i2c_timeout_operation(struct gb_i2c_device *gb_i2c_dev, u16 msec)
|
|||||||
struct gb_connection *connection = gb_i2c_dev->connection;
|
struct gb_connection *connection = gb_i2c_dev->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_i2c_timeout_request *request;
|
struct gb_i2c_timeout_request *request;
|
||||||
struct gb_i2c_timeout_response *response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
operation = gb_operation_create(connection, GB_I2C_TYPE_TIMEOUT,
|
operation = gb_operation_create(connection, GB_I2C_TYPE_TIMEOUT,
|
||||||
sizeof(*request), sizeof(*response));
|
sizeof(*request), 0);
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -208,11 +200,10 @@ static int gb_i2c_timeout_operation(struct gb_i2c_device *gb_i2c_dev, u16 msec)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "timeout response %hhu",
|
gb_connection_err(connection, "timeout result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
gb_i2c_dev->timeout_msec = msec;
|
gb_i2c_dev->timeout_msec = msec;
|
||||||
}
|
}
|
||||||
@ -228,11 +219,10 @@ static int gb_i2c_retries_operation(struct gb_i2c_device *gb_i2c_dev,
|
|||||||
struct gb_connection *connection = gb_i2c_dev->connection;
|
struct gb_connection *connection = gb_i2c_dev->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_i2c_retries_request *request;
|
struct gb_i2c_retries_request *request;
|
||||||
struct gb_i2c_retries_response *response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
operation = gb_operation_create(connection, GB_I2C_TYPE_RETRIES,
|
operation = gb_operation_create(connection, GB_I2C_TYPE_RETRIES,
|
||||||
sizeof(*request), sizeof(*response));
|
sizeof(*request), 0);
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -245,11 +235,10 @@ static int gb_i2c_retries_operation(struct gb_i2c_device *gb_i2c_dev,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "retries response %hhu",
|
gb_connection_err(connection, "retries result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
gb_i2c_dev->retries = retries;
|
gb_i2c_dev->retries = retries;
|
||||||
}
|
}
|
||||||
@ -380,16 +369,14 @@ static int gb_i2c_transfer_operation(struct gb_i2c_device *gb_i2c_dev,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
if (response->status == GB_OP_RETRY) {
|
if (ret != -EAGAIN) {
|
||||||
ret = -EAGAIN;
|
gb_connection_err(connection, "transfer result %hhu",
|
||||||
} else {
|
operation->result);
|
||||||
gb_connection_err(connection, "transfer response %hhu",
|
|
||||||
response->status);
|
|
||||||
ret = -EIO;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
response = operation->response.payload;
|
||||||
gb_i2c_transfer_response(msgs, msg_count, response->data);
|
gb_i2c_transfer_response(msgs, msg_count, response->data);
|
||||||
ret = msg_count;
|
ret = msg_count;
|
||||||
}
|
}
|
||||||
|
@ -525,10 +525,11 @@ static void gb_connection_recv_response(struct gb_connection *connection,
|
|||||||
return; /* XXX Should still complete operation */
|
return; /* XXX Should still complete operation */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hack the status from the buffer into the header */
|
/* The status in the response is the result of the operation */
|
||||||
header = message->buffer;
|
header = message->buffer;
|
||||||
header->result = *(char *)message->payload; /* Eeew. */
|
|
||||||
operation->result = header->result;
|
operation->result = header->result;
|
||||||
|
|
||||||
|
/* We must ignore the payload if a bad status is returned */
|
||||||
if (operation->result == GB_OP_SUCCESS)
|
if (operation->result == GB_OP_SUCCESS)
|
||||||
memcpy(message->buffer, data, size);
|
memcpy(message->buffer, data, size);
|
||||||
|
|
||||||
|
@ -41,20 +41,14 @@ struct gb_pwm_chip {
|
|||||||
#define GB_PWM_TYPE_DISABLE 0x08
|
#define GB_PWM_TYPE_DISABLE 0x08
|
||||||
#define GB_PWM_TYPE_RESPONSE 0x80 /* OR'd with rest */
|
#define GB_PWM_TYPE_RESPONSE 0x80 /* OR'd with rest */
|
||||||
|
|
||||||
struct gb_pwm_simple_response {
|
|
||||||
__u8 status;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* version request has no payload */
|
/* version request has no payload */
|
||||||
struct gb_pwm_proto_version_response {
|
struct gb_pwm_proto_version_response {
|
||||||
__u8 status;
|
|
||||||
__u8 major;
|
__u8 major;
|
||||||
__u8 minor;
|
__u8 minor;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* pwm count request has no payload */
|
/* pwm count request has no payload */
|
||||||
struct gb_pwm_count_response {
|
struct gb_pwm_count_response {
|
||||||
__u8 status;
|
|
||||||
__u8 count;
|
__u8 count;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -110,12 +104,12 @@ static int gb_pwm_proto_version_operation(struct gb_pwm_chip *pwmc)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "version response %hhu",
|
gb_connection_err(connection, "version result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
|
response = operation->response.payload;
|
||||||
if (response->major > GB_PWM_VERSION_MAJOR) {
|
if (response->major > GB_PWM_VERSION_MAJOR) {
|
||||||
pr_err("unsupported major version (%hhu > %hhu)\n",
|
pr_err("unsupported major version (%hhu > %hhu)\n",
|
||||||
response->major, GB_PWM_VERSION_MAJOR);
|
response->major, GB_PWM_VERSION_MAJOR);
|
||||||
@ -151,12 +145,12 @@ static int gb_pwm_count_operation(struct gb_pwm_chip *pwmc)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "pwm count response %hhu",
|
gb_connection_err(connection, "pwm count result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else
|
} else
|
||||||
|
response = operation->response.payload;
|
||||||
pwmc->pwm_max = response->count;
|
pwmc->pwm_max = response->count;
|
||||||
out:
|
out:
|
||||||
gb_operation_destroy(operation);
|
gb_operation_destroy(operation);
|
||||||
@ -170,7 +164,6 @@ static int gb_pwm_activate_operation(struct gb_pwm_chip *pwmc,
|
|||||||
struct gb_connection *connection = pwmc->connection;
|
struct gb_connection *connection = pwmc->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_pwm_activate_request *request;
|
struct gb_pwm_activate_request *request;
|
||||||
struct gb_pwm_simple_response *response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (which > pwmc->pwm_max)
|
if (which > pwmc->pwm_max)
|
||||||
@ -178,7 +171,7 @@ static int gb_pwm_activate_operation(struct gb_pwm_chip *pwmc,
|
|||||||
|
|
||||||
/* activate response has no payload */
|
/* activate response has no payload */
|
||||||
operation = gb_operation_create(connection, GB_PWM_TYPE_ACTIVATE,
|
operation = gb_operation_create(connection, GB_PWM_TYPE_ACTIVATE,
|
||||||
sizeof(*request), sizeof(*response));
|
sizeof(*request), 0);
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -191,11 +184,10 @@ static int gb_pwm_activate_operation(struct gb_pwm_chip *pwmc,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "activate response %hhu",
|
gb_connection_err(connection, "activate result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
gb_operation_destroy(operation);
|
gb_operation_destroy(operation);
|
||||||
@ -209,7 +201,6 @@ static int gb_pwm_deactivate_operation(struct gb_pwm_chip *pwmc,
|
|||||||
struct gb_connection *connection = pwmc->connection;
|
struct gb_connection *connection = pwmc->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_pwm_deactivate_request *request;
|
struct gb_pwm_deactivate_request *request;
|
||||||
struct gb_pwm_simple_response *response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (which > pwmc->pwm_max)
|
if (which > pwmc->pwm_max)
|
||||||
@ -217,7 +208,7 @@ static int gb_pwm_deactivate_operation(struct gb_pwm_chip *pwmc,
|
|||||||
|
|
||||||
/* deactivate response has no payload */
|
/* deactivate response has no payload */
|
||||||
operation = gb_operation_create(connection, GB_PWM_TYPE_DEACTIVATE,
|
operation = gb_operation_create(connection, GB_PWM_TYPE_DEACTIVATE,
|
||||||
sizeof(*request), sizeof(*response));
|
sizeof(*request), 0);
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -230,11 +221,10 @@ static int gb_pwm_deactivate_operation(struct gb_pwm_chip *pwmc,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "deactivate response %hhu",
|
gb_connection_err(connection, "deactivate result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
gb_operation_destroy(operation);
|
gb_operation_destroy(operation);
|
||||||
@ -248,14 +238,13 @@ static int gb_pwm_config_operation(struct gb_pwm_chip *pwmc,
|
|||||||
struct gb_connection *connection = pwmc->connection;
|
struct gb_connection *connection = pwmc->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_pwm_config_request *request;
|
struct gb_pwm_config_request *request;
|
||||||
struct gb_pwm_simple_response *response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (which > pwmc->pwm_max)
|
if (which > pwmc->pwm_max)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
operation = gb_operation_create(connection, GB_PWM_TYPE_CONFIG,
|
operation = gb_operation_create(connection, GB_PWM_TYPE_CONFIG,
|
||||||
sizeof(*request), sizeof(*response));
|
sizeof(*request), 0);
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -270,11 +259,10 @@ static int gb_pwm_config_operation(struct gb_pwm_chip *pwmc,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "config response %hhu",
|
gb_connection_err(connection, "config result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
gb_operation_destroy(operation);
|
gb_operation_destroy(operation);
|
||||||
@ -289,14 +277,13 @@ static int gb_pwm_set_polarity_operation(struct gb_pwm_chip *pwmc,
|
|||||||
struct gb_connection *connection = pwmc->connection;
|
struct gb_connection *connection = pwmc->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_pwm_polarity_request *request;
|
struct gb_pwm_polarity_request *request;
|
||||||
struct gb_pwm_simple_response *response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (which > pwmc->pwm_max)
|
if (which > pwmc->pwm_max)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
operation = gb_operation_create(connection, GB_PWM_TYPE_POLARITY,
|
operation = gb_operation_create(connection, GB_PWM_TYPE_POLARITY,
|
||||||
sizeof(*request), sizeof(*response));
|
sizeof(*request), 0);
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -310,11 +297,10 @@ static int gb_pwm_set_polarity_operation(struct gb_pwm_chip *pwmc,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "set polarity response %hhu",
|
gb_connection_err(connection, "set polarity result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
gb_operation_destroy(operation);
|
gb_operation_destroy(operation);
|
||||||
@ -328,7 +314,6 @@ static int gb_pwm_enable_operation(struct gb_pwm_chip *pwmc,
|
|||||||
struct gb_connection *connection = pwmc->connection;
|
struct gb_connection *connection = pwmc->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_pwm_enable_request *request;
|
struct gb_pwm_enable_request *request;
|
||||||
struct gb_pwm_simple_response *response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (which > pwmc->pwm_max)
|
if (which > pwmc->pwm_max)
|
||||||
@ -336,7 +321,7 @@ static int gb_pwm_enable_operation(struct gb_pwm_chip *pwmc,
|
|||||||
|
|
||||||
/* enable response has no payload */
|
/* enable response has no payload */
|
||||||
operation = gb_operation_create(connection, GB_PWM_TYPE_ENABLE,
|
operation = gb_operation_create(connection, GB_PWM_TYPE_ENABLE,
|
||||||
sizeof(*request), sizeof(*response));
|
sizeof(*request), 0);
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -349,11 +334,10 @@ static int gb_pwm_enable_operation(struct gb_pwm_chip *pwmc,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "enable response %hhu",
|
gb_connection_err(connection, "enable result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
gb_operation_destroy(operation);
|
gb_operation_destroy(operation);
|
||||||
@ -367,7 +351,6 @@ static int gb_pwm_disable_operation(struct gb_pwm_chip *pwmc,
|
|||||||
struct gb_connection *connection = pwmc->connection;
|
struct gb_connection *connection = pwmc->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_pwm_disable_request *request;
|
struct gb_pwm_disable_request *request;
|
||||||
struct gb_pwm_simple_response *response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (which > pwmc->pwm_max)
|
if (which > pwmc->pwm_max)
|
||||||
@ -375,7 +358,7 @@ static int gb_pwm_disable_operation(struct gb_pwm_chip *pwmc,
|
|||||||
|
|
||||||
/* disable response has no payload */
|
/* disable response has no payload */
|
||||||
operation = gb_operation_create(connection, GB_PWM_TYPE_DISABLE,
|
operation = gb_operation_create(connection, GB_PWM_TYPE_DISABLE,
|
||||||
sizeof(*request), sizeof(*response));
|
sizeof(*request), 0);
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -388,11 +371,10 @@ static int gb_pwm_disable_operation(struct gb_pwm_chip *pwmc,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "disable response %hhu",
|
gb_connection_err(connection, "disable result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
gb_operation_destroy(operation);
|
gb_operation_destroy(operation);
|
||||||
|
@ -49,7 +49,6 @@
|
|||||||
#define GB_UART_TYPE_RESPONSE 0x80 /* OR'd with rest */
|
#define GB_UART_TYPE_RESPONSE 0x80 /* OR'd with rest */
|
||||||
|
|
||||||
struct gb_uart_proto_version_response {
|
struct gb_uart_proto_version_response {
|
||||||
__u8 status;
|
|
||||||
__u8 major;
|
__u8 major;
|
||||||
__u8 minor;
|
__u8 minor;
|
||||||
};
|
};
|
||||||
@ -106,10 +105,6 @@ struct gb_uart_serial_state_request {
|
|||||||
__u16 control;
|
__u16 control;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gb_uart_simple_response {
|
|
||||||
__u8 status;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct gb_tty {
|
struct gb_tty {
|
||||||
struct tty_port port;
|
struct tty_port port;
|
||||||
struct gb_connection *connection;
|
struct gb_connection *connection;
|
||||||
@ -159,11 +154,10 @@ static int get_version(struct gb_tty *tty)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(tty->connection, "response %hhu",
|
gb_connection_err(tty->connection, "result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
if (response->major > GB_UART_VERSION_MAJOR) {
|
if (response->major > GB_UART_VERSION_MAJOR) {
|
||||||
pr_err("unsupported major version (%hhu > %hhu)\n",
|
pr_err("unsupported major version (%hhu > %hhu)\n",
|
||||||
@ -188,15 +182,13 @@ static int send_data(struct gb_tty *tty, u16 size, const u8 *data)
|
|||||||
struct gb_connection *connection = tty->connection;
|
struct gb_connection *connection = tty->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_uart_send_data_request *request;
|
struct gb_uart_send_data_request *request;
|
||||||
struct gb_uart_simple_response *response;
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (!data || !size)
|
if (!data || !size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
operation = gb_operation_create(connection, GB_UART_REQ_SEND_DATA,
|
operation = gb_operation_create(connection, GB_UART_REQ_SEND_DATA,
|
||||||
sizeof(*request) + size,
|
sizeof(*request) + size, 0);
|
||||||
sizeof(*response));
|
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -211,11 +203,10 @@ static int send_data(struct gb_tty *tty, u16 size, const u8 *data)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
retval = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "send data response %hhu",
|
gb_connection_err(connection, "send data result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
retval = -EIO;
|
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
gb_operation_destroy(operation);
|
gb_operation_destroy(operation);
|
||||||
@ -229,12 +220,10 @@ static int send_line_coding(struct gb_tty *tty,
|
|||||||
struct gb_connection *connection = tty->connection;
|
struct gb_connection *connection = tty->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_uart_set_line_coding_request *request;
|
struct gb_uart_set_line_coding_request *request;
|
||||||
struct gb_uart_simple_response *response;
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
operation = gb_operation_create(connection, GB_UART_REQ_SET_LINE_CODING,
|
operation = gb_operation_create(connection, GB_UART_REQ_SET_LINE_CODING,
|
||||||
sizeof(*request),
|
sizeof(*request), 0);
|
||||||
sizeof(*response));
|
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -248,11 +237,10 @@ static int send_line_coding(struct gb_tty *tty,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
retval = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "send line coding response %hhu",
|
gb_connection_err(connection, "send line coding result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
retval = -EIO;
|
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
gb_operation_destroy(operation);
|
gb_operation_destroy(operation);
|
||||||
@ -265,13 +253,11 @@ static int send_control(struct gb_tty *tty, u16 control)
|
|||||||
struct gb_connection *connection = tty->connection;
|
struct gb_connection *connection = tty->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_uart_set_control_line_state_request *request;
|
struct gb_uart_set_control_line_state_request *request;
|
||||||
struct gb_uart_simple_response *response;
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
operation = gb_operation_create(connection,
|
operation = gb_operation_create(connection,
|
||||||
GB_UART_REQ_SET_CONTROL_LINE_STATE,
|
GB_UART_REQ_SET_CONTROL_LINE_STATE,
|
||||||
sizeof(*request),
|
sizeof(*request), 0);
|
||||||
sizeof(*response));
|
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -285,11 +271,10 @@ static int send_control(struct gb_tty *tty, u16 control)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
retval = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "send control response %hhu",
|
gb_connection_err(connection, "send control result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
retval = -EIO;
|
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
gb_operation_destroy(operation);
|
gb_operation_destroy(operation);
|
||||||
@ -302,7 +287,6 @@ static int send_break(struct gb_tty *tty, u8 state)
|
|||||||
struct gb_connection *connection = tty->connection;
|
struct gb_connection *connection = tty->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_uart_set_break_request *request;
|
struct gb_uart_set_break_request *request;
|
||||||
struct gb_uart_simple_response *response;
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if ((state != 0) && (state != 1)) {
|
if ((state != 0) && (state != 1)) {
|
||||||
@ -311,8 +295,7 @@ static int send_break(struct gb_tty *tty, u8 state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
operation = gb_operation_create(connection, GB_UART_REQ_SET_BREAK,
|
operation = gb_operation_create(connection, GB_UART_REQ_SET_BREAK,
|
||||||
sizeof(*request),
|
sizeof(*request), 0);
|
||||||
sizeof(*response));
|
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -326,11 +309,10 @@ static int send_break(struct gb_tty *tty, u8 state)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
retval = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "send break response %hhu",
|
gb_connection_err(connection, "send break result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
retval = -EIO;
|
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
gb_operation_destroy(operation);
|
gb_operation_destroy(operation);
|
||||||
|
@ -34,7 +34,6 @@ struct gb_vibrator_device {
|
|||||||
#define GB_VIBRATOR_TYPE_RESPONSE 0x80 /* OR'd with rest */
|
#define GB_VIBRATOR_TYPE_RESPONSE 0x80 /* OR'd with rest */
|
||||||
|
|
||||||
struct gb_vibrator_proto_version_response {
|
struct gb_vibrator_proto_version_response {
|
||||||
__u8 status;
|
|
||||||
__u8 major;
|
__u8 major;
|
||||||
__u8 minor;
|
__u8 minor;
|
||||||
};
|
};
|
||||||
@ -43,15 +42,10 @@ struct gb_vibrator_on_request {
|
|||||||
__le16 timeout_ms;
|
__le16 timeout_ms;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gb_vibrator_simple_response {
|
|
||||||
__u8 status;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int request_operation(struct gb_connection *connection, int type,
|
static int request_operation(struct gb_connection *connection, int type,
|
||||||
void *response, int response_size)
|
void *response, int response_size)
|
||||||
{
|
{
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_vibrator_simple_response *fake_response;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
operation = gb_operation_create(connection, type, 0, response_size);
|
operation = gb_operation_create(connection, type, 0, response_size);
|
||||||
@ -70,15 +64,15 @@ static int request_operation(struct gb_connection *connection, int type,
|
|||||||
* layout for where the status is, so cast this to a random request so
|
* layout for where the status is, so cast this to a random request so
|
||||||
* we can see the status easier.
|
* we can see the status easier.
|
||||||
*/
|
*/
|
||||||
fake_response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (fake_response->status) {
|
ret = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "response %hhu",
|
gb_connection_err(connection, "operation result %hhu",
|
||||||
fake_response->status);
|
operation->result);
|
||||||
ret = -EIO;
|
|
||||||
} else {
|
} else {
|
||||||
/* Good request, so copy to the caller's buffer */
|
/* Good request, so copy to the caller's buffer */
|
||||||
if (response_size && response)
|
if (response_size && response)
|
||||||
memcpy(response, fake_response, response_size);
|
memcpy(response, operation->response.payload,
|
||||||
|
response_size);
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
gb_operation_destroy(operation);
|
gb_operation_destroy(operation);
|
||||||
@ -119,11 +113,10 @@ static int turn_on(struct gb_vibrator_device *vib, u16 timeout_ms)
|
|||||||
struct gb_connection *connection = vib->connection;
|
struct gb_connection *connection = vib->connection;
|
||||||
struct gb_operation *operation;
|
struct gb_operation *operation;
|
||||||
struct gb_vibrator_on_request *request;
|
struct gb_vibrator_on_request *request;
|
||||||
struct gb_vibrator_simple_response *response;
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
operation = gb_operation_create(connection, GB_VIBRATOR_TYPE_ON,
|
operation = gb_operation_create(connection, GB_VIBRATOR_TYPE_ON,
|
||||||
sizeof(*request), sizeof(*response));
|
sizeof(*request), 0);
|
||||||
if (!operation)
|
if (!operation)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
request = operation->request.payload;
|
request = operation->request.payload;
|
||||||
@ -137,11 +130,10 @@ static int turn_on(struct gb_vibrator_device *vib, u16 timeout_ms)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = operation->response.payload;
|
if (operation->result) {
|
||||||
if (response->status) {
|
retval = gb_operation_status_map(operation->result);
|
||||||
gb_connection_err(connection, "send data response %hhu",
|
gb_connection_err(connection, "send data result %hhu",
|
||||||
response->status);
|
operation->result);
|
||||||
retval = -EIO;
|
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
gb_operation_destroy(operation);
|
gb_operation_destroy(operation);
|
||||||
|
Loading…
Reference in New Issue
Block a user