From 25eb732954ee656edd92770f498d28f87086511b Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 19 Mar 2015 16:46:17 +0100 Subject: [PATCH] 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: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/connection.c | 19 ------------------- drivers/staging/greybus/connection.h | 2 -- drivers/staging/greybus/i2c.c | 4 ++-- drivers/staging/greybus/operation.c | 14 +++++++------- drivers/staging/greybus/spi.c | 11 +++++------ 5 files changed, 14 insertions(+), 36 deletions(-) diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index 46e259f05a55..102e1a4c6e74 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -255,25 +255,6 @@ void gb_connection_destroy(struct gb_connection *connection) 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 ret; diff --git a/drivers/staging/greybus/connection.h b/drivers/staging/greybus/connection.h index b07df79f9d86..7febf4e03049 100644 --- a/drivers/staging/greybus/connection.h +++ b/drivers/staging/greybus/connection.h @@ -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, 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); diff --git a/drivers/staging/greybus/i2c.c b/drivers/staging/greybus/i2c.c index 0bcd7a9b0e12..84d20e54ae9b 100644 --- a/drivers/staging/greybus/i2c.c +++ b/drivers/staging/greybus/i2c.c @@ -178,8 +178,8 @@ gb_i2c_operation_create(struct gb_connection *connection, u32 i; if (msg_count > (u32)U16_MAX) { - gb_connection_err(connection, "msg_count (%u) too big", - msg_count); + dev_err(&connection->dev, "msg_count (%u) too big\n", + msg_count); return NULL; } op_count = (u16)msg_count; diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c index d4b59fe79559..83359dde1a8f 100644 --- a/drivers/staging/greybus/operation.c +++ b/drivers/staging/greybus/operation.c @@ -220,7 +220,7 @@ static void gb_operation_request_handle(struct gb_operation *operation) return; } - gb_connection_err(operation->connection, + dev_err(&operation->connection->dev, "unexpected incoming request type 0x%02hhx\n", operation->type); if (gb_operation_result_set(operation, -EPROTONOSUPPORT)) queue_work(gb_operation_workqueue, &operation->work); @@ -793,7 +793,7 @@ static void gb_connection_recv_request(struct gb_connection *connection, operation = gb_operation_create_incoming(connection, operation_id, type, data, size); 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 */ } @@ -830,14 +830,14 @@ static void gb_connection_recv_response(struct gb_connection *connection, operation = gb_operation_find(connection, operation_id); if (!operation) { - gb_connection_err(connection, "operation not found"); + dev_err(&connection->dev, "operation not found\n"); return; } message = operation->response; message_size = sizeof(*message->header) + message->payload_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); errno = -EMSGSIZE; } @@ -865,20 +865,20 @@ void gb_connection_recv(struct gb_connection *connection, u16 operation_id; 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); return; } if (size < sizeof(*header)) { - gb_connection_err(connection, "message too small"); + dev_err(&connection->dev, "message too small\n"); return; } header = data; msg_size = (size_t)le16_to_cpu(header->size); if (msg_size > size) { - gb_connection_err(connection, "incomplete message"); + dev_err(&connection->dev, "incomplete message\n"); return; /* XXX Should still complete operation */ } diff --git a/drivers/staging/greybus/spi.c b/drivers/staging/greybus/spi.c index ad0c179e51f5..639c9cdac516 100644 --- a/drivers/staging/greybus/spi.c +++ b/drivers/staging/greybus/spi.c @@ -143,9 +143,8 @@ gb_spi_operation_create(struct gb_connection *connection, /* Find number of transfers queued and tx/rx length in the message */ list_for_each_entry(xfer, &msg->transfers, transfer_list) { if (!xfer->tx_buf && !xfer->rx_buf) { - gb_connection_err(connection, - "Bufferless transfer, length %u\n", - xfer->len); + dev_err(&connection->dev, + "bufferless transfer, length %u\n", xfer->len); return NULL; } @@ -160,8 +159,8 @@ gb_spi_operation_create(struct gb_connection *connection, /* Too many transfers ? */ if (count > (u32)U16_MAX) { - gb_connection_err(connection, "transfer count (%u) too big", - count); + dev_err(&connection->dev, "transfer count (%u) too big\n", + count); return NULL; } @@ -382,7 +381,7 @@ static int gb_spi_connection_init(struct gb_connection *connection) /* Allocate master with space for data */ master = spi_alloc_master(&connection->dev, sizeof(*spi)); if (!master) { - gb_connection_err(connection, "cannot alloc SPI master\n"); + dev_err(&connection->dev, "cannot alloc SPI master\n"); return -ENOMEM; }