From patchwork Sun Oct 9 14:52:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 77406 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp883691qge; Sun, 9 Oct 2016 07:53:22 -0700 (PDT) X-Received: by 10.25.198.9 with SMTP id w9mr12259671lff.164.1476024802578; Sun, 09 Oct 2016 07:53:22 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id 79si14493411lja.36.2016.10.09.07.53.22; Sun, 09 Oct 2016 07:53:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BBAA1A75DC; Sun, 9 Oct 2016 16:53:21 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id o8-ljiorgYq0; Sun, 9 Oct 2016 16:53:21 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D66DAA7537; Sun, 9 Oct 2016 16:53:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D8235A7537 for ; Sun, 9 Oct 2016 16:53:16 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Z2R-Tqh_tKA4 for ; Sun, 9 Oct 2016 16:53:16 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from conuserg-07.nifty.com (conuserg-07.nifty.com [210.131.2.74]) by theia.denx.de (Postfix) with ESMTPS id 2B5E9A7527 for ; Sun, 9 Oct 2016 16:53:13 +0200 (CEST) Received: from grover.sesame (FL1-111-169-71-157.osk.mesh.ad.jp [111.169.71.157]) (authenticated) by conuserg-07.nifty.com with ESMTP id u99Eqxve029444; Sun, 9 Oct 2016 23:53:02 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com u99Eqxve029444 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1476024782; bh=orNmDzh9GVOZP216+MllFwsU7tqCC/OZuQS5dBop9ac=; h=From:To:Cc:Subject:Date:From; b=FcqKCLx6C8ywMifvOY0kp0v4XgfJ42kBzUHouACv1yDvW/KmS2pYy1c4vap4SFBIA bN4xub3+YRgEcrXrvaGXUKgfSvgytChVu/XP3SKrc7f2bCpWuEjpoo4Rm9ehiIwU3w JrYdTjy9mLJa8cwqEWv57Q/0weWOn3p0BMFW75FpIF0wGoVR1bvDsEthY7wefxQQT1 twlZFdnawlWWq/TrPzfuBU3EQetjmtHbGi+eRzZVPCAszVnayjfBlhjSN31wv/Asl6 WXnqLKJ8GrwhAU6KAaRtkuiK6lt5z0PWwQLmuYeMTJrL1WTCBgh5HrIcVGp+9/cFlY bpw9w3kFxKNtA== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Sun, 9 Oct 2016 23:52:57 +0900 Message-Id: <1476024777-5113-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 Cc: Marek Vasut Subject: [U-Boot] [PATCH] pinctrl: uniphier: fix unused-const-variable warnings for GCC 6.x X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Marek reports warnings in UniPhier pinctrl drivers when compiled by GCC 6.x, like: drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c:58:18: warning: 'usb3_muxvals' defined but not used [-Wunused-const-variable=] static const int usb3_muxvals[] = {0, 0}; ^~~~~~~~~~~~ My intention here is to compile minimum set of pin data for SPL to save memory footprint, but GCC these days is clever enough to notice unused data arrays. We can fix it by sprinkling around __maybe_unused on those arrays, but I did not do that because they are counterparts of the pinctrl drivers in Linux. All the pin data were just copy-pasted from Linux and are kept in sync for maintainability. I chose a bit tricky way to fix the issue; calculate ARRAY_SIZE of *_pins and *_muxvals and set their sum to an unused struct member. This trick will satisfy GCC because the data arrays are used anyway, but such data arrays will be dropped from the final binary because the pointers to them are not used. Signed-off-by: Masahiro Yamada Reported-by: Marek Vasut --- drivers/pinctrl/uniphier/pinctrl-uniphier.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier.h b/drivers/pinctrl/uniphier/pinctrl-uniphier.h index 5c3db2a..21e2d37 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier.h +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier.h @@ -91,7 +91,12 @@ struct uniphier_pinctrl_socdata { #define __UNIPHIER_PINMUX_FUNCTION(func) #func #ifdef CONFIG_SPL_BUILD -#define UNIPHIER_PINCTRL_GROUP(grp) { .name = NULL } + /* + * a tricky way to drop unneeded *_pins and *_muxvals arrays from SPL, + * suppressing "defined but not used" warnings. + */ +#define UNIPHIER_PINCTRL_GROUP(grp) \ + { .num_pins = ARRAY_SIZE(grp##_pins) + ARRAY_SIZE(grp##_muxvals) } #define UNIPHIER_PINMUX_FUNCTION(func) NULL #else #define UNIPHIER_PINCTRL_GROUP(grp) __UNIPHIER_PINCTRL_GROUP(grp)