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: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Viresh Kumar 2015-12-04 21:30:09 +05:30 committed by Greg Kroah-Hartman
parent 4aac6c5a14
commit 2f3db927cd
10 changed files with 36 additions and 36 deletions

View File

@ -128,7 +128,7 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
* the interface bundle list locked here.
*/
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;
}
@ -152,7 +152,7 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
retval = device_add(&bundle->dev);
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);
put_device(&bundle->dev);
return NULL;

View File

@ -89,7 +89,7 @@ static void gb_connection_init_name(struct gb_connection *connection)
}
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,
* about holding the connection lock.
*/
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);
return NULL;
}
@ -534,7 +534,7 @@ int gb_connection_bind_protocol(struct gb_connection *connection)
connection->minor);
if (!protocol) {
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->major, connection->minor);
return 0;

View File

@ -442,7 +442,7 @@ static int cport_reset(struct gb_host_device *hd, u16 cport_id)
USB_RECIP_INTERFACE, cport_id, 0,
NULL, 0, ES2_TIMEOUT);
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);
return retval;
}
@ -890,7 +890,7 @@ static int ap_probe(struct usb_interface *interface,
endpoint->bEndpointAddress;
} else {
dev_err(&udev->dev,
"Unknown endpoint type found, address %x\n",
"Unknown endpoint type found, address %02x\n",
endpoint->bEndpointAddress);
}
}

View File

@ -210,7 +210,7 @@ static int gb_firmware_request_recv(u8 type, struct gb_operation *op)
return gb_firmware_ready_to_boot(op);
default:
dev_err(&op->connection->bundle->dev,
"unsupported request: %hhu\n", type);
"unsupported request: %u\n", type);
return -EINVAL;
}
}

View File

@ -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> */
/* 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),
hid->vendor, hid->product);

View File

@ -487,7 +487,7 @@ static int gb_loopback_request_recv(u8 type, struct gb_operation *operation)
return 0;
default:
dev_err(dev, "unsupported request: %hhu\n", type);
dev_err(dev, "unsupported request: %u\n", type);
return -EINVAL;
}
}

View File

@ -140,7 +140,7 @@ static int identify_descriptor(struct gb_interface *intf,
break;
case GREYBUS_TYPE_INVALID:
default:
pr_err("invalid descriptor type (%hhu)\n", desc_header->type);
pr_err("invalid descriptor type (%u)\n", desc_header->type);
return -EINVAL;
}
@ -440,14 +440,14 @@ bool gb_manifest_parse(struct gb_interface *intf, void *data, size_t size)
header = &manifest->header;
manifest_size = le16_to_cpu(header->size);
if (manifest_size != size) {
pr_err("manifest size mismatch (%zu != %hu)\n",
pr_err("manifest size mismatch (%zu != %u)\n",
size, manifest_size);
return false;
}
/* Validate major/minor number */
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,
GREYBUS_VERSION_MAJOR, GREYBUS_VERSION_MINOR);
return false;

View File

@ -229,7 +229,7 @@ static void gb_operation_request_handle(struct gb_operation *operation)
status = protocol->request_recv(operation->type, operation);
} else {
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);
status = -EPROTONOSUPPORT;
@ -238,7 +238,7 @@ static void gb_operation_request_handle(struct gb_operation *operation)
ret = gb_operation_response_send(operation, status);
if (ret) {
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);
return;
}
@ -797,7 +797,7 @@ void greybus_message_sent(struct gb_host_device *hd,
if (message == operation->response) {
if (status) {
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);
}
gb_operation_put_active(operation);
@ -868,7 +868,7 @@ static void gb_connection_recv_response(struct gb_connection *connection,
operation = gb_operation_find_outgoing(connection, operation_id);
if (!operation) {
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);
return;
}
@ -877,7 +877,7 @@ static void gb_connection_recv_response(struct gb_connection *connection,
message_size = sizeof(*message->header) + message->payload_size;
if (!errno && size != message_size) {
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,
message_size);
errno = -EMSGSIZE;
@ -926,7 +926,7 @@ void gb_connection_recv(struct gb_connection *connection,
msg_size = le16_to_cpu(header.size);
if (size < msg_size) {
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),
header.type, size, msg_size);
return; /* XXX Should still complete operation */
@ -1036,7 +1036,7 @@ int gb_operation_sync_timeout(struct gb_connection *connection, int type,
ret = gb_operation_request_send_sync_timeout(operation, timeout);
if (ret) {
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);
} else {
if (response_size) {

View File

@ -166,7 +166,7 @@ int gb_protocol_get_version(struct gb_connection *connection)
if (response.major > connection->protocol->major) {
dev_err(&connection->hd->dev,
"%s: unsupported major version (%hhu > %hhu)\n",
"%s: unsupported major version (%u > %u)\n",
connection->name, response.major,
connection->protocol->major);
return -ENOTSUPP;
@ -176,7 +176,7 @@ int gb_protocol_get_version(struct gb_connection *connection)
connection->module_minor = response.minor;
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);
return 0;

View File

@ -85,14 +85,14 @@ 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) {
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);
return ret;
}
result = le16_to_cpu(response.result_code);
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);
return -EIO;
}
@ -121,14 +121,14 @@ 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) {
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);
return ret;
}
result = le16_to_cpu(response.result_code);
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);
return -EIO;
}
@ -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,
&request, sizeof(request), NULL, 0);
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);
}
}
@ -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,
&request, sizeof(request), NULL, 0);
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);
}
}
@ -287,7 +287,7 @@ static int gb_svc_version_request(struct gb_operation *op)
request = op->request->payload;
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);
return -ENOTSUPP;
}
@ -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
* 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);
gb_svc_intf_remove(svc, intf);
}
intf = gb_interface_create(hd, intf_id);
if (!intf) {
dev_err(&svc->dev, "failed to create interface %hhu\n",
dev_err(&svc->dev, "failed to create interface %u\n",
intf_id);
return;
}
@ -413,14 +413,14 @@ static void gb_svc_process_intf_hotplug(struct gb_operation *operation)
GB_DEVICE_ID_MODULES_START, 0, GFP_KERNEL);
if (device_id < 0) {
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);
goto destroy_interface;
}
ret = gb_svc_intf_device_id(svc, intf_id, device_id);
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);
goto ida_put;
}
@ -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,
intf_id, device_id);
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);
goto svc_id_free;
}
ret = gb_interface_init(intf, device_id);
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);
goto destroy_route;
}
@ -474,7 +474,7 @@ static void gb_svc_process_intf_hot_unplug(struct gb_operation *operation)
intf = gb_interface_find(hd, intf_id);
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);
return;
}