From eeeed42250f851a9c3368448b63c5aeaae65962a Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Fri, 3 Oct 2014 15:05:22 -0500 Subject: [PATCH] greybus: define gb_connection_err() Define a function that prints error information about a Greybus connection in a standard format. This adopts the convention that [M:I:C] represents the "path" the connection represents--specifying the module id, the interface number on that module, and the connection id on that interface. Signed-off-by: Alex Elder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/connection.c | 18 ++++++++++++++++++ drivers/staging/greybus/connection.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index c50472d07831..80ebe1d305ae 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -116,3 +116,21 @@ u16 gb_connection_op_id(struct gb_connection *connection) { return (u16)(atomic_inc_return(&connection->op_cycle) % U16_MAX); } + +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->interface->gmod->module_id, + connection->interface->id, + connection->interface_cport_id, &vaf); + + va_end(args); +} diff --git a/drivers/staging/greybus/connection.h b/drivers/staging/greybus/connection.h index f2588a74904a..61e94357db3a 100644 --- a/drivers/staging/greybus/connection.h +++ b/drivers/staging/greybus/connection.h @@ -35,4 +35,7 @@ void gb_connection_destroy(struct gb_connection *connection); u16 gb_connection_op_id(struct gb_connection *connection); +__printf(2, 3) +void gb_connection_err(struct gb_connection *connection, const char *fmt, ...); + #endif /* __CONNECTION_H */ -- 2.39.2