From patchwork Sun Sep 25 07:15:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9349525 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6BF456077B for ; Sun, 25 Sep 2016 07:15:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53E0F28DF1 for ; Sun, 25 Sep 2016 07:15:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45FB528DF5; Sun, 25 Sep 2016 07:15:31 +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=-6.9 required=2.0 tests=BAYES_00,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 9A02E28DF1 for ; Sun, 25 Sep 2016 07:15:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936434AbcIYHP3 (ORCPT ); Sun, 25 Sep 2016 03:15:29 -0400 Received: from mout.web.de ([212.227.15.3]:49739 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934317AbcIYHP2 (ORCPT ); Sun, 25 Sep 2016 03:15:28 -0400 Received: from [192.168.1.2] ([78.48.212.125]) by smtp.web.de (mrweb001) with ESMTPSA (Nemesis) id 0LpOOj-1bI0Ys1dCP-00fA3A; Sun, 25 Sep 2016 09:15:19 +0200 Subject: [PATCH v2 3/3] Input-gameport: Replace some printk() calls by pr_info() in joydump_connect() To: linux-input@vger.kernel.org, Dmitry Torokhov , Joe Perches References: <1474733610.23838.2.camel@perches.com> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <814f7993-de4b-05d8-845e-3f0230122061@users.sourceforge.net> Date: Sun, 25 Sep 2016 09:15:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1474733610.23838.2.camel@perches.com> X-Provags-ID: V03:K0:lGKa4KDRQOUTzJgDuxMJu4c/cQ4TfwB+V585QA88F/De4JxjJy5 3lVCudHqcwgwbCiVpJY7I3+p0lsOZUpAUBSJIaS86X81JZKFCbnmEAh2jp8Zx3RkZiBz3mX j5luYIx1dNuujHQmlMn+4PtEc7R5qIyQGghQYe7WEmMFNcYi2h1JoDA5a0bgHbe2c4s/CWD 6RLNOh459H7YsAADm6qnw== X-UI-Out-Filterresults: notjunk:1; V01:K0:3WJ7mSDKaTU=:Jp9RjGG9X9cGmzKqxPRpsX 3IC5suiMg2HfltkhfyU0AYrcpCLpsTVvWHWnP4TGIIN02PBxbmAeILv+2wd5y6wOuuY4Qu2GJ MI684ZhbMmxjhzMbr0bE1exnBdZOsirNEG5XoihtbGk69DLkzk0Zk76RjTRJt6OHRGAW33zdB YXQzRFpz8hSvyxxp58RLwhKX8ktxoVAD6TH9NBQX9Y6tTib2OUutl9yCwWn5L45MFEBs5WtsC Vg9rNVnDg+ARajI36Z+Uhw1+/STngv8c/hIa/Dg76gL+N1W39NUngMWuZ1InA5744a61pe8/D qQqK+jm1iM0BSfHnp2L/jOet3GInaUPWpQINoqOH3djdcC9F8wVyLIoGw0EeKGqIrzKz9m89x pvqpmwwofaK6Da6sv814cNHETP+vun5nlRrk9m7kklP6PVfCOrZCNn+hIRibRkPeRFlzuu3UI c+fO6a+yJU+sgzOkByCZZyZTw8RIqyWgMgg9An2XxwsA8QgL0sHTa1//lPgVFxIpb3/ajkjkJ uwLi+Q/+U1oAtUzz9a48Vp/QEcw0kRAtEsWGXWsd1Q+u7GCT0JECOQcqRCC4wyxUNdrPA5PiJ oWkymDjadhxvELfU4ZTpiS777HnYVvCql6x2q3b9zJgMFVCHmHxdpfafSn3L7CbvuO2cK+Xs0 PO2IXly4mrwbWTCqckK2lB97MrFv63aSY37lg+ozmrn6sC7NlzDiWngA1ZFQd5YM063HafjRy imzIGouIhtdHdZ/k9MZkDwsZwFoXwa6y1zdF6F7XV+ks9HVn3HOl/HI/5HBH5JBZ5Iga+gAIT 2YF3dqz 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 From: Markus Elfring Date: Sun, 25 Sep 2016 08:40:34 +0200 1. Add a definition for the macros "MY_LOG_PREFIX" and "pr_fmt" so that their information can be used for consistent message output. 2. Prefer usage of the macro "pr_info" over the interface "printk" in this function. 3. Reduce number of output function calls. Signed-off-by: Markus Elfring --- v2: Yesterday a software development discussion pointed weaknesses out around the previous update steps "3" and "4". Now I propose this update variant in the hope that my second approach for this software module will work as desired and can be accepted a bit easier. Will the script "checkpatch.pl" need another improvement so that the following information can be avoided for my use case anyhow? ERROR: Macros with complex values should be enclosed in parentheses drivers/input/joystick/joydump.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/input/joystick/joydump.c b/drivers/input/joystick/joydump.c index f9f6cbe..e23c499 100644 --- a/drivers/input/joystick/joydump.c +++ b/drivers/input/joystick/joydump.c @@ -27,6 +27,8 @@ * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic */ +#define MY_LOG_PREFIX KBUILD_MODNAME ": " +#define pr_fmt(fmt) MY_LOG_PREFIX fmt #include #include #include @@ -55,27 +57,31 @@ static int joydump_connect(struct gameport *gameport, struct gameport_driver *dr unsigned long flags; unsigned char u; - printk(KERN_INFO "joydump: ,------------------ START ----------------.\n"); - printk(KERN_INFO "joydump: | Dumping: %30s |\n", gameport->phys); - printk(KERN_INFO "joydump: | Speed: %28d kHz |\n", gameport->speed); + pr_info(",------------------ START ----------------.\n" + MY_LOG_PREFIX "| Dumping: %30s |\n" + MY_LOG_PREFIX "| Speed: %28d kHz |\n", + gameport->phys, + gameport->speed); if (gameport_open(gameport, drv, GAMEPORT_MODE_RAW)) { - - printk(KERN_INFO "joydump: | Raw mode not available - trying cooked. |\n"); - + pr_info("| Raw mode not available - trying cooked. |\n"); if (gameport_open(gameport, drv, GAMEPORT_MODE_COOKED)) { - - printk(KERN_INFO "joydump: | Cooked not available either. Failing. |\n"); - printk(KERN_INFO "joydump: `------------------- END -----------------'\n"); + pr_info("| Cooked not available either. Failing. |\n" + MY_LOG_PREFIX + "`------------------- END -----------------'\n"); return -ENODEV; } gameport_cooked_read(gameport, axes, &buttons); for (i = 0; i < 4; i++) - printk(KERN_INFO "joydump: | Axis %d: %4d. |\n", i, axes[i]); - printk(KERN_INFO "joydump: | Buttons %02x. |\n", buttons); - printk(KERN_INFO "joydump: `------------------- END -----------------'\n"); + pr_info("| Axis %d: %4d. |\n", + i, + axes[i]); + pr_info("| Buttons %02x. |\n" + MY_LOG_PREFIX + "`------------------- END -----------------'\n", + buttons); } timeout = gameport_time(gameport, 10000); /* 10 ms */ @@ -119,16 +125,15 @@ static int joydump_connect(struct gameport *gameport, struct gameport_driver *dr t = i; dump = buf; prev = dump; - - printk(KERN_INFO "joydump: >------------------ DATA -----------------<\n"); - printk(KERN_INFO "joydump: | index: %3d delta: %3d us data: ", 0, 0); + pr_info(">------------------ DATA -----------------<\n" + MY_LOG_PREFIX "| index: %3d delta: %3d us data: ", 0, 0); for (j = 7; j >= 0; j--) printk("%d", (dump->data >> j) & 1); printk(" |\n"); dump++; for (i = 1; i < t; i++, dump++, prev++) { - printk(KERN_INFO "joydump: | index: %3d delta: %3d us data: ", + pr_info("| index: %3d delta: %3d us data: ", i, dump->time - prev->time); for (j = 7; j >= 0; j--) printk("%d", (dump->data >> j) & 1); @@ -137,8 +142,7 @@ static int joydump_connect(struct gameport *gameport, struct gameport_driver *dr kfree(buf); jd_end: - printk(KERN_INFO "joydump: `------------------- END -----------------'\n"); - + pr_info("`------------------- END -----------------'\n"); return 0; }