From patchwork Tue Dec 4 15:27:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 1838961 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 4DC2A3FC64 for ; Tue, 4 Dec 2012 15:35:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754016Ab2LDPfY (ORCPT ); Tue, 4 Dec 2012 10:35:24 -0500 Received: from mail-wi0-f180.google.com ([209.85.212.180]:62769 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752353Ab2LDPfX (ORCPT ); Tue, 4 Dec 2012 10:35:23 -0500 X-Greylist: delayed 421 seconds by postgrey-1.27 at vger.kernel.org; Tue, 04 Dec 2012 10:35:22 EST Received: by mail-wi0-f180.google.com with SMTP id hj13so813278wib.1 for ; Tue, 04 Dec 2012 07:35:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; bh=qwtBO/pfvCb5Tr+1rRtqFBREB5Y/hjbOICeeIGutUbE=; b=abQnU1wNoPSuIRtc666KwCR4xeQ8OXyjWUR+L7TCDem7vF87ph+oi2dNVqtZJLA9iH jnAHR6AfatF60QQCloxf/2G1nFKc1NFVG0+oHfSKaMnzVrPK93aB6gIzBy9DHRdaQLgM duAYsPS4PFcbMLW3ixuFtxMFgt41X685eL7q09ejbbggdUIcS2Gaq7MnleNvEeDGqFB/ pW2apCxBAd2G8PVUV6+My+dHtrejhUoD94CGmcz8pusRQIqhoegMtJkdADsUeQo6rWVh 2hE0sQM4hlltd6MJ9h+PuBgj2gIfXCGxeTidRaZ8r4JJm2KlD58FxXtEnh9KUGag3HPq w3lQ== Received: by 10.216.139.140 with SMTP id c12mr5410102wej.46.1354634901572; Tue, 04 Dec 2012 07:28:21 -0800 (PST) Received: from localhost.localdomain.com (lan31-8-82-247-176-67.fbx.proxad.net. [82.247.176.67]) by mx.google.com with ESMTPS id p3sm15443846wic.8.2012.12.04.07.28.19 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 04 Dec 2012 07:28:20 -0800 (PST) From: Benjamin Tissoires To: Benjamin Tissoires , Jiri Kosina , Jean Delvare , linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/14] HID: i2c-hid: fix i2c_hid_dbg macro Date: Tue, 4 Dec 2012 16:27:46 +0100 Message-Id: <1354634875-5182-6-git-send-email-benjamin.tissoires@gmail.com> X-Mailer: git-send-email 1.8.0.1 In-Reply-To: <1354634875-5182-1-git-send-email-benjamin.tissoires@gmail.com> References: <1354634875-5182-1-git-send-email-benjamin.tissoires@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This avoids the problematic case: if (condition) i2c_hid_dbg(ihid, "Blah blah %d\n", i); else do_something_very_important(); Which looks correct, however with the previous macro definition, this expands to the unexpected: if (condition) { if (debug) \ dev_printk(KERN_DEBUG, &ihid->client->dev, "Blah blah %d\n", i); else do_something_very_important(); } Signed-off-by: Benjamin Tissoires Reviewed-by: Jean Delvare --- drivers/hid/i2c-hid/i2c-hid.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 9ee6555..54950be 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -50,9 +50,11 @@ static bool debug; module_param(debug, bool, 0444); MODULE_PARM_DESC(debug, "print a lot of debug information"); -#define i2c_hid_dbg(ihid, fmt, arg...) \ - if (debug) \ - dev_printk(KERN_DEBUG, &(ihid)->client->dev, fmt, ##arg) +#define i2c_hid_dbg(ihid, fmt, arg...) \ +do { \ + if (debug) \ + dev_printk(KERN_DEBUG, &(ihid)->client->dev, fmt, ##arg); \ +} while (0) struct i2c_hid_desc { __le16 wHIDDescLength;