From: Johan Hovold Date: Wed, 25 Nov 2015 14:59:19 +0000 (+0100) Subject: greybus: svc: clean up log messages X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=684156a9d6eba32db939b11618d3c14d7e92d630;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git greybus: svc: clean up log messages Use dev_err and friends with the svc device for messages. Clean up error messages. Demote a few warnings to warning level. Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/svc.c b/drivers/staging/greybus/svc.c index 11fa8c91bbe3..62b67cc6f8d9 100644 --- a/drivers/staging/greybus/svc.c +++ b/drivers/staging/greybus/svc.c @@ -7,7 +7,6 @@ * Released under the GPLv2 only. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include #include "greybus.h" @@ -87,15 +86,15 @@ int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, &request, sizeof(request), &response, sizeof(response)); if (ret) { - pr_err("failed to get DME attribute (%hhu %hx %hu) %d\n", - intf_id, attr, selector, ret); + dev_err(&svc->dev, "failed to get DME attribute (%hhu %hx %hu): %d\n", + intf_id, attr, selector, ret); return ret; } result = le16_to_cpu(response.result_code); if (result) { - pr_err("Unipro error %hu while getting DME attribute (%hhu %hx %hu)\n", - result, intf_id, attr, selector); + dev_err(&svc->dev, "UniPro error while getting DME attribute (%hhu %hx %hu): %hu\n", + intf_id, attr, selector, result); return -EINVAL; } @@ -123,15 +122,15 @@ int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, &request, sizeof(request), &response, sizeof(response)); if (ret) { - pr_err("failed to set DME attribute (%hhu %hx %hu %u) %d\n", - intf_id, attr, selector, value, ret); + dev_err(&svc->dev, "failed to set DME attribute (%hhu %hx %hu %u): %d\n", + intf_id, attr, selector, value, ret); return ret; } result = le16_to_cpu(response.result_code); if (result) { - pr_err("Unipro error %hu while setting DME attribute (%hhu %hx %hu %u)\n", - result, intf_id, attr, selector, value); + dev_err(&svc->dev, "UniPro error while setting DME attribute (%hhu %hx %hu %u): %hu\n", + intf_id, attr, selector, value, result); return -EINVAL; } @@ -233,9 +232,10 @@ void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id, ret = gb_operation_sync(connection, GB_SVC_TYPE_CONN_DESTROY, &request, sizeof(request), NULL, 0); - if (ret) - pr_err("failed to destroy connection (%hhu:%hu %hhu:%hu) %d\n", - intf1_id, cport1_id, intf2_id, cport2_id, ret); + if (ret) { + dev_err(&svc->dev, "failed to destroy connection (%hhu:%hu %hhu:%hu): %d\n", + intf1_id, cport1_id, intf2_id, cport2_id, ret); + } } EXPORT_SYMBOL_GPL(gb_svc_connection_destroy); @@ -265,20 +265,21 @@ static void gb_svc_route_destroy(struct gb_svc *svc, u8 intf1_id, u8 intf2_id) ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_ROUTE_DESTROY, &request, sizeof(request), NULL, 0); - if (ret) - pr_err("failed to destroy route (%hhu %hhu) %d\n", - intf1_id, intf2_id, ret); + if (ret) { + dev_err(&svc->dev, "failed to destroy route (%hhu %hhu): %d\n", + intf1_id, intf2_id, ret); + } } static int gb_svc_version_request(struct gb_operation *op) { struct gb_connection *connection = op->connection; + struct gb_svc *svc = connection->private; struct gb_protocol_version_request *request; struct gb_protocol_version_response *response; if (op->request->payload_size < sizeof(*request)) { - pr_err("%d: short version request (%zu < %zu)\n", - connection->intf_cport_id, + dev_err(&svc->dev, "short version request (%zu < %zu)\n", op->request->payload_size, sizeof(*request)); return -EINVAL; @@ -287,20 +288,16 @@ static int gb_svc_version_request(struct gb_operation *op) request = op->request->payload; if (request->major > GB_SVC_VERSION_MAJOR) { - pr_err("%d: unsupported major version (%hhu > %hhu)\n", - connection->intf_cport_id, request->major, - GB_SVC_VERSION_MAJOR); + dev_warn(&svc->dev, "unsupported major version (%hhu > %hhu)\n", + request->major, GB_SVC_VERSION_MAJOR); return -ENOTSUPP; } connection->module_major = request->major; connection->module_minor = request->minor; - if (!gb_operation_response_alloc(op, sizeof(*response), GFP_KERNEL)) { - pr_err("%d: error allocating response\n", - connection->intf_cport_id); + if (!gb_operation_response_alloc(op, sizeof(*response), GFP_KERNEL)) return -ENOMEM; - } response = op->response->payload; response->major = connection->module_major; @@ -322,9 +319,9 @@ static int gb_svc_hello(struct gb_operation *op) * request, use that to create an endo. */ if (op->request->payload_size < sizeof(*hello_request)) { - pr_err("%d: Illegal size of hello request (%zu < %zu)\n", - connection->intf_cport_id, op->request->payload_size, - sizeof(*hello_request)); + dev_warn(&svc->dev, "short hello request (%zu < %zu)\n", + op->request->payload_size, + sizeof(*hello_request)); return -EINVAL; } @@ -401,15 +398,15 @@ static void svc_process_hotplug(struct work_struct *work) * Remove the interface and add it again, and let user know * about this with a print message. */ - pr_info("%d: Removed interface (%hhu) to add it again\n", - connection->intf_cport_id, intf_id); + dev_info(&svc->dev, "removing interface %hhu to add it again\n", + intf_id); svc_intf_remove(connection, intf); } intf = gb_interface_create(hd, intf_id); if (!intf) { - pr_err("%d: Failed to create interface with id %hhu\n", - connection->intf_cport_id, intf_id); + dev_err(&svc->dev, "failed to create interface %hhu\n", + intf_id); goto free_svc_hotplug; } @@ -434,15 +431,15 @@ static void svc_process_hotplug(struct work_struct *work) GB_DEVICE_ID_MODULES_START, 0, GFP_KERNEL); if (device_id < 0) { ret = device_id; - pr_err("%d: Failed to allocate device id for interface with id %hhu (%d)\n", - connection->intf_cport_id, intf_id, ret); + dev_err(&svc->dev, "failed to allocate device id for interface %hhu: %d\n", + intf_id, ret); goto destroy_interface; } ret = gb_svc_intf_device_id(svc, intf_id, device_id); if (ret) { - pr_err("%d: Device id operation failed, interface %hhu device_id %hhu (%d)\n", - connection->intf_cport_id, intf_id, device_id, ret); + dev_err(&svc->dev, "failed to set device id %hhu for interface %hhu: %d\n", + device_id, intf_id, ret); goto ida_put; } @@ -452,15 +449,15 @@ static void svc_process_hotplug(struct work_struct *work) ret = gb_svc_route_create(svc, svc->ap_intf_id, GB_DEVICE_ID_AP, intf_id, device_id); if (ret) { - pr_err("%d: Route create operation failed, interface %hhu device_id %hhu (%d)\n", - connection->intf_cport_id, intf_id, device_id, ret); + dev_err(&svc->dev, "failed to create route to interface %hhu (device id %hhu): %d\n", + intf_id, device_id, ret); goto svc_id_free; } ret = gb_interface_init(intf, device_id); if (ret) { - pr_err("%d: Failed to initialize interface, interface %hhu device_id %hhu (%d)\n", - connection->intf_cport_id, intf_id, device_id, ret); + dev_err(&svc->dev, "failed to initialize interface %hhu (device id %hhu): %d\n", + intf_id, device_id, ret); goto destroy_route; } @@ -492,13 +489,14 @@ free_svc_hotplug: */ static int gb_svc_intf_hotplug_recv(struct gb_operation *op) { + struct gb_svc *svc = op->connection->private; struct gb_message *request = op->request; struct svc_hotplug *svc_hotplug; if (request->payload_size < sizeof(svc_hotplug->data)) { - pr_err("%d: short hotplug request received (%zu < %zu)\n", - op->connection->intf_cport_id, request->payload_size, - sizeof(svc_hotplug->data)); + dev_warn(&svc->dev, "short hotplug request received (%zu < %zu)\n", + request->payload_size, + sizeof(svc_hotplug->data)); return -EINVAL; } @@ -517,6 +515,7 @@ static int gb_svc_intf_hotplug_recv(struct gb_operation *op) static int gb_svc_intf_hot_unplug_recv(struct gb_operation *op) { + struct gb_svc *svc = op->connection->private; struct gb_message *request = op->request; struct gb_svc_intf_hot_unplug_request *hot_unplug = request->payload; struct gb_host_device *hd = op->connection->hd; @@ -524,9 +523,9 @@ static int gb_svc_intf_hot_unplug_recv(struct gb_operation *op) u8 intf_id; if (request->payload_size < sizeof(*hot_unplug)) { - pr_err("connection %d: short hot unplug request received (%zu < %zu)\n", - op->connection->intf_cport_id, request->payload_size, - sizeof(*hot_unplug)); + dev_warn(&svc->dev, "short hot unplug request received (%zu < %zu)\n", + request->payload_size, + sizeof(*hot_unplug)); return -EINVAL; } @@ -534,8 +533,8 @@ static int gb_svc_intf_hot_unplug_recv(struct gb_operation *op) intf = gb_interface_find(hd, intf_id); if (!intf) { - pr_err("connection %d: Couldn't find interface for id %hhu\n", - op->connection->intf_cport_id, intf_id); + dev_warn(&svc->dev, "could not find hot-unplug interface %hhu\n", + intf_id); return -EINVAL; } @@ -546,14 +545,14 @@ static int gb_svc_intf_hot_unplug_recv(struct gb_operation *op) static int gb_svc_intf_reset_recv(struct gb_operation *op) { + struct gb_svc *svc = op->connection->private; struct gb_message *request = op->request; struct gb_svc_intf_reset_request *reset; u8 intf_id; if (request->payload_size < sizeof(*reset)) { - pr_err("connection %d: short reset request received (%zu < %zu)\n", - op->connection->intf_cport_id, request->payload_size, - sizeof(*reset)); + dev_warn(&svc->dev, "short reset request received (%zu < %zu)\n", + request->payload_size, sizeof(*reset)); return -EINVAL; } reset = request->payload; @@ -597,8 +596,8 @@ static int gb_svc_request_recv(u8 type, struct gb_operation *op) } if (ret) { - pr_warn("connection %d: unexpected SVC request 0x%02x received (state %u)\n", - connection->intf_cport_id, type, svc->state); + dev_warn(&svc->dev, "unexpected request 0x%02x received (state %u)\n", + type, svc->state); return ret; } @@ -620,8 +619,7 @@ static int gb_svc_request_recv(u8 type, struct gb_operation *op) case GB_SVC_TYPE_INTF_RESET: return gb_svc_intf_reset_recv(op); default: - pr_err("connection %d: unsupported request: %hhu\n", - connection->intf_cport_id, type); + dev_warn(&svc->dev, "unsupported request 0x%02x\n", type); return -EINVAL; } }