From patchwork Wed Feb 22 08:15:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Rokicki X-Patchwork-Id: 9586357 X-Patchwork-Delegate: kvalo@adurom.com 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 730B5602A7 for ; Wed, 22 Feb 2017 08:16:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 564A628502 for ; Wed, 22 Feb 2017 08:16:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47E982853C; Wed, 22 Feb 2017 08:16:08 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C89FF28502 for ; Wed, 22 Feb 2017 08:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=UZKrk74sGAvUWiXje+5qySELfTnGZs8mWuChmk7jYxw=; b=iy6 Wezn66GoYKvycq9UKgC53n2ffJshFBth/K/h4yF6PIuaguguKdOr0B4PRRQYUkuNsfhvNY7XxbQ/L lE1jUVRlRraADjUpgZ9fdmTezakPakIZQYiraLwOMFKKBCVTsk/fggYDjq/lf/vqsAote/Vc0Qovg I6qKnq2tX3D71sLmb5xaCex78fEpyqcI6VAWjAQZGuASuIMUj/ue21QegtDPYnZTTzXpEpj1+Njos pfsfszACAwM8WL/nRKUyz6nEhGSG5YuZafilBDzatLcGiBSItdLeE6v8kpeEZ0LK7Z2mbdJ48TSFj 7lft0lUS72KEOACd3Xds+82kVWLB98g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cgS5f-0003SY-6R; Wed, 22 Feb 2017 08:15:59 +0000 Received: from mail-lf0-x231.google.com ([2a00:1450:4010:c07::231]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cgS5b-0003QR-Dv for ath10k@lists.infradead.org; Wed, 22 Feb 2017 08:15:57 +0000 Received: by mail-lf0-x231.google.com with SMTP id b80so2052049lfe.3 for ; Wed, 22 Feb 2017 00:15:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id; bh=kI2DNjl6Rd6Vm7Lqn2rL7ZttWSYTNMNi9xYTDKmNM+k=; b=0EGDUPqbbSM0Vi3cRDSZenQ+cVFvudSdW196EChx8FVD4T0BcwR68vhjYdvjFT273Q l1eDl7TY602lUUqFmuJqlJPQXrj0ph/lyVPRuuSUx6/tdsU+lX6FC1eoqRnIRxTq8duK /7JUkn5SREwNyuU4t8lKffOiHKaIOvke8exEw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=kI2DNjl6Rd6Vm7Lqn2rL7ZttWSYTNMNi9xYTDKmNM+k=; b=jo9Zrjc3pKbF5M090/jjykqWyAlKNzB7nZ+tjDIXbdBjRM3nms70b/gZE0tmwgk+bY wh68NiRyW0t2h36dBLxj3CyGBa4dlvB8UC803xZF6BbXX1c+XNfd/IJ0XeJdgD55Ot+x Jz+t0O96HiqKdilrTHrJG2oD9zWjk1LcvHS9S5pXbXc4wS2NnyObgtn3JolzrtkgqJt+ 1zRELi44GMHCVs6nxmbAca5hQTGsoGVn4/O3azrecMElw3EuKh0IWfiI6+y+Wag596YY 5rbtp0kw/py1n7T4JrkMIGTiHhY97id2WAGatyGePDTkiIcROf1oAGNqDBD6AH5+VCq5 O33w== X-Gm-Message-State: AMke39lIA/ZO50UiiYFiUltYeMhrZcmmaomc78vgFbt3kVk3Tpn31+2IiiQ//EffD2D3YEY6LfqVe7B8O+ExbJvpfSzkPPBhpv2czi7wG32/BpDkZI7u+ZQVjkk+WTQD3JUTLQ0VeJLemK2rOUj6PDgb7r3Ec0Mq1nCGuyngCeuQ6pqNz9hdo2mdbBXOU5IRj2A= X-Received: by 10.25.10.6 with SMTP id 6mr9495204lfk.88.1487751330028; Wed, 22 Feb 2017 00:15:30 -0800 (PST) Received: from localhost.localdomain ([91.198.246.8]) by smtp.gmail.com with ESMTPSA id b7sm164081lfe.33.2017.02.22.00.15.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Feb 2017 00:15:29 -0800 (PST) From: Marcin Rokicki To: ath10k@lists.infradead.org Subject: [PATCH] ath10k: Modify macros to fix style issues Date: Wed, 22 Feb 2017 09:15:27 +0100 Message-Id: <1487751327-2917-1-git-send-email-marcin.rokicki@tieto.com> X-Mailer: git-send-email 2.7.4 X-DomainID: tieto.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170222_001555_657117_ABE13F6F X-CRM114-Status: GOOD ( 10.35 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Both macros are used internally to convert incomming parameters to strings in a switch case statement. Current implementation gives following output from checkpatch.pl: - ERROR: Macros with complex values should be enclosed in parentheses - WARNING: Macros with flow control statements should be avoided Fix them by modify local variable in the middle and just return at the end. Btw add const to function that return string literals Signed-off-by: Marcin Rokicki --- drivers/net/wireless/ath/ath10k/wmi.h | 36 +++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h index 427220c..0bf578f 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.h +++ b/drivers/net/wireless/ath/ath10k/wmi.h @@ -312,9 +312,16 @@ enum wmi_10_4_service { WMI_10_4_SERVICE_TX_MODE_DYNAMIC, }; -static inline char *wmi_service_name(int service_id) +#define SVCSTR(x) \ +{ \ + case x: \ + str = #x; \ + break; \ +} + +static inline const char *wmi_service_name(int service_id) { -#define SVCSTR(x) case x: return #x + const char *str = NULL; switch (service_id) { SVCSTR(WMI_SERVICE_BEACON_OFFLOAD); @@ -408,13 +415,13 @@ static inline char *wmi_service_name(int service_id) SVCSTR(WMI_SERVICE_TX_MODE_PUSH_ONLY); SVCSTR(WMI_SERVICE_TX_MODE_PUSH_PULL); SVCSTR(WMI_SERVICE_TX_MODE_DYNAMIC); - default: - return NULL; } -#undef SVCSTR + return str; } +#undef SVCSTR + #define WMI_SERVICE_IS_ENABLED(wmi_svc_bmap, svc_id, len) \ ((svc_id) < (len) && \ __le32_to_cpu((wmi_svc_bmap)[(svc_id) / (sizeof(u32))]) & \ @@ -6412,10 +6419,17 @@ enum wmi_wow_wakeup_event { WOW_EVENT_MAX, }; -#define C2S(x) case x: return #x +#define C2S(x) \ +{ \ + case x: \ + str = #x; \ + break; \ +} static inline const char *wow_wakeup_event(enum wmi_wow_wakeup_event ev) { + const char *str = NULL; + switch (ev) { C2S(WOW_BMISS_EVENT); C2S(WOW_BETTER_AP_EVENT); @@ -6442,9 +6456,9 @@ static inline const char *wow_wakeup_event(enum wmi_wow_wakeup_event ev) C2S(WOW_BEACON_EVENT); C2S(WOW_CLIENT_KICKOUT_EVENT); C2S(WOW_EVENT_MAX); - default: - return NULL; } + + return str; } enum wmi_wow_wake_reason { @@ -6482,6 +6496,8 @@ enum wmi_wow_wake_reason { static inline const char *wow_reason(enum wmi_wow_wake_reason reason) { + const char *str = NULL; + switch (reason) { C2S(WOW_REASON_UNSPECIFIED); C2S(WOW_REASON_NLOD); @@ -6513,9 +6529,9 @@ static inline const char *wow_reason(enum wmi_wow_wake_reason reason) C2S(WOW_REASON_BEACON_RECV); C2S(WOW_REASON_CLIENT_KICKOUT_EVENT); C2S(WOW_REASON_DEBUG_TEST); - default: - return NULL; } + + return str; } #undef C2S