Commit 25eb7329 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: connection: replace custom error function with dev_err

Remove custom connection error function and replace it with dev_err.

The standard error function provides more information in the message
prefix (e.g. includes the interface id), has a well-known semantics
(e.g. does does not add newlines to messages), and is even somewhat
shorter to type.

Note that some uses of the custom function were already adding double
newlines due to the non-standard semantics.
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent fe4c0e54
...@@ -255,25 +255,6 @@ void gb_connection_destroy(struct gb_connection *connection) ...@@ -255,25 +255,6 @@ void gb_connection_destroy(struct gb_connection *connection)
device_del(&connection->dev); device_del(&connection->dev);
} }
void gb_connection_err(struct gb_connection *connection, const char *fmt, ...)
{
struct va_format vaf;
va_list args;
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
pr_err("greybus: [%hhu:%hhu:%hu]: %pV\n",
connection->bundle->intf->module->module_id,
connection->bundle->id,
connection->bundle_cport_id, &vaf);
va_end(args);
}
EXPORT_SYMBOL_GPL(gb_connection_err);
int gb_connection_init(struct gb_connection *connection) int gb_connection_init(struct gb_connection *connection)
{ {
int ret; int ret;
......
...@@ -58,8 +58,6 @@ struct gb_connection *gb_hd_connection_find(struct greybus_host_device *hd, ...@@ -58,8 +58,6 @@ struct gb_connection *gb_hd_connection_find(struct greybus_host_device *hd,
void greybus_data_rcvd(struct greybus_host_device *hd, u16 cport_id, void greybus_data_rcvd(struct greybus_host_device *hd, u16 cport_id,
u8 *data, size_t length); u8 *data, size_t length);
__printf(2, 3)
void gb_connection_err(struct gb_connection *connection, const char *fmt, ...);
void gb_connection_bind_protocol(struct gb_connection *connection); void gb_connection_bind_protocol(struct gb_connection *connection);
......
...@@ -178,8 +178,8 @@ gb_i2c_operation_create(struct gb_connection *connection, ...@@ -178,8 +178,8 @@ gb_i2c_operation_create(struct gb_connection *connection,
u32 i; u32 i;
if (msg_count > (u32)U16_MAX) { if (msg_count > (u32)U16_MAX) {
gb_connection_err(connection, "msg_count (%u) too big", dev_err(&connection->dev, "msg_count (%u) too big\n",
msg_count); msg_count);
return NULL; return NULL;
} }
op_count = (u16)msg_count; op_count = (u16)msg_count;
......
...@@ -220,7 +220,7 @@ static void gb_operation_request_handle(struct gb_operation *operation) ...@@ -220,7 +220,7 @@ static void gb_operation_request_handle(struct gb_operation *operation)
return; return;
} }
gb_connection_err(operation->connection, dev_err(&operation->connection->dev,
"unexpected incoming request type 0x%02hhx\n", operation->type); "unexpected incoming request type 0x%02hhx\n", operation->type);
if (gb_operation_result_set(operation, -EPROTONOSUPPORT)) if (gb_operation_result_set(operation, -EPROTONOSUPPORT))
queue_work(gb_operation_workqueue, &operation->work); queue_work(gb_operation_workqueue, &operation->work);
...@@ -793,7 +793,7 @@ static void gb_connection_recv_request(struct gb_connection *connection, ...@@ -793,7 +793,7 @@ static void gb_connection_recv_request(struct gb_connection *connection,
operation = gb_operation_create_incoming(connection, operation_id, operation = gb_operation_create_incoming(connection, operation_id,
type, data, size); type, data, size);
if (!operation) { if (!operation) {
gb_connection_err(connection, "can't create operation"); dev_err(&connection->dev, "can't create operation\n");
return; /* XXX Respond with pre-allocated ENOMEM */ return; /* XXX Respond with pre-allocated ENOMEM */
} }
...@@ -830,14 +830,14 @@ static void gb_connection_recv_response(struct gb_connection *connection, ...@@ -830,14 +830,14 @@ static void gb_connection_recv_response(struct gb_connection *connection,
operation = gb_operation_find(connection, operation_id); operation = gb_operation_find(connection, operation_id);
if (!operation) { if (!operation) {
gb_connection_err(connection, "operation not found"); dev_err(&connection->dev, "operation not found\n");
return; return;
} }
message = operation->response; message = operation->response;
message_size = sizeof(*message->header) + message->payload_size; message_size = sizeof(*message->header) + message->payload_size;
if (!errno && size != message_size) { if (!errno && size != message_size) {
gb_connection_err(connection, "bad message size (%zu != %zu)", dev_err(&connection->dev, "bad message size (%zu != %zu)\n",
size, message_size); size, message_size);
errno = -EMSGSIZE; errno = -EMSGSIZE;
} }
...@@ -865,20 +865,20 @@ void gb_connection_recv(struct gb_connection *connection, ...@@ -865,20 +865,20 @@ void gb_connection_recv(struct gb_connection *connection,
u16 operation_id; u16 operation_id;
if (connection->state != GB_CONNECTION_STATE_ENABLED) { if (connection->state != GB_CONNECTION_STATE_ENABLED) {
gb_connection_err(connection, "dropping %zu received bytes", dev_err(&connection->dev, "dropping %zu received bytes\n",
size); size);
return; return;
} }
if (size < sizeof(*header)) { if (size < sizeof(*header)) {
gb_connection_err(connection, "message too small"); dev_err(&connection->dev, "message too small\n");
return; return;
} }
header = data; header = data;
msg_size = (size_t)le16_to_cpu(header->size); msg_size = (size_t)le16_to_cpu(header->size);
if (msg_size > size) { if (msg_size > size) {
gb_connection_err(connection, "incomplete message"); dev_err(&connection->dev, "incomplete message\n");
return; /* XXX Should still complete operation */ return; /* XXX Should still complete operation */
} }
......
...@@ -143,9 +143,8 @@ gb_spi_operation_create(struct gb_connection *connection, ...@@ -143,9 +143,8 @@ gb_spi_operation_create(struct gb_connection *connection,
/* Find number of transfers queued and tx/rx length in the message */ /* Find number of transfers queued and tx/rx length in the message */
list_for_each_entry(xfer, &msg->transfers, transfer_list) { list_for_each_entry(xfer, &msg->transfers, transfer_list) {
if (!xfer->tx_buf && !xfer->rx_buf) { if (!xfer->tx_buf && !xfer->rx_buf) {
gb_connection_err(connection, dev_err(&connection->dev,
"Bufferless transfer, length %u\n", "bufferless transfer, length %u\n", xfer->len);
xfer->len);
return NULL; return NULL;
} }
...@@ -160,8 +159,8 @@ gb_spi_operation_create(struct gb_connection *connection, ...@@ -160,8 +159,8 @@ gb_spi_operation_create(struct gb_connection *connection,
/* Too many transfers ? */ /* Too many transfers ? */
if (count > (u32)U16_MAX) { if (count > (u32)U16_MAX) {
gb_connection_err(connection, "transfer count (%u) too big", dev_err(&connection->dev, "transfer count (%u) too big\n",
count); count);
return NULL; return NULL;
} }
...@@ -382,7 +381,7 @@ static int gb_spi_connection_init(struct gb_connection *connection) ...@@ -382,7 +381,7 @@ static int gb_spi_connection_init(struct gb_connection *connection)
/* Allocate master with space for data */ /* Allocate master with space for data */
master = spi_alloc_master(&connection->dev, sizeof(*spi)); master = spi_alloc_master(&connection->dev, sizeof(*spi));
if (!master) { if (!master) {
gb_connection_err(connection, "cannot alloc SPI master\n"); dev_err(&connection->dev, "cannot alloc SPI master\n");
return -ENOMEM; return -ENOMEM;
} }
......
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