#define GB_BATTERY_TYPE_VOLTAGE 0x07
struct gb_battery_proto_version_response {
- __u8 status;
__u8 major;
__u8 minor;
};
#define GB_BATTERY_TECH_LiMn 0x0006
struct gb_battery_technology_response {
- __u8 status;
__le32 technology;
};
#define GB_BATTERY_STATUS_FULL 0x0004
struct gb_battery_status_response {
- __u8 status;
__le16 battery_status;
};
struct gb_battery_max_voltage_response {
- __u8 status;
__le32 max_voltage;
};
struct gb_battery_capacity_response {
- __u8 status;
__le32 capacity;
};
struct gb_battery_temperature_response {
- __u8 status;
__le32 temperature;
};
struct gb_battery_voltage_response {
- __u8 status;
__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
* function implements all of the requests by allowing the caller to
{
struct gb_connection *connection = gb->connection;
struct gb_operation *operation;
- struct gb_generic_battery_response *fake_response;
int ret;
operation = gb_operation_create(connection, type, 0, response_size);
* layout for where the status is, so cast this to a random request so
* we can see the status easier.
*/
- fake_response = operation->response.payload;
- if (fake_response->status) {
- gb_connection_err(connection, "version response %hhu",
- fake_response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "operation result %hhu",
+ operation->result);
} else {
/* Good response, so copy to the caller's buffer */
- memcpy(response, fake_response, response_size);
+ memcpy(response, operation->response.payload, response_size);
}
out:
gb_operation_destroy(operation);
/* version request has no payload */
struct gb_gpio_proto_version_response {
- __u8 status;
__u8 major;
__u8 minor;
};
/* line count request has no payload */
struct gb_gpio_line_count_response {
- __u8 status;
__u8 count;
};
__u8 which;
};
struct gb_gpio_activate_response {
- __u8 status;
};
struct gb_gpio_deactivate_request {
__u8 which;
};
-struct gb_gpio_deactivate_response {
- __u8 status;
-};
+/* deactivate response has no payload */
struct gb_gpio_get_direction_request {
__u8 which;
};
struct gb_gpio_get_direction_response {
- __u8 status;
__u8 direction;
};
struct gb_gpio_direction_in_request {
__u8 which;
};
-struct gb_gpio_direction_in_response {
- __u8 status;
-};
+/* direction in response has no payload */
struct gb_gpio_direction_out_request {
__u8 which;
__u8 value;
};
-struct gb_gpio_direction_out_response {
- __u8 status;
-};
+/* direction out response has no payload */
struct gb_gpio_get_value_request {
__u8 which;
};
struct gb_gpio_get_value_response {
- __u8 status;
__u8 value;
};
__u8 which;
__u8 value;
};
-struct gb_gpio_set_value_response {
- __u8 status;
-};
+/* set value response has no payload */
struct gb_gpio_set_debounce_request {
__u8 which;
__le16 usec;
};
-struct gb_gpio_set_debounce_response {
- __u8 status;
-};
+/* debounce response has no payload */
/*
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "version response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "version result %hhu",
+ operation->result);
} else {
+ response = operation->response.payload;
if (response->major > GB_GPIO_VERSION_MAJOR) {
pr_err("unsupported major version (%hhu > %hhu)\n",
response->major, GB_GPIO_VERSION_MAJOR);
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "line count response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "line count result %hhu",
+ operation->result);
} else {
+ response = operation->response.payload;
gb_gpio_controller->line_max = response->count;
pr_debug("%s: count = %u\n", __func__,
struct gb_connection *connection = gb_gpio_controller->connection;
struct gb_operation *operation;
struct gb_gpio_activate_request *request;
- struct gb_gpio_activate_response *response;
int ret;
if (which > gb_gpio_controller->line_max)
/* activate response has no payload */
operation = gb_operation_create(connection,
GB_GPIO_TYPE_ACTIVATE,
- sizeof(*request), sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "activate response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "activate result %hhu",
+ operation->result);
} else {
gb_gpio_controller->lines[which].active = true;
struct gb_connection *connection = gb_gpio_controller->connection;
struct gb_operation *operation;
struct gb_gpio_deactivate_request *request;
- struct gb_gpio_deactivate_response *response;
int ret;
if (which > gb_gpio_controller->line_max)
/* deactivate response has no payload */
operation = gb_operation_create(connection,
GB_GPIO_TYPE_DEACTIVATE,
- sizeof(*request), sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "deactivate response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "deactivate result %hhu",
+ operation->result);
} else {
gb_gpio_controller->lines[which].active = false;
pr_debug("%s: %u is now inactive\n", __func__, which);
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "get direction response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "get direction result %hhu",
+ operation->result);
} else {
- u8 direction = response->direction;
+ u8 direction;
+ response = operation->response.payload;
+ direction = response->direction;
if (direction && direction != 1)
pr_warn("gpio %u direction was %u (should be 0 or 1)\n",
which, direction);
struct gb_connection *connection = gb_gpio_controller->connection;
struct gb_operation *operation;
struct gb_gpio_direction_in_request *request;
- struct gb_gpio_direction_in_response *response;
int ret;
if (which > gb_gpio_controller->line_max)
/* direction_in response has no payload */
operation = gb_operation_create(connection,
GB_GPIO_TYPE_DIRECTION_IN,
- sizeof(*request), sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "direction in response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "direction in result %hhu",
+ operation->result);
} else {
gb_gpio_controller->lines[which].direction = 1;
pr_debug("%s: direction of %u is now in\n", __func__, which);
struct gb_connection *connection = gb_gpio_controller->connection;
struct gb_operation *operation;
struct gb_gpio_direction_out_request *request;
- struct gb_gpio_direction_out_response *response;
int ret;
if (which > gb_gpio_controller->line_max)
/* direction_out response has no payload */
operation = gb_operation_create(connection,
GB_GPIO_TYPE_DIRECTION_OUT,
- sizeof(*request), sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "direction out response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "direction out result %hhu",
+ operation->result);
} else {
gb_gpio_controller->lines[which].direction = 0;
pr_debug("%s: direction of %u is now out, value %s\n", __func__,
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "get value response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "get value result %hhu",
+ operation->result);
} else {
- u8 value = response->value;
+ u8 value;
+ response = operation->response.payload;
+ value = response->value;
if (value && value != 1)
pr_warn("gpio %u value was %u (should be 0 or 1)\n",
which, value);
struct gb_connection *connection = gb_gpio_controller->connection;
struct gb_operation *operation;
struct gb_gpio_set_value_request *request;
- struct gb_gpio_set_value_response *response;
int ret;
if (which > gb_gpio_controller->line_max)
/* set_value response has no payload */
operation = gb_operation_create(connection,
GB_GPIO_TYPE_SET_VALUE,
- sizeof(*request), sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "set value response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "set value result %hhu",
+ operation->result);
} else {
/* XXX should this set direction to out? */
gb_gpio_controller->lines[which].value = request->value;
struct gb_connection *connection = gb_gpio_controller->connection;
struct gb_operation *operation;
struct gb_gpio_set_debounce_request *request;
- struct gb_gpio_set_debounce_response *response;
int ret;
if (which > gb_gpio_controller->line_max)
/* set_debounce response has no payload */
operation = gb_operation_create(connection,
GB_GPIO_TYPE_SET_DEBOUNCE,
- sizeof(*request), sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "set debounce response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "set debounce result %hhu",
+ operation->result);
} else {
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,
/* version request has no payload */
struct gb_i2c_proto_version_response {
- __u8 status;
__u8 major;
__u8 minor;
};
/* functionality request has no payload */
struct gb_i2c_functionality_response {
- __u8 status;
__le32 functionality;
};
struct gb_i2c_timeout_request {
__le16 msec;
};
-struct gb_i2c_timeout_response {
- __u8 status;
-};
+/* timeout response has no payload */
struct gb_i2c_retries_request {
__u8 retries;
};
-struct gb_i2c_retries_response {
- __u8 status;
-};
+/* retries response has no payload */
/*
* Outgoing data immediately follows the op count and ops array.
struct gb_i2c_transfer_op ops[0]; /* op_count of these */
};
struct gb_i2c_transfer_response {
- __u8 status;
__u8 data[0]; /* inbound data */
};
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "version response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "version result %hhu",
+ operation->result);
} else {
+ response = operation->response.payload;
if (response->major > GB_I2C_VERSION_MAJOR) {
pr_err("unsupported major version (%hhu > %hhu)\n",
response->major, GB_I2C_VERSION_MAJOR);
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "functionality response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "functionality result %hhu",
+ operation->result);
} else {
+ response = operation->response.payload;
functionality = le32_to_cpu(response->functionality);
gb_i2c_dev->functionality =
gb_i2c_functionality_map(functionality);
struct gb_connection *connection = gb_i2c_dev->connection;
struct gb_operation *operation;
struct gb_i2c_timeout_request *request;
- struct gb_i2c_timeout_response *response;
int ret;
operation = gb_operation_create(connection, GB_I2C_TYPE_TIMEOUT,
- sizeof(*request), sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "timeout response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "timeout result %hhu",
+ operation->result);
} else {
gb_i2c_dev->timeout_msec = msec;
}
struct gb_connection *connection = gb_i2c_dev->connection;
struct gb_operation *operation;
struct gb_i2c_retries_request *request;
- struct gb_i2c_retries_response *response;
int ret;
operation = gb_operation_create(connection, GB_I2C_TYPE_RETRIES,
- sizeof(*request), sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "retries response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "retries result %hhu",
+ operation->result);
} else {
gb_i2c_dev->retries = retries;
}
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- if (response->status == GB_OP_RETRY) {
- ret = -EAGAIN;
- } else {
- gb_connection_err(connection, "transfer response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ if (ret != -EAGAIN) {
+ gb_connection_err(connection, "transfer result %hhu",
+ operation->result);
}
} else {
+ response = operation->response.payload;
gb_i2c_transfer_response(msgs, msg_count, response->data);
ret = msg_count;
}
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->result = *(char *)message->payload; /* Eeew. */
operation->result = header->result;
+
+ /* We must ignore the payload if a bad status is returned */
if (operation->result == GB_OP_SUCCESS)
memcpy(message->buffer, data, size);
#define GB_PWM_TYPE_DISABLE 0x08
#define GB_PWM_TYPE_RESPONSE 0x80 /* OR'd with rest */
-struct gb_pwm_simple_response {
- __u8 status;
-};
-
/* version request has no payload */
struct gb_pwm_proto_version_response {
- __u8 status;
__u8 major;
__u8 minor;
};
/* pwm count request has no payload */
struct gb_pwm_count_response {
- __u8 status;
__u8 count;
};
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "version response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "version result %hhu",
+ operation->result);
} else {
+ response = operation->response.payload;
if (response->major > GB_PWM_VERSION_MAJOR) {
pr_err("unsupported major version (%hhu > %hhu)\n",
response->major, GB_PWM_VERSION_MAJOR);
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "pwm count response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "pwm count result %hhu",
+ operation->result);
} else
+ response = operation->response.payload;
pwmc->pwm_max = response->count;
out:
gb_operation_destroy(operation);
struct gb_connection *connection = pwmc->connection;
struct gb_operation *operation;
struct gb_pwm_activate_request *request;
- struct gb_pwm_simple_response *response;
int ret;
if (which > pwmc->pwm_max)
/* activate response has no payload */
operation = gb_operation_create(connection, GB_PWM_TYPE_ACTIVATE,
- sizeof(*request), sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "activate response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "activate result %hhu",
+ operation->result);
}
out:
gb_operation_destroy(operation);
struct gb_connection *connection = pwmc->connection;
struct gb_operation *operation;
struct gb_pwm_deactivate_request *request;
- struct gb_pwm_simple_response *response;
int ret;
if (which > pwmc->pwm_max)
/* deactivate response has no payload */
operation = gb_operation_create(connection, GB_PWM_TYPE_DEACTIVATE,
- sizeof(*request), sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "deactivate response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "deactivate result %hhu",
+ operation->result);
}
out:
gb_operation_destroy(operation);
struct gb_connection *connection = pwmc->connection;
struct gb_operation *operation;
struct gb_pwm_config_request *request;
- struct gb_pwm_simple_response *response;
int ret;
if (which > pwmc->pwm_max)
return -EINVAL;
operation = gb_operation_create(connection, GB_PWM_TYPE_CONFIG,
- sizeof(*request), sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "config response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "config result %hhu",
+ operation->result);
}
out:
gb_operation_destroy(operation);
struct gb_connection *connection = pwmc->connection;
struct gb_operation *operation;
struct gb_pwm_polarity_request *request;
- struct gb_pwm_simple_response *response;
int ret;
if (which > pwmc->pwm_max)
return -EINVAL;
operation = gb_operation_create(connection, GB_PWM_TYPE_POLARITY,
- sizeof(*request), sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "set polarity response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "set polarity result %hhu",
+ operation->result);
}
out:
gb_operation_destroy(operation);
struct gb_connection *connection = pwmc->connection;
struct gb_operation *operation;
struct gb_pwm_enable_request *request;
- struct gb_pwm_simple_response *response;
int ret;
if (which > pwmc->pwm_max)
/* enable response has no payload */
operation = gb_operation_create(connection, GB_PWM_TYPE_ENABLE,
- sizeof(*request), sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "enable response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "enable result %hhu",
+ operation->result);
}
out:
gb_operation_destroy(operation);
struct gb_connection *connection = pwmc->connection;
struct gb_operation *operation;
struct gb_pwm_disable_request *request;
- struct gb_pwm_simple_response *response;
int ret;
if (which > pwmc->pwm_max)
/* disable response has no payload */
operation = gb_operation_create(connection, GB_PWM_TYPE_DISABLE,
- sizeof(*request), sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "disable response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "disable result %hhu",
+ operation->result);
}
out:
gb_operation_destroy(operation);
#define GB_UART_TYPE_RESPONSE 0x80 /* OR'd with rest */
struct gb_uart_proto_version_response {
- __u8 status;
__u8 major;
__u8 minor;
};
__u16 control;
};
-struct gb_uart_simple_response {
- __u8 status;
-};
-
struct gb_tty {
struct tty_port port;
struct gb_connection *connection;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(tty->connection, "response %hhu",
- response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(tty->connection, "result %hhu",
+ operation->result);
} else {
if (response->major > GB_UART_VERSION_MAJOR) {
pr_err("unsupported major version (%hhu > %hhu)\n",
struct gb_connection *connection = tty->connection;
struct gb_operation *operation;
struct gb_uart_send_data_request *request;
- struct gb_uart_simple_response *response;
int retval;
if (!data || !size)
return 0;
operation = gb_operation_create(connection, GB_UART_REQ_SEND_DATA,
- sizeof(*request) + size,
- sizeof(*response));
+ sizeof(*request) + size, 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "send data response %hhu",
- response->status);
- retval = -EIO;
+ if (operation->result) {
+ retval = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "send data result %hhu",
+ operation->result);
}
out:
gb_operation_destroy(operation);
struct gb_connection *connection = tty->connection;
struct gb_operation *operation;
struct gb_uart_set_line_coding_request *request;
- struct gb_uart_simple_response *response;
int retval;
operation = gb_operation_create(connection, GB_UART_REQ_SET_LINE_CODING,
- sizeof(*request),
- sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "send line coding response %hhu",
- response->status);
- retval = -EIO;
+ if (operation->result) {
+ retval = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "send line coding result %hhu",
+ operation->result);
}
out:
gb_operation_destroy(operation);
struct gb_connection *connection = tty->connection;
struct gb_operation *operation;
struct gb_uart_set_control_line_state_request *request;
- struct gb_uart_simple_response *response;
int retval;
operation = gb_operation_create(connection,
GB_UART_REQ_SET_CONTROL_LINE_STATE,
- sizeof(*request),
- sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "send control response %hhu",
- response->status);
- retval = -EIO;
+ if (operation->result) {
+ retval = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "send control result %hhu",
+ operation->result);
}
out:
gb_operation_destroy(operation);
struct gb_connection *connection = tty->connection;
struct gb_operation *operation;
struct gb_uart_set_break_request *request;
- struct gb_uart_simple_response *response;
int retval;
if ((state != 0) && (state != 1)) {
}
operation = gb_operation_create(connection, GB_UART_REQ_SET_BREAK,
- sizeof(*request),
- sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "send break response %hhu",
- response->status);
- retval = -EIO;
+ if (operation->result) {
+ retval = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "send break result %hhu",
+ operation->result);
}
out:
gb_operation_destroy(operation);
#define GB_VIBRATOR_TYPE_RESPONSE 0x80 /* OR'd with rest */
struct gb_vibrator_proto_version_response {
- __u8 status;
__u8 major;
__u8 minor;
};
__le16 timeout_ms;
};
-struct gb_vibrator_simple_response {
- __u8 status;
-};
-
static int request_operation(struct gb_connection *connection, int type,
void *response, int response_size)
{
struct gb_operation *operation;
- struct gb_vibrator_simple_response *fake_response;
int ret;
operation = gb_operation_create(connection, type, 0, response_size);
* layout for where the status is, so cast this to a random request so
* we can see the status easier.
*/
- fake_response = operation->response.payload;
- if (fake_response->status) {
- gb_connection_err(connection, "response %hhu",
- fake_response->status);
- ret = -EIO;
+ if (operation->result) {
+ ret = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "operation result %hhu",
+ operation->result);
} else {
/* Good request, so copy to the caller's buffer */
if (response_size && response)
- memcpy(response, fake_response, response_size);
+ memcpy(response, operation->response.payload,
+ response_size);
}
out:
gb_operation_destroy(operation);
struct gb_connection *connection = vib->connection;
struct gb_operation *operation;
struct gb_vibrator_on_request *request;
- struct gb_vibrator_simple_response *response;
int retval;
operation = gb_operation_create(connection, GB_VIBRATOR_TYPE_ON,
- sizeof(*request), sizeof(*response));
+ sizeof(*request), 0);
if (!operation)
return -ENOMEM;
request = operation->request.payload;
goto out;
}
- response = operation->response.payload;
- if (response->status) {
- gb_connection_err(connection, "send data response %hhu",
- response->status);
- retval = -EIO;
+ if (operation->result) {
+ retval = gb_operation_status_map(operation->result);
+ gb_connection_err(connection, "send data result %hhu",
+ operation->result);
}
out:
gb_operation_destroy(operation);