greybus: connection: replace custom error function with dev_err
authorJohan Hovold <johan@hovoldconsulting.com>
Thu, 19 Mar 2015 15:46:17 +0000 (16:46 +0100)
committerGreg Kroah-Hartman <greg@kroah.com>
Thu, 19 Mar 2015 16:28:19 +0000 (17:28 +0100)
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 <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/connection.c
drivers/staging/greybus/connection.h
drivers/staging/greybus/i2c.c
drivers/staging/greybus/operation.c
drivers/staging/greybus/spi.c

index 46e259f05a55994d0613bb8de63459591bca193b..102e1a4c6e745439dcba977e53f3896783157484 100644 (file)
@@ -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;
index b07df79f9d86867c57c9c0666394a9b22be4d5b5..7febf4e03049dbfdb42b02a2a38535cf64e68cbe 100644 (file)
@@ -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);
 
index 0bcd7a9b0e123d7204c519386b2195c0222cf332..84d20e54ae9b95c432f23a6a5b2618c2d8d403dc 100644 (file)
@@ -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;
index d4b59fe79559d67ad2daff7ef3d68454b7be70e0..83359dde1a8f757380a8b04a3e107f7482232a92 100644 (file)
@@ -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 */
        }
 
index ad0c179e51f5573c0e2d18b047078be812628b75..639c9cdac51656ca259f574573aa71a5330d15e0 100644 (file)
@@ -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;
        }