From patchwork Tue Jul 24 15:21:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Schumacher X-Patchwork-Id: 10542333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 18521112B for ; Tue, 24 Jul 2018 15:21:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05DAD28925 for ; Tue, 24 Jul 2018 15:21:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0429428904; Tue, 24 Jul 2018 15:21:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 641362899F for ; Tue, 24 Jul 2018 15:21:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726889AbeGXQ2Q (ORCPT ); Tue, 24 Jul 2018 12:28:16 -0400 Received: from mout.gmx.net ([212.227.15.18]:38429 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726857AbeGXQ2P (ORCPT ); Tue, 24 Jul 2018 12:28:15 -0400 Received: from p2520la.lan ([217.235.88.97]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0LjIel-1gHbWO3FUd-00dT63; Tue, 24 Jul 2018 17:21:15 +0200 From: Tim Schumacher To: dmitry.torokhov@gmail.com Cc: timschumi@gmx.de, linux-input@vger.kernel.org Subject: [PATCH v2] input/iforce: Reformat the packet dump output Date: Tue, 24 Jul 2018 17:21:06 +0200 Message-Id: <20180724152106.27109-1-timschumi@gmx.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180723224654.GM100814@dtor-ws> References: <20180723224654.GM100814@dtor-ws> X-Provags-ID: V03:K1:gUEQFYNL8m/fqn5+g0vEFFdtoQfs/Au7hkmNT8WktmUsOCImSHh a5cNPq1G/q1QdhsxohgwoXxgZ4ApvW6G/1fqy2U/VhP6/eN9hqhnF+jcKKc4x6zND+56AHY E+BcS8uVmwpnXNm7pE6EKc57OXsA/VP2RuOASiPXSMpkNq5xyPaS0TyjiFbHDiyOFFI4qrl mXwXKpItgSZ2/b97tBjbQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:ZyOFy5B05zY=:xLimYUKKyOidPnMZmHv9Rl aiwy9pwMTuZEXthZjK97jZgMfDOJQF1FeBKnGhWyRz/drZLgBErOkDKtnWBZGMhU6hHaf1S8k 44mMtS6gD/IqIINq6AXQnBxsuzpunFWNoWSTuyclnsxyxjnUdVSuwP0KLwpRRo6nPz4pOUmnP 6zle1bPdr1v19Ixfn2Lm+XjSNcgRzWnNSawqI9auDfJEqvPE38fZeDadzyFNJYqq1EsTNp4WZ p8UndkCrLBlNZSYWn1vWslUK5McJJ5yW0l5FKyDvJU0lcH7rUE4SGLn9wC7BS0yAA3CXPWDj6 SA9/LuUD/WFYlbsk8IYqe/4RQHH5sTTh4nZ5CHIfRVV9bfAmfX6f+nee0jjskUbqT+eDYEYcb YZAZUzatVndq50xbh40HbHDqe7UjPTTEVUzE+3gG4sm56ovoNQrKNDH1aiRtbZyFaF9w+rSgC n2iW/Q5yL2qK1m+w0NrwokDHjSIfGiqcNFhfjl3AJv/GOc3WsOZPdfdGVJ7cRz8knb0YIONpe 4xw6OPKM40aXAqYPePpWL28uyTBtkjOHetjT7/A9+18fJArcsyMoa7zknnQmuS7oLIfprKyqT lz50KiN59p6F7Ob2Cw62NO2QhB/hlIIjw2PT2e0m7WDsew+4DzFE21AjVMmcg5/mOKSJK0RFb 4pNOgE6JajsZD51EYMzQb+z+RfzJUGybzgd4IQWq4zWCTAoh540gnrsOw+7ox/MIq+zLpR0DO RhiUWTPTydupdO10cCq1CxciDqf7Bgak3KI5OxgfkxByzkJCZjUcd2rARyQ= Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Previously, packets that have been dumped are shown in the kernel log like this: drivers/input/joystick/iforce/iforce-packets.c: info cmd = ff04, data = 56 02 04 00 Use dev_dbg to dump the packages only when requested and to list the parent device as well. Use printf logic to generate the hexdump instead of looping through every char that needs to be printed (which in turn fixes the unnecessary newlines and looks more clean in general). The resulting package dump output does now look like this: usb 2-8: iforce_dump_packet info cmd = ff04, data = 56 02 04 00 Signed-off-by: Tim Schumacher --- drivers/input/joystick/iforce/iforce-ff.c | 4 ++-- drivers/input/joystick/iforce/iforce-main.c | 2 +- drivers/input/joystick/iforce/iforce-packets.c | 10 +++------- drivers/input/joystick/iforce/iforce.h | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/input/joystick/iforce/iforce-ff.c b/drivers/input/joystick/iforce/iforce-ff.c index 0de9a0943a9e..c939d45207f9 100644 --- a/drivers/input/joystick/iforce/iforce-ff.c +++ b/drivers/input/joystick/iforce/iforce-ff.c @@ -56,7 +56,7 @@ static int make_magnitude_modifier(struct iforce* iforce, iforce_send_packet(iforce, FF_CMD_MAGNITUDE, data); - iforce_dump_packet("magnitude: ", FF_CMD_MAGNITUDE, data); + iforce_dump_packet(iforce, "magnitude", FF_CMD_MAGNITUDE, data); return 0; } @@ -178,7 +178,7 @@ static int make_condition_modifier(struct iforce* iforce, data[9] = (100 * lsat) >> 16; iforce_send_packet(iforce, FF_CMD_CONDITION, data); - iforce_dump_packet("condition", FF_CMD_CONDITION, data); + iforce_dump_packet(iforce, "condition", FF_CMD_CONDITION, data); return 0; } diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c index a4ab58633136..583e5c77f7da 100644 --- a/drivers/input/joystick/iforce/iforce-main.c +++ b/drivers/input/joystick/iforce/iforce-main.c @@ -360,7 +360,7 @@ int iforce_init_device(struct iforce *iforce) for (i = 0; c[i]; i++) if (!iforce_get_id_packet(iforce, c + i)) - iforce_dump_packet("info", iforce->ecmd, iforce->edata); + iforce_dump_packet(iforce, "info", iforce->ecmd, iforce->edata); /* * Disable spring, enable force feedback. diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c index d929c6f05275..2eadc76adffb 100644 --- a/drivers/input/joystick/iforce/iforce-packets.c +++ b/drivers/input/joystick/iforce/iforce-packets.c @@ -33,14 +33,10 @@ static struct { } iforce_hat_to_axis[16] = {{ 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}}; -void iforce_dump_packet(char *msg, u16 cmd, unsigned char *data) +void iforce_dump_packet(struct iforce *iforce, char *msg, u16 cmd, unsigned char *data) { - int i; - - printk(KERN_DEBUG __FILE__ ": %s cmd = %04x, data = ", msg, cmd); - for (i = 0; i < LO(cmd); i++) - printk("%02x ", data[i]); - printk("\n"); + dev_dbg(iforce->dev->dev.parent, "%s %s cmd = %04x, data = %*ph\n", + __func__, msg, cmd, LO(cmd), data); } /* diff --git a/drivers/input/joystick/iforce/iforce.h b/drivers/input/joystick/iforce/iforce.h index 96ae4f5bd0eb..7abf1b0341c9 100644 --- a/drivers/input/joystick/iforce/iforce.h +++ b/drivers/input/joystick/iforce/iforce.h @@ -158,7 +158,7 @@ int iforce_init_device(struct iforce *iforce); int iforce_control_playback(struct iforce*, u16 id, unsigned int); void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data); int iforce_send_packet(struct iforce *iforce, u16 cmd, unsigned char* data); -void iforce_dump_packet(char *msg, u16 cmd, unsigned char *data) ; +void iforce_dump_packet(struct iforce *iforce, char *msg, u16 cmd, unsigned char *data) ; int iforce_get_id_packet(struct iforce *iforce, char *packet); /* iforce-ff.c */