Commit 684156a9 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

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: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 5ef32384
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* Released under the GPLv2 only. * Released under the GPLv2 only.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include "greybus.h" #include "greybus.h"
...@@ -87,15 +86,15 @@ int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, ...@@ -87,15 +86,15 @@ int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
&request, sizeof(request), &request, sizeof(request),
&response, sizeof(response)); &response, sizeof(response));
if (ret) { if (ret) {
pr_err("failed to get DME attribute (%hhu %hx %hu) %d\n", dev_err(&svc->dev, "failed to get DME attribute (%hhu %hx %hu): %d\n",
intf_id, attr, selector, ret); intf_id, attr, selector, ret);
return ret; return ret;
} }
result = le16_to_cpu(response.result_code); result = le16_to_cpu(response.result_code);
if (result) { if (result) {
pr_err("Unipro error %hu while getting DME attribute (%hhu %hx %hu)\n", dev_err(&svc->dev, "UniPro error while getting DME attribute (%hhu %hx %hu): %hu\n",
result, intf_id, attr, selector); intf_id, attr, selector, result);
return -EINVAL; return -EINVAL;
} }
...@@ -123,15 +122,15 @@ int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, ...@@ -123,15 +122,15 @@ int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
&request, sizeof(request), &request, sizeof(request),
&response, sizeof(response)); &response, sizeof(response));
if (ret) { if (ret) {
pr_err("failed to set DME attribute (%hhu %hx %hu %u) %d\n", dev_err(&svc->dev, "failed to set DME attribute (%hhu %hx %hu %u): %d\n",
intf_id, attr, selector, value, ret); intf_id, attr, selector, value, ret);
return ret; return ret;
} }
result = le16_to_cpu(response.result_code); result = le16_to_cpu(response.result_code);
if (result) { if (result) {
pr_err("Unipro error %hu while setting DME attribute (%hhu %hx %hu %u)\n", dev_err(&svc->dev, "UniPro error while setting DME attribute (%hhu %hx %hu %u): %hu\n",
result, intf_id, attr, selector, value); intf_id, attr, selector, value, result);
return -EINVAL; return -EINVAL;
} }
...@@ -233,9 +232,10 @@ void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id, ...@@ -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, ret = gb_operation_sync(connection, GB_SVC_TYPE_CONN_DESTROY,
&request, sizeof(request), NULL, 0); &request, sizeof(request), NULL, 0);
if (ret) if (ret) {
pr_err("failed to destroy connection (%hhu:%hu %hhu:%hu) %d\n", dev_err(&svc->dev, "failed to destroy connection (%hhu:%hu %hhu:%hu): %d\n",
intf1_id, cport1_id, intf2_id, cport2_id, ret); intf1_id, cport1_id, intf2_id, cport2_id, ret);
}
} }
EXPORT_SYMBOL_GPL(gb_svc_connection_destroy); 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) ...@@ -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, ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_ROUTE_DESTROY,
&request, sizeof(request), NULL, 0); &request, sizeof(request), NULL, 0);
if (ret) if (ret) {
pr_err("failed to destroy route (%hhu %hhu) %d\n", dev_err(&svc->dev, "failed to destroy route (%hhu %hhu): %d\n",
intf1_id, intf2_id, ret); intf1_id, intf2_id, ret);
}
} }
static int gb_svc_version_request(struct gb_operation *op) static int gb_svc_version_request(struct gb_operation *op)
{ {
struct gb_connection *connection = op->connection; struct gb_connection *connection = op->connection;
struct gb_svc *svc = connection->private;
struct gb_protocol_version_request *request; struct gb_protocol_version_request *request;
struct gb_protocol_version_response *response; struct gb_protocol_version_response *response;
if (op->request->payload_size < sizeof(*request)) { if (op->request->payload_size < sizeof(*request)) {
pr_err("%d: short version request (%zu < %zu)\n", dev_err(&svc->dev, "short version request (%zu < %zu)\n",
connection->intf_cport_id,
op->request->payload_size, op->request->payload_size,
sizeof(*request)); sizeof(*request));
return -EINVAL; return -EINVAL;
...@@ -287,20 +288,16 @@ static int gb_svc_version_request(struct gb_operation *op) ...@@ -287,20 +288,16 @@ static int gb_svc_version_request(struct gb_operation *op)
request = op->request->payload; request = op->request->payload;
if (request->major > GB_SVC_VERSION_MAJOR) { if (request->major > GB_SVC_VERSION_MAJOR) {
pr_err("%d: unsupported major version (%hhu > %hhu)\n", dev_warn(&svc->dev, "unsupported major version (%hhu > %hhu)\n",
connection->intf_cport_id, request->major, request->major, GB_SVC_VERSION_MAJOR);
GB_SVC_VERSION_MAJOR);
return -ENOTSUPP; return -ENOTSUPP;
} }
connection->module_major = request->major; connection->module_major = request->major;
connection->module_minor = request->minor; connection->module_minor = request->minor;
if (!gb_operation_response_alloc(op, sizeof(*response), GFP_KERNEL)) { if (!gb_operation_response_alloc(op, sizeof(*response), GFP_KERNEL))
pr_err("%d: error allocating response\n",
connection->intf_cport_id);
return -ENOMEM; return -ENOMEM;
}
response = op->response->payload; response = op->response->payload;
response->major = connection->module_major; response->major = connection->module_major;
...@@ -322,9 +319,9 @@ static int gb_svc_hello(struct gb_operation *op) ...@@ -322,9 +319,9 @@ static int gb_svc_hello(struct gb_operation *op)
* request, use that to create an endo. * request, use that to create an endo.
*/ */
if (op->request->payload_size < sizeof(*hello_request)) { if (op->request->payload_size < sizeof(*hello_request)) {
pr_err("%d: Illegal size of hello request (%zu < %zu)\n", dev_warn(&svc->dev, "short hello request (%zu < %zu)\n",
connection->intf_cport_id, op->request->payload_size, op->request->payload_size,
sizeof(*hello_request)); sizeof(*hello_request));
return -EINVAL; return -EINVAL;
} }
...@@ -401,15 +398,15 @@ static void svc_process_hotplug(struct work_struct *work) ...@@ -401,15 +398,15 @@ static void svc_process_hotplug(struct work_struct *work)
* Remove the interface and add it again, and let user know * Remove the interface and add it again, and let user know
* about this with a print message. * about this with a print message.
*/ */
pr_info("%d: Removed interface (%hhu) to add it again\n", dev_info(&svc->dev, "removing interface %hhu to add it again\n",
connection->intf_cport_id, intf_id); intf_id);
svc_intf_remove(connection, intf); svc_intf_remove(connection, intf);
} }
intf = gb_interface_create(hd, intf_id); intf = gb_interface_create(hd, intf_id);
if (!intf) { if (!intf) {
pr_err("%d: Failed to create interface with id %hhu\n", dev_err(&svc->dev, "failed to create interface %hhu\n",
connection->intf_cport_id, intf_id); intf_id);
goto free_svc_hotplug; goto free_svc_hotplug;
} }
...@@ -434,15 +431,15 @@ static void svc_process_hotplug(struct work_struct *work) ...@@ -434,15 +431,15 @@ static void svc_process_hotplug(struct work_struct *work)
GB_DEVICE_ID_MODULES_START, 0, GFP_KERNEL); GB_DEVICE_ID_MODULES_START, 0, GFP_KERNEL);
if (device_id < 0) { if (device_id < 0) {
ret = device_id; ret = device_id;
pr_err("%d: Failed to allocate device id for interface with id %hhu (%d)\n", dev_err(&svc->dev, "failed to allocate device id for interface %hhu: %d\n",
connection->intf_cport_id, intf_id, ret); intf_id, ret);
goto destroy_interface; goto destroy_interface;
} }
ret = gb_svc_intf_device_id(svc, intf_id, device_id); ret = gb_svc_intf_device_id(svc, intf_id, device_id);
if (ret) { if (ret) {
pr_err("%d: Device id operation failed, interface %hhu device_id %hhu (%d)\n", dev_err(&svc->dev, "failed to set device id %hhu for interface %hhu: %d\n",
connection->intf_cport_id, intf_id, device_id, ret); device_id, intf_id, ret);
goto ida_put; goto ida_put;
} }
...@@ -452,15 +449,15 @@ static void svc_process_hotplug(struct work_struct *work) ...@@ -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, ret = gb_svc_route_create(svc, svc->ap_intf_id, GB_DEVICE_ID_AP,
intf_id, device_id); intf_id, device_id);
if (ret) { if (ret) {
pr_err("%d: Route create operation failed, interface %hhu device_id %hhu (%d)\n", dev_err(&svc->dev, "failed to create route to interface %hhu (device id %hhu): %d\n",
connection->intf_cport_id, intf_id, device_id, ret); intf_id, device_id, ret);
goto svc_id_free; goto svc_id_free;
} }
ret = gb_interface_init(intf, device_id); ret = gb_interface_init(intf, device_id);
if (ret) { if (ret) {
pr_err("%d: Failed to initialize interface, interface %hhu device_id %hhu (%d)\n", dev_err(&svc->dev, "failed to initialize interface %hhu (device id %hhu): %d\n",
connection->intf_cport_id, intf_id, device_id, ret); intf_id, device_id, ret);
goto destroy_route; goto destroy_route;
} }
...@@ -492,13 +489,14 @@ static void svc_process_hotplug(struct work_struct *work) ...@@ -492,13 +489,14 @@ static void svc_process_hotplug(struct work_struct *work)
*/ */
static int gb_svc_intf_hotplug_recv(struct gb_operation *op) 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 gb_message *request = op->request;
struct svc_hotplug *svc_hotplug; struct svc_hotplug *svc_hotplug;
if (request->payload_size < sizeof(svc_hotplug->data)) { if (request->payload_size < sizeof(svc_hotplug->data)) {
pr_err("%d: short hotplug request received (%zu < %zu)\n", dev_warn(&svc->dev, "short hotplug request received (%zu < %zu)\n",
op->connection->intf_cport_id, request->payload_size, request->payload_size,
sizeof(svc_hotplug->data)); sizeof(svc_hotplug->data));
return -EINVAL; return -EINVAL;
} }
...@@ -517,6 +515,7 @@ static int gb_svc_intf_hotplug_recv(struct gb_operation *op) ...@@ -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) 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_message *request = op->request;
struct gb_svc_intf_hot_unplug_request *hot_unplug = request->payload; struct gb_svc_intf_hot_unplug_request *hot_unplug = request->payload;
struct gb_host_device *hd = op->connection->hd; struct gb_host_device *hd = op->connection->hd;
...@@ -524,9 +523,9 @@ static int gb_svc_intf_hot_unplug_recv(struct gb_operation *op) ...@@ -524,9 +523,9 @@ static int gb_svc_intf_hot_unplug_recv(struct gb_operation *op)
u8 intf_id; u8 intf_id;
if (request->payload_size < sizeof(*hot_unplug)) { if (request->payload_size < sizeof(*hot_unplug)) {
pr_err("connection %d: short hot unplug request received (%zu < %zu)\n", dev_warn(&svc->dev, "short hot unplug request received (%zu < %zu)\n",
op->connection->intf_cport_id, request->payload_size, request->payload_size,
sizeof(*hot_unplug)); sizeof(*hot_unplug));
return -EINVAL; return -EINVAL;
} }
...@@ -534,8 +533,8 @@ static int gb_svc_intf_hot_unplug_recv(struct gb_operation *op) ...@@ -534,8 +533,8 @@ static int gb_svc_intf_hot_unplug_recv(struct gb_operation *op)
intf = gb_interface_find(hd, intf_id); intf = gb_interface_find(hd, intf_id);
if (!intf) { if (!intf) {
pr_err("connection %d: Couldn't find interface for id %hhu\n", dev_warn(&svc->dev, "could not find hot-unplug interface %hhu\n",
op->connection->intf_cport_id, intf_id); intf_id);
return -EINVAL; return -EINVAL;
} }
...@@ -546,14 +545,14 @@ static int gb_svc_intf_hot_unplug_recv(struct gb_operation *op) ...@@ -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) 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_message *request = op->request;
struct gb_svc_intf_reset_request *reset; struct gb_svc_intf_reset_request *reset;
u8 intf_id; u8 intf_id;
if (request->payload_size < sizeof(*reset)) { if (request->payload_size < sizeof(*reset)) {
pr_err("connection %d: short reset request received (%zu < %zu)\n", dev_warn(&svc->dev, "short reset request received (%zu < %zu)\n",
op->connection->intf_cport_id, request->payload_size, request->payload_size, sizeof(*reset));
sizeof(*reset));
return -EINVAL; return -EINVAL;
} }
reset = request->payload; reset = request->payload;
...@@ -597,8 +596,8 @@ static int gb_svc_request_recv(u8 type, struct gb_operation *op) ...@@ -597,8 +596,8 @@ static int gb_svc_request_recv(u8 type, struct gb_operation *op)
} }
if (ret) { if (ret) {
pr_warn("connection %d: unexpected SVC request 0x%02x received (state %u)\n", dev_warn(&svc->dev, "unexpected request 0x%02x received (state %u)\n",
connection->intf_cport_id, type, svc->state); type, svc->state);
return ret; return ret;
} }
...@@ -620,8 +619,7 @@ static int gb_svc_request_recv(u8 type, struct gb_operation *op) ...@@ -620,8 +619,7 @@ static int gb_svc_request_recv(u8 type, struct gb_operation *op)
case GB_SVC_TYPE_INTF_RESET: case GB_SVC_TYPE_INTF_RESET:
return gb_svc_intf_reset_recv(op); return gb_svc_intf_reset_recv(op);
default: default:
pr_err("connection %d: unsupported request: %hhu\n", dev_warn(&svc->dev, "unsupported request 0x%02x\n", type);
connection->intf_cport_id, type);
return -EINVAL; return -EINVAL;
} }
} }
......
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