* [PATCH] hid-wiimote: print small buffers via %*ph
@ 2013-09-03 12:32 Andy Shevchenko
2013-09-03 13:21 ` David Herrmann
2013-09-04 9:40 ` Jiri Kosina
0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2013-09-03 12:32 UTC (permalink / raw)
To: David Herrmann, Jiri Kosina, linux-input; +Cc: Andy Shevchenko
Instead of passing each byte through stack let's use %*ph specifier to dump
buffer as a hex string.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/hid/hid-wiimote-core.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index 6602098..ad3ac57 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -441,8 +441,7 @@ static __u8 wiimote_cmd_read_ext(struct wiimote_data *wdata, __u8 *rmem)
if (ret != 6)
return WIIMOTE_EXT_NONE;
- hid_dbg(wdata->hdev, "extension ID: %02x:%02x %02x:%02x %02x:%02x\n",
- rmem[0], rmem[1], rmem[2], rmem[3], rmem[4], rmem[5]);
+ hid_dbg(wdata->hdev, "extension ID: %6ph\n", rmem);
if (rmem[0] == 0xff && rmem[1] == 0xff && rmem[2] == 0xff &&
rmem[3] == 0xff && rmem[4] == 0xff && rmem[5] == 0xff)
@@ -512,14 +511,12 @@ static bool wiimote_cmd_read_mp(struct wiimote_data *wdata, __u8 *rmem)
if (ret != 6)
return false;
- hid_dbg(wdata->hdev, "motion plus ID: %02x:%02x %02x:%02x %02x:%02x\n",
- rmem[0], rmem[1], rmem[2], rmem[3], rmem[4], rmem[5]);
+ hid_dbg(wdata->hdev, "motion plus ID: %6ph\n", rmem);
if (rmem[5] == 0x05)
return true;
- hid_info(wdata->hdev, "unknown motion plus ID: %02x:%02x %02x:%02x %02x:%02x\n",
- rmem[0], rmem[1], rmem[2], rmem[3], rmem[4], rmem[5]);
+ hid_info(wdata->hdev, "unknown motion plus ID: %6ph\n", rmem);
return false;
}
@@ -535,8 +532,7 @@ static __u8 wiimote_cmd_read_mp_mapped(struct wiimote_data *wdata)
if (ret != 6)
return WIIMOTE_MP_NONE;
- hid_dbg(wdata->hdev, "mapped motion plus ID: %02x:%02x %02x:%02x %02x:%02x\n",
- rmem[0], rmem[1], rmem[2], rmem[3], rmem[4], rmem[5]);
+ hid_dbg(wdata->hdev, "mapped motion plus ID: %6ph\n", rmem);
if (rmem[0] == 0xff && rmem[1] == 0xff && rmem[2] == 0xff &&
rmem[3] == 0xff && rmem[4] == 0xff && rmem[5] == 0xff)
@@ -1128,9 +1124,8 @@ static void wiimote_init_hotplug(struct wiimote_data *wdata)
wiimote_ext_unload(wdata);
if (exttype == WIIMOTE_EXT_UNKNOWN) {
- hid_info(wdata->hdev, "cannot detect extension; %02x:%02x %02x:%02x %02x:%02x\n",
- extdata[0], extdata[1], extdata[2],
- extdata[3], extdata[4], extdata[5]);
+ hid_info(wdata->hdev, "cannot detect extension; %6ph\n",
+ extdata);
} else if (exttype == WIIMOTE_EXT_NONE) {
spin_lock_irq(&wdata->state.lock);
wdata->state.exttype = WIIMOTE_EXT_NONE;
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] hid-wiimote: print small buffers via %*ph
2013-09-03 12:32 [PATCH] hid-wiimote: print small buffers via %*ph Andy Shevchenko
@ 2013-09-03 13:21 ` David Herrmann
2013-09-04 9:40 ` Jiri Kosina
1 sibling, 0 replies; 4+ messages in thread
From: David Herrmann @ 2013-09-03 13:21 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: David Herrmann, Jiri Kosina, open list:HID CORE LAYER
Hi
On Tue, Sep 3, 2013 at 2:32 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> Instead of passing each byte through stack let's use %*ph specifier to dump
> buffer as a hex string.
I'd actually prefer %*phC to make grep'ing for these things easier.
Apart from that:
Acked-by: David Herrmann <dh.herrmann@gmail.com>
Thanks
David
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/hid/hid-wiimote-core.c | 17 ++++++-----------
> 1 file changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
> index 6602098..ad3ac57 100644
> --- a/drivers/hid/hid-wiimote-core.c
> +++ b/drivers/hid/hid-wiimote-core.c
> @@ -441,8 +441,7 @@ static __u8 wiimote_cmd_read_ext(struct wiimote_data *wdata, __u8 *rmem)
> if (ret != 6)
> return WIIMOTE_EXT_NONE;
>
> - hid_dbg(wdata->hdev, "extension ID: %02x:%02x %02x:%02x %02x:%02x\n",
> - rmem[0], rmem[1], rmem[2], rmem[3], rmem[4], rmem[5]);
> + hid_dbg(wdata->hdev, "extension ID: %6ph\n", rmem);
>
> if (rmem[0] == 0xff && rmem[1] == 0xff && rmem[2] == 0xff &&
> rmem[3] == 0xff && rmem[4] == 0xff && rmem[5] == 0xff)
> @@ -512,14 +511,12 @@ static bool wiimote_cmd_read_mp(struct wiimote_data *wdata, __u8 *rmem)
> if (ret != 6)
> return false;
>
> - hid_dbg(wdata->hdev, "motion plus ID: %02x:%02x %02x:%02x %02x:%02x\n",
> - rmem[0], rmem[1], rmem[2], rmem[3], rmem[4], rmem[5]);
> + hid_dbg(wdata->hdev, "motion plus ID: %6ph\n", rmem);
>
> if (rmem[5] == 0x05)
> return true;
>
> - hid_info(wdata->hdev, "unknown motion plus ID: %02x:%02x %02x:%02x %02x:%02x\n",
> - rmem[0], rmem[1], rmem[2], rmem[3], rmem[4], rmem[5]);
> + hid_info(wdata->hdev, "unknown motion plus ID: %6ph\n", rmem);
>
> return false;
> }
> @@ -535,8 +532,7 @@ static __u8 wiimote_cmd_read_mp_mapped(struct wiimote_data *wdata)
> if (ret != 6)
> return WIIMOTE_MP_NONE;
>
> - hid_dbg(wdata->hdev, "mapped motion plus ID: %02x:%02x %02x:%02x %02x:%02x\n",
> - rmem[0], rmem[1], rmem[2], rmem[3], rmem[4], rmem[5]);
> + hid_dbg(wdata->hdev, "mapped motion plus ID: %6ph\n", rmem);
>
> if (rmem[0] == 0xff && rmem[1] == 0xff && rmem[2] == 0xff &&
> rmem[3] == 0xff && rmem[4] == 0xff && rmem[5] == 0xff)
> @@ -1128,9 +1124,8 @@ static void wiimote_init_hotplug(struct wiimote_data *wdata)
> wiimote_ext_unload(wdata);
>
> if (exttype == WIIMOTE_EXT_UNKNOWN) {
> - hid_info(wdata->hdev, "cannot detect extension; %02x:%02x %02x:%02x %02x:%02x\n",
> - extdata[0], extdata[1], extdata[2],
> - extdata[3], extdata[4], extdata[5]);
> + hid_info(wdata->hdev, "cannot detect extension; %6ph\n",
> + extdata);
> } else if (exttype == WIIMOTE_EXT_NONE) {
> spin_lock_irq(&wdata->state.lock);
> wdata->state.exttype = WIIMOTE_EXT_NONE;
> --
> 1.8.4.rc3
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hid-wiimote: print small buffers via %*ph
2013-09-03 12:32 [PATCH] hid-wiimote: print small buffers via %*ph Andy Shevchenko
2013-09-03 13:21 ` David Herrmann
@ 2013-09-04 9:40 ` Jiri Kosina
2013-09-04 9:43 ` Jiri Kosina
1 sibling, 1 reply; 4+ messages in thread
From: Jiri Kosina @ 2013-09-04 9:40 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: David Herrmann, linux-input
On Tue, 3 Sep 2013, Andy Shevchenko wrote:
> Instead of passing each byte through stack let's use %*ph specifier to dump
> buffer as a hex string.
Applied, thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hid-wiimote: print small buffers via %*ph
2013-09-04 9:40 ` Jiri Kosina
@ 2013-09-04 9:43 ` Jiri Kosina
0 siblings, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2013-09-04 9:43 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: David Herrmann, linux-input
On Wed, 4 Sep 2013, Jiri Kosina wrote:
> > Instead of passing each byte through stack let's use %*ph specifier to dump
> > buffer as a hex string.
>
> Applied, thanks.
I acutally applied the phC one, but replied to wrong thread, sorry for the
noise.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-09-04 9:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-03 12:32 [PATCH] hid-wiimote: print small buffers via %*ph Andy Shevchenko
2013-09-03 13:21 ` David Herrmann
2013-09-04 9:40 ` Jiri Kosina
2013-09-04 9:43 ` Jiri Kosina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).