Commit 2f3db927 authored by Viresh Kumar's avatar Viresh Kumar Committed by Greg Kroah-Hartman

greybus: don't use %h and %hh for printing short and char variables

Because the width of our fields is already known, we can use %0Nx (for
hex) to print N bytes and %u (for unsigned decimal), instead of using %h
and %hh, which isn't that readable.

This patch makes following changes:
- s/%hx/%04x
- s/%04hx/%04x
- s/%hhx/%02x
- s/%02hhx/%02x
- s/%hhu/%u
- s/%hu/%u
- s/%x/%02x for u8 value (only at a single place)
Suggested-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 4aac6c5a
...@@ -128,7 +128,7 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id, ...@@ -128,7 +128,7 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
* the interface bundle list locked here. * the interface bundle list locked here.
*/ */
if (gb_bundle_find(intf, bundle_id)) { if (gb_bundle_find(intf, bundle_id)) {
pr_err("duplicate bundle id 0x%02hhx\n", bundle_id); pr_err("duplicate bundle id 0x%02x\n", bundle_id);
return NULL; return NULL;
} }
...@@ -152,7 +152,7 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id, ...@@ -152,7 +152,7 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
retval = device_add(&bundle->dev); retval = device_add(&bundle->dev);
if (retval) { if (retval) {
pr_err("failed to add bundle device for id 0x%02hhx\n", pr_err("failed to add bundle device for id 0x%02x\n",
bundle_id); bundle_id);
put_device(&bundle->dev); put_device(&bundle->dev);
return NULL; return NULL;
......
...@@ -89,7 +89,7 @@ static void gb_connection_init_name(struct gb_connection *connection) ...@@ -89,7 +89,7 @@ static void gb_connection_init_name(struct gb_connection *connection)
} }
snprintf(connection->name, sizeof(connection->name), snprintf(connection->name, sizeof(connection->name),
"%hu/%hhu:%hu", hd_cport_id, intf_id, cport_id); "%u/%u:%u", hd_cport_id, intf_id, cport_id);
} }
/* /*
...@@ -129,7 +129,7 @@ gb_connection_create(struct gb_host_device *hd, int hd_cport_id, ...@@ -129,7 +129,7 @@ gb_connection_create(struct gb_host_device *hd, int hd_cport_id,
* about holding the connection lock. * about holding the connection lock.
*/ */
if (bundle && gb_connection_intf_find(bundle->intf, cport_id)) { if (bundle && gb_connection_intf_find(bundle->intf, cport_id)) {
dev_err(&bundle->dev, "cport 0x%04hx already connected\n", dev_err(&bundle->dev, "cport 0x%04x already connected\n",
cport_id); cport_id);
return NULL; return NULL;
} }
...@@ -534,7 +534,7 @@ int gb_connection_bind_protocol(struct gb_connection *connection) ...@@ -534,7 +534,7 @@ int gb_connection_bind_protocol(struct gb_connection *connection)
connection->minor); connection->minor);
if (!protocol) { if (!protocol) {
dev_warn(&connection->hd->dev, dev_warn(&connection->hd->dev,
"protocol 0x%02hhx version %hhu.%hhu not found\n", "protocol 0x%02x version %u.%u not found\n",
connection->protocol_id, connection->protocol_id,
connection->major, connection->minor); connection->major, connection->minor);
return 0; return 0;
......
...@@ -442,7 +442,7 @@ static int cport_reset(struct gb_host_device *hd, u16 cport_id) ...@@ -442,7 +442,7 @@ static int cport_reset(struct gb_host_device *hd, u16 cport_id)
USB_RECIP_INTERFACE, cport_id, 0, USB_RECIP_INTERFACE, cport_id, 0,
NULL, 0, ES2_TIMEOUT); NULL, 0, ES2_TIMEOUT);
if (retval < 0) { if (retval < 0) {
dev_err(&udev->dev, "failed to reset cport %hu: %d\n", cport_id, dev_err(&udev->dev, "failed to reset cport %u: %d\n", cport_id,
retval); retval);
return retval; return retval;
} }
...@@ -890,7 +890,7 @@ static int ap_probe(struct usb_interface *interface, ...@@ -890,7 +890,7 @@ static int ap_probe(struct usb_interface *interface,
endpoint->bEndpointAddress; endpoint->bEndpointAddress;
} else { } else {
dev_err(&udev->dev, dev_err(&udev->dev,
"Unknown endpoint type found, address %x\n", "Unknown endpoint type found, address %02x\n",
endpoint->bEndpointAddress); endpoint->bEndpointAddress);
} }
} }
......
...@@ -210,7 +210,7 @@ static int gb_firmware_request_recv(u8 type, struct gb_operation *op) ...@@ -210,7 +210,7 @@ static int gb_firmware_request_recv(u8 type, struct gb_operation *op)
return gb_firmware_ready_to_boot(op); return gb_firmware_ready_to_boot(op);
default: default:
dev_err(&op->connection->bundle->dev, dev_err(&op->connection->bundle->dev,
"unsupported request: %hhu\n", type); "unsupported request: %u\n", type);
return -EINVAL; return -EINVAL;
} }
} }
......
...@@ -411,7 +411,7 @@ static int gb_hid_init(struct gb_hid *ghid) ...@@ -411,7 +411,7 @@ static int gb_hid_init(struct gb_hid *ghid)
// hid->bus = BUS_GREYBUS; /* Need a bustype for GREYBUS in <linux/input.h> */ // hid->bus = BUS_GREYBUS; /* Need a bustype for GREYBUS in <linux/input.h> */
/* Set HID device's name */ /* Set HID device's name */
snprintf(hid->name, sizeof(hid->name), "%s %04hX:%04hX", snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X",
dev_name(&ghid->connection->bundle->dev), dev_name(&ghid->connection->bundle->dev),
hid->vendor, hid->product); hid->vendor, hid->product);
......
...@@ -487,7 +487,7 @@ static int gb_loopback_request_recv(u8 type, struct gb_operation *operation) ...@@ -487,7 +487,7 @@ static int gb_loopback_request_recv(u8 type, struct gb_operation *operation)
return 0; return 0;
default: default:
dev_err(dev, "unsupported request: %hhu\n", type); dev_err(dev, "unsupported request: %u\n", type);
return -EINVAL; return -EINVAL;
} }
} }
......
...@@ -140,7 +140,7 @@ static int identify_descriptor(struct gb_interface *intf, ...@@ -140,7 +140,7 @@ static int identify_descriptor(struct gb_interface *intf,
break; break;
case GREYBUS_TYPE_INVALID: case GREYBUS_TYPE_INVALID:
default: default:
pr_err("invalid descriptor type (%hhu)\n", desc_header->type); pr_err("invalid descriptor type (%u)\n", desc_header->type);
return -EINVAL; return -EINVAL;
} }
...@@ -440,14 +440,14 @@ bool gb_manifest_parse(struct gb_interface *intf, void *data, size_t size) ...@@ -440,14 +440,14 @@ bool gb_manifest_parse(struct gb_interface *intf, void *data, size_t size)
header = &manifest->header; header = &manifest->header;
manifest_size = le16_to_cpu(header->size); manifest_size = le16_to_cpu(header->size);
if (manifest_size != size) { if (manifest_size != size) {
pr_err("manifest size mismatch (%zu != %hu)\n", pr_err("manifest size mismatch (%zu != %u)\n",
size, manifest_size); size, manifest_size);
return false; return false;
} }
/* Validate major/minor number */ /* Validate major/minor number */
if (header->version_major > GREYBUS_VERSION_MAJOR) { if (header->version_major > GREYBUS_VERSION_MAJOR) {
pr_err("manifest version too new (%hhu.%hhu > %hhu.%hhu)\n", pr_err("manifest version too new (%u.%u > %u.%u)\n",
header->version_major, header->version_minor, header->version_major, header->version_minor,
GREYBUS_VERSION_MAJOR, GREYBUS_VERSION_MINOR); GREYBUS_VERSION_MAJOR, GREYBUS_VERSION_MINOR);
return false; return false;
......
...@@ -229,7 +229,7 @@ static void gb_operation_request_handle(struct gb_operation *operation) ...@@ -229,7 +229,7 @@ static void gb_operation_request_handle(struct gb_operation *operation)
status = protocol->request_recv(operation->type, operation); status = protocol->request_recv(operation->type, operation);
} else { } else {
dev_err(&connection->hd->dev, dev_err(&connection->hd->dev,
"%s: unexpected incoming request of type 0x%02hhx\n", "%s: unexpected incoming request of type 0x%02x\n",
connection->name, operation->type); connection->name, operation->type);
status = -EPROTONOSUPPORT; status = -EPROTONOSUPPORT;
...@@ -238,7 +238,7 @@ static void gb_operation_request_handle(struct gb_operation *operation) ...@@ -238,7 +238,7 @@ static void gb_operation_request_handle(struct gb_operation *operation)
ret = gb_operation_response_send(operation, status); ret = gb_operation_response_send(operation, status);
if (ret) { if (ret) {
dev_err(&connection->hd->dev, dev_err(&connection->hd->dev,
"%s: failed to send response %d for type 0x%02hhx: %d\n", "%s: failed to send response %d for type 0x%02x: %d\n",
connection->name, status, operation->type, ret); connection->name, status, operation->type, ret);
return; return;
} }
...@@ -797,7 +797,7 @@ void greybus_message_sent(struct gb_host_device *hd, ...@@ -797,7 +797,7 @@ void greybus_message_sent(struct gb_host_device *hd,
if (message == operation->response) { if (message == operation->response) {
if (status) { if (status) {
dev_err(&connection->hd->dev, dev_err(&connection->hd->dev,
"%s: error sending response 0x%02hhx: %d\n", "%s: error sending response 0x%02x: %d\n",
connection->name, operation->type, status); connection->name, operation->type, status);
} }
gb_operation_put_active(operation); gb_operation_put_active(operation);
...@@ -868,7 +868,7 @@ static void gb_connection_recv_response(struct gb_connection *connection, ...@@ -868,7 +868,7 @@ static void gb_connection_recv_response(struct gb_connection *connection,
operation = gb_operation_find_outgoing(connection, operation_id); operation = gb_operation_find_outgoing(connection, operation_id);
if (!operation) { if (!operation) {
dev_err(&connection->hd->dev, dev_err(&connection->hd->dev,
"%s: unexpected response id 0x%04hx received\n", "%s: unexpected response id 0x%04x received\n",
connection->name, operation_id); connection->name, operation_id);
return; return;
} }
...@@ -877,7 +877,7 @@ static void gb_connection_recv_response(struct gb_connection *connection, ...@@ -877,7 +877,7 @@ static void gb_connection_recv_response(struct gb_connection *connection,
message_size = sizeof(*message->header) + message->payload_size; message_size = sizeof(*message->header) + message->payload_size;
if (!errno && size != message_size) { if (!errno && size != message_size) {
dev_err(&connection->hd->dev, dev_err(&connection->hd->dev,
"%s: malformed response 0x%02hhx received (%zu != %zu)\n", "%s: malformed response 0x%02x received (%zu != %zu)\n",
connection->name, message->header->type, size, connection->name, message->header->type, size,
message_size); message_size);
errno = -EMSGSIZE; errno = -EMSGSIZE;
...@@ -926,7 +926,7 @@ void gb_connection_recv(struct gb_connection *connection, ...@@ -926,7 +926,7 @@ void gb_connection_recv(struct gb_connection *connection,
msg_size = le16_to_cpu(header.size); msg_size = le16_to_cpu(header.size);
if (size < msg_size) { if (size < msg_size) {
dev_err(dev, dev_err(dev,
"%s: incomplete message 0x%04hx of type 0x%02hhx received (%zu < %zu)\n", "%s: incomplete message 0x%04x of type 0x%02x received (%zu < %zu)\n",
connection->name, le16_to_cpu(header.operation_id), connection->name, le16_to_cpu(header.operation_id),
header.type, size, msg_size); header.type, size, msg_size);
return; /* XXX Should still complete operation */ return; /* XXX Should still complete operation */
...@@ -1036,7 +1036,7 @@ int gb_operation_sync_timeout(struct gb_connection *connection, int type, ...@@ -1036,7 +1036,7 @@ int gb_operation_sync_timeout(struct gb_connection *connection, int type,
ret = gb_operation_request_send_sync_timeout(operation, timeout); ret = gb_operation_request_send_sync_timeout(operation, timeout);
if (ret) { if (ret) {
dev_err(&connection->hd->dev, dev_err(&connection->hd->dev,
"%s: synchronous operation of type 0x%02hhx failed: %d\n", "%s: synchronous operation of type 0x%02x failed: %d\n",
connection->name, type, ret); connection->name, type, ret);
} else { } else {
if (response_size) { if (response_size) {
......
...@@ -166,7 +166,7 @@ int gb_protocol_get_version(struct gb_connection *connection) ...@@ -166,7 +166,7 @@ int gb_protocol_get_version(struct gb_connection *connection)
if (response.major > connection->protocol->major) { if (response.major > connection->protocol->major) {
dev_err(&connection->hd->dev, dev_err(&connection->hd->dev,
"%s: unsupported major version (%hhu > %hhu)\n", "%s: unsupported major version (%u > %u)\n",
connection->name, response.major, connection->name, response.major,
connection->protocol->major); connection->protocol->major);
return -ENOTSUPP; return -ENOTSUPP;
...@@ -176,7 +176,7 @@ int gb_protocol_get_version(struct gb_connection *connection) ...@@ -176,7 +176,7 @@ int gb_protocol_get_version(struct gb_connection *connection)
connection->module_minor = response.minor; connection->module_minor = response.minor;
dev_dbg(&connection->hd->dev, dev_dbg(&connection->hd->dev,
"%s: %s (0x%02hhx) v%hhu.%hhu\n", connection->name, "%s: %s (0x%02x) v%u.%u\n", connection->name,
protocol->name, protocol->id, response.major, response.minor); protocol->name, protocol->id, response.major, response.minor);
return 0; return 0;
......
...@@ -85,14 +85,14 @@ int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, ...@@ -85,14 +85,14 @@ 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) {
dev_err(&svc->dev, "failed to get DME attribute (%hhu %hx %hu): %d\n", dev_err(&svc->dev, "failed to get DME attribute (%u %04x %u): %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) {
dev_err(&svc->dev, "UniPro error while getting DME attribute (%hhu %hx %hu): %hu\n", dev_err(&svc->dev, "UniPro error while getting DME attribute (%u %04x %u): %u\n",
intf_id, attr, selector, result); intf_id, attr, selector, result);
return -EIO; return -EIO;
} }
...@@ -121,14 +121,14 @@ int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, ...@@ -121,14 +121,14 @@ 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) {
dev_err(&svc->dev, "failed to set DME attribute (%hhu %hx %hu %u): %d\n", dev_err(&svc->dev, "failed to set DME attribute (%u %04x %u %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) {
dev_err(&svc->dev, "UniPro error while setting DME attribute (%hhu %hx %hu %u): %hu\n", dev_err(&svc->dev, "UniPro error while setting DME attribute (%u %04x %u %u): %u\n",
intf_id, attr, selector, value, result); intf_id, attr, selector, value, result);
return -EIO; return -EIO;
} }
...@@ -232,7 +232,7 @@ void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id, ...@@ -232,7 +232,7 @@ 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) {
dev_err(&svc->dev, "failed to destroy connection (%hhu:%hu %hhu:%hu): %d\n", dev_err(&svc->dev, "failed to destroy connection (%u:%u %u:%u): %d\n",
intf1_id, cport1_id, intf2_id, cport2_id, ret); intf1_id, cport1_id, intf2_id, cport2_id, ret);
} }
} }
...@@ -265,7 +265,7 @@ static void gb_svc_route_destroy(struct gb_svc *svc, u8 intf1_id, u8 intf2_id) ...@@ -265,7 +265,7 @@ 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) {
dev_err(&svc->dev, "failed to destroy route (%hhu %hhu): %d\n", dev_err(&svc->dev, "failed to destroy route (%u %u): %d\n",
intf1_id, intf2_id, ret); intf1_id, intf2_id, ret);
} }
} }
...@@ -287,7 +287,7 @@ static int gb_svc_version_request(struct gb_operation *op) ...@@ -287,7 +287,7 @@ 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) {
dev_warn(&svc->dev, "unsupported major version (%hhu > %hhu)\n", dev_warn(&svc->dev, "unsupported major version (%u > %u)\n",
request->major, GB_SVC_VERSION_MAJOR); request->major, GB_SVC_VERSION_MAJOR);
return -ENOTSUPP; return -ENOTSUPP;
} }
...@@ -380,14 +380,14 @@ static void gb_svc_process_intf_hotplug(struct gb_operation *operation) ...@@ -380,14 +380,14 @@ static void gb_svc_process_intf_hotplug(struct gb_operation *operation)
* 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.
*/ */
dev_info(&svc->dev, "removing interface %hhu to add it again\n", dev_info(&svc->dev, "removing interface %u to add it again\n",
intf_id); intf_id);
gb_svc_intf_remove(svc, intf); gb_svc_intf_remove(svc, intf);
} }
intf = gb_interface_create(hd, intf_id); intf = gb_interface_create(hd, intf_id);
if (!intf) { if (!intf) {
dev_err(&svc->dev, "failed to create interface %hhu\n", dev_err(&svc->dev, "failed to create interface %u\n",
intf_id); intf_id);
return; return;
} }
...@@ -413,14 +413,14 @@ static void gb_svc_process_intf_hotplug(struct gb_operation *operation) ...@@ -413,14 +413,14 @@ static void gb_svc_process_intf_hotplug(struct gb_operation *operation)
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;
dev_err(&svc->dev, "failed to allocate device id for interface %hhu: %d\n", dev_err(&svc->dev, "failed to allocate device id for interface %u: %d\n",
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) {
dev_err(&svc->dev, "failed to set device id %hhu for interface %hhu: %d\n", dev_err(&svc->dev, "failed to set device id %u for interface %u: %d\n",
device_id, intf_id, ret); device_id, intf_id, ret);
goto ida_put; goto ida_put;
} }
...@@ -431,14 +431,14 @@ static void gb_svc_process_intf_hotplug(struct gb_operation *operation) ...@@ -431,14 +431,14 @@ static void gb_svc_process_intf_hotplug(struct gb_operation *operation)
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) {
dev_err(&svc->dev, "failed to create route to interface %hhu (device id %hhu): %d\n", dev_err(&svc->dev, "failed to create route to interface %u (device id %u): %d\n",
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) {
dev_err(&svc->dev, "failed to initialize interface %hhu (device id %hhu): %d\n", dev_err(&svc->dev, "failed to initialize interface %u (device id %u): %d\n",
intf_id, device_id, ret); intf_id, device_id, ret);
goto destroy_route; goto destroy_route;
} }
...@@ -474,7 +474,7 @@ static void gb_svc_process_intf_hot_unplug(struct gb_operation *operation) ...@@ -474,7 +474,7 @@ static void gb_svc_process_intf_hot_unplug(struct gb_operation *operation)
intf = gb_interface_find(hd, intf_id); intf = gb_interface_find(hd, intf_id);
if (!intf) { if (!intf) {
dev_warn(&svc->dev, "could not find hot-unplug interface %hhu\n", dev_warn(&svc->dev, "could not find hot-unplug interface %u\n",
intf_id); intf_id);
return; return;
} }
......
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