Commit c08b1dda authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: dynamically allocate requests and responses

Have an operation's request and response messages be dynamically
allocated rather than embedded in an operation.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 0a4e14a8
...@@ -119,7 +119,7 @@ static int battery_operation(struct gb_battery *gb, int type, ...@@ -119,7 +119,7 @@ static int battery_operation(struct gb_battery *gb, int type,
operation->result); operation->result);
} else { } else {
/* Good response, so copy to the caller's buffer */ /* Good response, so copy to the caller's buffer */
memcpy(response, operation->response.payload, response_size); memcpy(response, operation->response->payload, response_size);
} }
out: out:
gb_operation_destroy(operation); gb_operation_destroy(operation);
......
...@@ -142,7 +142,7 @@ static int gb_gpio_proto_version_operation(struct gb_gpio_controller *gb_gpio_co ...@@ -142,7 +142,7 @@ static int gb_gpio_proto_version_operation(struct gb_gpio_controller *gb_gpio_co
gb_connection_err(connection, "version result %hhu", gb_connection_err(connection, "version result %hhu",
operation->result); operation->result);
} else { } else {
response = operation->response.payload; 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);
...@@ -188,7 +188,7 @@ static int gb_gpio_line_count_operation(struct gb_gpio_controller *gb_gpio_contr ...@@ -188,7 +188,7 @@ static int gb_gpio_line_count_operation(struct gb_gpio_controller *gb_gpio_contr
gb_connection_err(connection, "line count result %hhu", gb_connection_err(connection, "line count result %hhu",
operation->result); operation->result);
} else { } else {
response = operation->response.payload; 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__,
...@@ -217,7 +217,7 @@ static int gb_gpio_activate_operation(struct gb_gpio_controller *gb_gpio_control ...@@ -217,7 +217,7 @@ static int gb_gpio_activate_operation(struct gb_gpio_controller *gb_gpio_control
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->which = which; request->which = which;
/* Synchronous operation--no callback */ /* Synchronous operation--no callback */
...@@ -259,7 +259,7 @@ static int gb_gpio_deactivate_operation(struct gb_gpio_controller *gb_gpio_contr ...@@ -259,7 +259,7 @@ static int gb_gpio_deactivate_operation(struct gb_gpio_controller *gb_gpio_contr
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->which = which; request->which = which;
/* Synchronous operation--no callback */ /* Synchronous operation--no callback */
...@@ -300,7 +300,7 @@ static int gb_gpio_get_direction_operation(struct gb_gpio_controller *gb_gpio_co ...@@ -300,7 +300,7 @@ static int gb_gpio_get_direction_operation(struct gb_gpio_controller *gb_gpio_co
sizeof(*request), sizeof(*response)); sizeof(*request), sizeof(*response));
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->which = which; request->which = which;
/* Synchronous operation--no callback */ /* Synchronous operation--no callback */
...@@ -317,7 +317,7 @@ static int gb_gpio_get_direction_operation(struct gb_gpio_controller *gb_gpio_co ...@@ -317,7 +317,7 @@ static int gb_gpio_get_direction_operation(struct gb_gpio_controller *gb_gpio_co
} else { } else {
u8 direction; u8 direction;
response = operation->response.payload; response = operation->response->payload;
direction = response->direction; 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",
...@@ -349,7 +349,7 @@ static int gb_gpio_direction_in_operation(struct gb_gpio_controller *gb_gpio_con ...@@ -349,7 +349,7 @@ static int gb_gpio_direction_in_operation(struct gb_gpio_controller *gb_gpio_con
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->which = which; request->which = which;
/* Synchronous operation--no callback */ /* Synchronous operation--no callback */
...@@ -390,7 +390,7 @@ static int gb_gpio_direction_out_operation(struct gb_gpio_controller *gb_gpio_co ...@@ -390,7 +390,7 @@ static int gb_gpio_direction_out_operation(struct gb_gpio_controller *gb_gpio_co
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->which = which; request->which = which;
request->value = value_high ? 1 : 0; request->value = value_high ? 1 : 0;
...@@ -433,7 +433,7 @@ static int gb_gpio_get_value_operation(struct gb_gpio_controller *gb_gpio_contro ...@@ -433,7 +433,7 @@ static int gb_gpio_get_value_operation(struct gb_gpio_controller *gb_gpio_contro
sizeof(*request), sizeof(*response)); sizeof(*request), sizeof(*response));
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->which = which; request->which = which;
/* Synchronous operation--no callback */ /* Synchronous operation--no callback */
...@@ -450,7 +450,7 @@ static int gb_gpio_get_value_operation(struct gb_gpio_controller *gb_gpio_contro ...@@ -450,7 +450,7 @@ static int gb_gpio_get_value_operation(struct gb_gpio_controller *gb_gpio_contro
} else { } else {
u8 value; u8 value;
response = operation->response.payload; response = operation->response->payload;
value = response->value; 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",
...@@ -484,7 +484,7 @@ static int gb_gpio_set_value_operation(struct gb_gpio_controller *gb_gpio_contro ...@@ -484,7 +484,7 @@ static int gb_gpio_set_value_operation(struct gb_gpio_controller *gb_gpio_contro
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->which = which; request->which = which;
request->value = value_high ? 1 : 0; request->value = value_high ? 1 : 0;
...@@ -529,7 +529,7 @@ static int gb_gpio_set_debounce_operation(struct gb_gpio_controller *gb_gpio_con ...@@ -529,7 +529,7 @@ static int gb_gpio_set_debounce_operation(struct gb_gpio_controller *gb_gpio_con
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->which = which; request->which = which;
request->usec = cpu_to_le16(debounce_usec); request->usec = cpu_to_le16(debounce_usec);
......
...@@ -116,7 +116,7 @@ static int gb_i2c_proto_version_operation(struct gb_i2c_device *gb_i2c_dev) ...@@ -116,7 +116,7 @@ static int gb_i2c_proto_version_operation(struct gb_i2c_device *gb_i2c_dev)
gb_connection_err(connection, "version result %hhu", gb_connection_err(connection, "version result %hhu",
operation->result); operation->result);
} else { } else {
response = operation->response.payload; 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);
...@@ -168,7 +168,7 @@ static int gb_i2c_functionality_operation(struct gb_i2c_device *gb_i2c_dev) ...@@ -168,7 +168,7 @@ static int gb_i2c_functionality_operation(struct gb_i2c_device *gb_i2c_dev)
gb_connection_err(connection, "functionality result %hhu", gb_connection_err(connection, "functionality result %hhu",
operation->result); operation->result);
} else { } else {
response = operation->response.payload; 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);
...@@ -190,7 +190,7 @@ static int gb_i2c_timeout_operation(struct gb_i2c_device *gb_i2c_dev, u16 msec) ...@@ -190,7 +190,7 @@ static int gb_i2c_timeout_operation(struct gb_i2c_device *gb_i2c_dev, u16 msec)
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->msec = cpu_to_le16(msec); request->msec = cpu_to_le16(msec);
/* Synchronous operation--no callback */ /* Synchronous operation--no callback */
...@@ -225,7 +225,7 @@ static int gb_i2c_retries_operation(struct gb_i2c_device *gb_i2c_dev, ...@@ -225,7 +225,7 @@ static int gb_i2c_retries_operation(struct gb_i2c_device *gb_i2c_dev,
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->retries = retries; request->retries = retries;
/* Synchronous operation--no callback */ /* Synchronous operation--no callback */
...@@ -310,7 +310,7 @@ gb_i2c_transfer_request(struct gb_connection *connection, ...@@ -310,7 +310,7 @@ gb_i2c_transfer_request(struct gb_connection *connection,
if (!operation) if (!operation)
return NULL; return NULL;
request = operation->request.payload; request = operation->request->payload;
request->op_count = cpu_to_le16(op_count); request->op_count = cpu_to_le16(op_count);
/* Fill in the ops array */ /* Fill in the ops array */
op = &request->ops[0]; op = &request->ops[0];
...@@ -376,7 +376,7 @@ static int gb_i2c_transfer_operation(struct gb_i2c_device *gb_i2c_dev, ...@@ -376,7 +376,7 @@ static int gb_i2c_transfer_operation(struct gb_i2c_device *gb_i2c_dev,
operation->result); operation->result);
} }
} else { } else {
response = operation->response.payload; 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;
} }
......
...@@ -81,7 +81,7 @@ static void gb_pending_operation_insert(struct gb_operation *operation) ...@@ -81,7 +81,7 @@ static void gb_pending_operation_insert(struct gb_operation *operation)
spin_unlock_irq(&gb_operations_lock); spin_unlock_irq(&gb_operations_lock);
/* Store the operation id in the request header */ /* Store the operation id in the request header */
header = operation->request.header; header = operation->request->header;
header->operation_id = cpu_to_le16(operation->id); header->operation_id = cpu_to_le16(operation->id);
} }
...@@ -167,7 +167,7 @@ int gb_operation_wait(struct gb_operation *operation) ...@@ -167,7 +167,7 @@ int gb_operation_wait(struct gb_operation *operation)
ret = wait_for_completion_interruptible(&operation->completion); ret = wait_for_completion_interruptible(&operation->completion);
/* If interrupted, cancel the in-flight buffer */ /* If interrupted, cancel the in-flight buffer */
if (ret < 0) if (ret < 0)
gb_message_cancel(&operation->request); gb_message_cancel(operation->request);
return ret; return ret;
} }
...@@ -177,7 +177,7 @@ static void gb_operation_request_handle(struct gb_operation *operation) ...@@ -177,7 +177,7 @@ static void gb_operation_request_handle(struct gb_operation *operation)
struct gb_protocol *protocol = operation->connection->protocol; struct gb_protocol *protocol = operation->connection->protocol;
struct gb_operation_msg_hdr *header; struct gb_operation_msg_hdr *header;
header = operation->request.header; header = operation->request->header;
/* /*
* If the protocol has no incoming request handler, report * If the protocol has no incoming request handler, report
...@@ -205,7 +205,7 @@ static void gb_operation_recv_work(struct work_struct *recv_work) ...@@ -205,7 +205,7 @@ static void gb_operation_recv_work(struct work_struct *recv_work)
bool incoming_request; bool incoming_request;
operation = container_of(recv_work, struct gb_operation, recv_work); operation = container_of(recv_work, struct gb_operation, recv_work);
incoming_request = operation->response.header == NULL; incoming_request = operation->response->header == NULL;
if (incoming_request) if (incoming_request)
gb_operation_request_handle(operation); gb_operation_request_handle(operation);
gb_operation_complete(operation); gb_operation_complete(operation);
...@@ -251,61 +251,53 @@ gb_buffer_free(struct greybus_host_device *hd, void *buffer) ...@@ -251,61 +251,53 @@ gb_buffer_free(struct greybus_host_device *hd, void *buffer)
} }
/* /*
* Allocate a buffer to be used for an operation request or response * Allocate a message to be used for an operation request or
* message. For outgoing messages, both types of message contain a * response. For outgoing messages, both types of message contain a
* common header, which is filled in here. Incoming requests or * common header, which is filled in here. Incoming requests or
* responses also contain the same header, but there's no need to * responses also contain the same header, but there's no need to
* initialize it here (it'll be overwritten by the incoming * initialize it here (it'll be overwritten by the incoming
* message). * message).
*/ */
static int gb_operation_message_init(struct gb_operation *operation, static struct gb_message *
u8 type, size_t size, gb_operation_message_alloc(struct greybus_host_device *hd, u8 type,
bool request, gfp_t gfp_flags) size_t size, gfp_t gfp_flags)
{ {
struct gb_connection *connection = operation->connection;
struct greybus_host_device *hd = connection->hd;
struct gb_message *message; struct gb_message *message;
struct gb_operation_msg_hdr *header; struct gb_operation_msg_hdr *header;
size += sizeof(*header); size += sizeof(*header);
if (size > hd->buffer_size_max) if (size > hd->buffer_size_max)
return -E2BIG; return NULL;
if (request) { message = kzalloc(sizeof(*message), gfp_flags);
message = &operation->request; if (!message)
} else { return NULL;
message = &operation->response;
type |= GB_OPERATION_TYPE_RESPONSE;
}
message->header = gb_buffer_alloc(hd, size, gfp_flags); header = gb_buffer_alloc(hd, size, gfp_flags);
if (!message->header) if (!header) {
return -ENOMEM; kfree(message);
message->size = size; return NULL;
}
/* Fill in the header structure */ /* Fill in the header structure */
header = message->header;
header->size = cpu_to_le16(size); header->size = cpu_to_le16(size);
header->operation_id = 0; /* Filled in when submitted */ header->operation_id = 0; /* Filled in when submitted */
header->type = type; header->type = type;
message->header = header;
message->payload = header + 1; message->payload = header + 1;
message->operation = operation; message->size = size;
return 0; return message;
} }
static void gb_operation_message_exit(struct gb_message *message) static void gb_operation_message_free(struct gb_message *message)
{ {
struct greybus_host_device *hd; struct greybus_host_device *hd;
hd = message->operation->connection->hd; hd = message->operation->connection->hd;
gb_buffer_free(hd, message->header); gb_buffer_free(hd, message->header);
kfree(message);
message->operation = NULL;
message->payload = NULL;
message->header = NULL;
message->size = 0;
} }
/* /*
...@@ -358,25 +350,28 @@ gb_operation_create_common(struct gb_connection *connection, bool outgoing, ...@@ -358,25 +350,28 @@ gb_operation_create_common(struct gb_connection *connection, bool outgoing,
u8 type, size_t request_size, u8 type, size_t request_size,
size_t response_size) size_t response_size)
{ {
struct greybus_host_device *hd = connection->hd;
struct gb_operation *operation; struct gb_operation *operation;
gfp_t gfp_flags = response_size ? GFP_KERNEL : GFP_ATOMIC; gfp_t gfp_flags = response_size ? GFP_KERNEL : GFP_ATOMIC;
int ret;
operation = kmem_cache_zalloc(gb_operation_cache, gfp_flags); operation = kmem_cache_zalloc(gb_operation_cache, gfp_flags);
if (!operation) if (!operation)
return NULL; return NULL;
operation->connection = connection; operation->connection = connection;
ret = gb_operation_message_init(operation, type, request_size, operation->request = gb_operation_message_alloc(hd, type, request_size,
true, gfp_flags); gfp_flags);
if (ret) if (!operation->request)
goto err_cache; goto err_cache;
operation->request->operation = operation;
if (outgoing) { if (outgoing) {
ret = gb_operation_message_init(operation, type, response_size, type |= GB_OPERATION_TYPE_RESPONSE;
false, GFP_KERNEL); operation->response = gb_operation_message_alloc(hd, type,
if (ret) response_size, GFP_KERNEL);
if (!operation->response)
goto err_request; goto err_request;
operation->response->operation = operation;
} }
INIT_WORK(&operation->recv_work, gb_operation_recv_work); INIT_WORK(&operation->recv_work, gb_operation_recv_work);
...@@ -392,7 +387,7 @@ gb_operation_create_common(struct gb_connection *connection, bool outgoing, ...@@ -392,7 +387,7 @@ gb_operation_create_common(struct gb_connection *connection, bool outgoing,
return operation; return operation;
err_request: err_request:
gb_operation_message_exit(&operation->request); gb_operation_message_free(operation->request);
err_cache: err_cache:
kmem_cache_free(gb_operation_cache, operation); kmem_cache_free(gb_operation_cache, operation);
...@@ -430,8 +425,8 @@ static void _gb_operation_destroy(struct kref *kref) ...@@ -430,8 +425,8 @@ static void _gb_operation_destroy(struct kref *kref)
list_del(&operation->links); list_del(&operation->links);
spin_unlock_irq(&gb_operations_lock); spin_unlock_irq(&gb_operations_lock);
gb_operation_message_exit(&operation->response); gb_operation_message_free(operation->response);
gb_operation_message_exit(&operation->request); gb_operation_message_free(operation->request);
kmem_cache_free(gb_operation_cache, operation); kmem_cache_free(gb_operation_cache, operation);
} }
...@@ -478,7 +473,7 @@ int gb_operation_request_send(struct gb_operation *operation, ...@@ -478,7 +473,7 @@ int gb_operation_request_send(struct gb_operation *operation,
schedule_delayed_work(&operation->timeout_work, timeout); schedule_delayed_work(&operation->timeout_work, timeout);
/* All set, send the request */ /* All set, send the request */
ret = gb_message_send(&operation->request, GFP_KERNEL); ret = gb_message_send(operation->request, GFP_KERNEL);
if (ret) if (ret)
return ret; return ret;
...@@ -516,7 +511,7 @@ void gb_connection_recv_request(struct gb_connection *connection, ...@@ -516,7 +511,7 @@ void gb_connection_recv_request(struct gb_connection *connection,
return; /* XXX Respond with pre-allocated ENOMEM */ return; /* XXX Respond with pre-allocated ENOMEM */
} }
operation->id = operation_id; operation->id = operation_id;
memcpy(operation->request.header, data, size); memcpy(operation->request->header, data, size);
/* The rest will be handled in work queue context */ /* The rest will be handled in work queue context */
queue_work(gb_operation_recv_workqueue, &operation->recv_work); queue_work(gb_operation_recv_workqueue, &operation->recv_work);
...@@ -546,7 +541,7 @@ static void gb_connection_recv_response(struct gb_connection *connection, ...@@ -546,7 +541,7 @@ static void gb_connection_recv_response(struct gb_connection *connection,
cancel_delayed_work(&operation->timeout_work); cancel_delayed_work(&operation->timeout_work);
gb_pending_operation_remove(operation); gb_pending_operation_remove(operation);
message = &operation->response; message = operation->response;
if (size <= message->size) { if (size <= message->size) {
/* Transfer the operation result from the response header */ /* Transfer the operation result from the response header */
header = message->header; header = message->header;
...@@ -609,9 +604,9 @@ void gb_connection_recv(struct gb_connection *connection, ...@@ -609,9 +604,9 @@ void gb_connection_recv(struct gb_connection *connection,
void gb_operation_cancel(struct gb_operation *operation) void gb_operation_cancel(struct gb_operation *operation)
{ {
operation->canceled = true; operation->canceled = true;
gb_message_cancel(&operation->request); gb_message_cancel(operation->request);
if (operation->response.header) if (operation->response->header)
gb_message_cancel(&operation->response); gb_message_cancel(operation->response);
} }
int gb_operation_init(void) int gb_operation_init(void)
......
...@@ -64,8 +64,8 @@ struct gb_message { ...@@ -64,8 +64,8 @@ struct gb_message {
typedef void (*gb_operation_callback)(struct gb_operation *); typedef void (*gb_operation_callback)(struct gb_operation *);
struct gb_operation { struct gb_operation {
struct gb_connection *connection; struct gb_connection *connection;
struct gb_message request; struct gb_message *request;
struct gb_message response; struct gb_message *response;
u16 id; u16 id;
bool canceled; bool canceled;
......
...@@ -109,7 +109,7 @@ static int gb_pwm_proto_version_operation(struct gb_pwm_chip *pwmc) ...@@ -109,7 +109,7 @@ static int gb_pwm_proto_version_operation(struct gb_pwm_chip *pwmc)
gb_connection_err(connection, "version result %hhu", gb_connection_err(connection, "version result %hhu",
operation->result); operation->result);
} else { } else {
response = operation->response.payload; 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);
...@@ -150,7 +150,7 @@ static int gb_pwm_count_operation(struct gb_pwm_chip *pwmc) ...@@ -150,7 +150,7 @@ static int gb_pwm_count_operation(struct gb_pwm_chip *pwmc)
gb_connection_err(connection, "pwm count result %hhu", gb_connection_err(connection, "pwm count result %hhu",
operation->result); operation->result);
} else { } else {
response = operation->response.payload; response = operation->response->payload;
pwmc->pwm_max = response->count; pwmc->pwm_max = response->count;
} }
out: out:
...@@ -175,7 +175,7 @@ static int gb_pwm_activate_operation(struct gb_pwm_chip *pwmc, ...@@ -175,7 +175,7 @@ static int gb_pwm_activate_operation(struct gb_pwm_chip *pwmc,
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->which = which; request->which = which;
/* Synchronous operation--no callback */ /* Synchronous operation--no callback */
...@@ -212,7 +212,7 @@ static int gb_pwm_deactivate_operation(struct gb_pwm_chip *pwmc, ...@@ -212,7 +212,7 @@ static int gb_pwm_deactivate_operation(struct gb_pwm_chip *pwmc,
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->which = which; request->which = which;
/* Synchronous operation--no callback */ /* Synchronous operation--no callback */
...@@ -248,7 +248,7 @@ static int gb_pwm_config_operation(struct gb_pwm_chip *pwmc, ...@@ -248,7 +248,7 @@ static int gb_pwm_config_operation(struct gb_pwm_chip *pwmc,
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->which = which; request->which = which;
request->duty = duty; request->duty = duty;
request->period = period; request->period = period;
...@@ -287,7 +287,7 @@ static int gb_pwm_set_polarity_operation(struct gb_pwm_chip *pwmc, ...@@ -287,7 +287,7 @@ static int gb_pwm_set_polarity_operation(struct gb_pwm_chip *pwmc,
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->which = which; request->which = which;
request->polarity = polarity; request->polarity = polarity;
...@@ -325,7 +325,7 @@ static int gb_pwm_enable_operation(struct gb_pwm_chip *pwmc, ...@@ -325,7 +325,7 @@ static int gb_pwm_enable_operation(struct gb_pwm_chip *pwmc,
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->which = which; request->which = which;
/* Synchronous operation--no callback */ /* Synchronous operation--no callback */
...@@ -362,7 +362,7 @@ static int gb_pwm_disable_operation(struct gb_pwm_chip *pwmc, ...@@ -362,7 +362,7 @@ static int gb_pwm_disable_operation(struct gb_pwm_chip *pwmc,
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->which = which; request->which = which;
/* Synchronous operation--no callback */ /* Synchronous operation--no callback */
......
...@@ -159,7 +159,7 @@ static int get_version(struct gb_tty *tty) ...@@ -159,7 +159,7 @@ static int get_version(struct gb_tty *tty)
gb_connection_err(tty->connection, "result %hhu", gb_connection_err(tty->connection, "result %hhu",
operation->result); operation->result);
} else { } else {
response = operation->response.payload; response = operation->response->payload;
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",
response->major, GB_UART_VERSION_MAJOR); response->major, GB_UART_VERSION_MAJOR);
...@@ -192,7 +192,7 @@ static int send_data(struct gb_tty *tty, u16 size, const u8 *data) ...@@ -192,7 +192,7 @@ static int send_data(struct gb_tty *tty, u16 size, const u8 *data)
sizeof(*request) + size, 0); sizeof(*request) + size, 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->size = cpu_to_le16(size); request->size = cpu_to_le16(size);
memcpy(&request->data[0], data, size); memcpy(&request->data[0], data, size);
...@@ -227,7 +227,7 @@ static int send_line_coding(struct gb_tty *tty, ...@@ -227,7 +227,7 @@ static int send_line_coding(struct gb_tty *tty,
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
memcpy(&request->line_coding, line_coding, sizeof(*line_coding)); memcpy(&request->line_coding, line_coding, sizeof(*line_coding));
/* Synchronous operation--no callback */ /* Synchronous operation--no callback */
...@@ -261,7 +261,7 @@ static int send_control(struct gb_tty *tty, u16 control) ...@@ -261,7 +261,7 @@ static int send_control(struct gb_tty *tty, u16 control)
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->control = cpu_to_le16(control); request->control = cpu_to_le16(control);
/* Synchronous operation--no callback */ /* Synchronous operation--no callback */
...@@ -299,7 +299,7 @@ static int send_break(struct gb_tty *tty, u8 state) ...@@ -299,7 +299,7 @@ static int send_break(struct gb_tty *tty, u8 state)
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->state = state; request->state = state;
/* Synchronous operation--no callback */ /* Synchronous operation--no callback */
......
...@@ -71,7 +71,7 @@ static int request_operation(struct gb_connection *connection, int type, ...@@ -71,7 +71,7 @@ static int request_operation(struct gb_connection *connection, int type,
} 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, operation->response.payload, memcpy(response, operation->response->payload,
response_size); response_size);
} }
out: out:
...@@ -119,7 +119,7 @@ static int turn_on(struct gb_vibrator_device *vib, u16 timeout_ms) ...@@ -119,7 +119,7 @@ static int turn_on(struct gb_vibrator_device *vib, u16 timeout_ms)
sizeof(*request), 0); sizeof(*request), 0);
if (!operation) if (!operation)
return -ENOMEM; return -ENOMEM;
request = operation->request.payload; request = operation->request->payload;
request->timeout_ms = cpu_to_le16(timeout_ms); request->timeout_ms = cpu_to_le16(timeout_ms);
/* Synchronous operation--no callback */ /* Synchronous operation--no callback */
......
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