From patchwork Sat Mar 11 02:21:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 9618325 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 C0A216046A for ; Sat, 11 Mar 2017 02:23:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1E392870E for ; Sat, 11 Mar 2017 02:23:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A653E28753; Sat, 11 Mar 2017 02:23:36 +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 0502A2870E for ; Sat, 11 Mar 2017 02:23:33 +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=uKmL0JPGKp58vsHeW+pfRJ5JPPdrNbgT4yNaUV9shxw=; b=I5b Db+ute8tJsQH3p76cbzHO3kmErUvNkJoTOsV7F2q3/imT3ClBguVjL4gWP9XhygZ+FTpShEusnvp/ ZtjJMAjBq21EmW+9uQB+sjgH+wMRpYpITn8avEitzqmjThq/r33PHYUFQUjquDzV3UZPCnRsiqrl2 z39HzKVSeTuHyO50pbo9Dl9arpBPoU5bGukAYAVCVI/AIwj1rBwViIYUhDPwCArR8WZC2hxVAJDiK XkynhstoizJlp6B3WnymBacvNNPJnw7Hjhx2W3RDnexUx4v/3rMxLxAuzVSZhm81znxEMHxHZr5ew sY6DhhLY08fqGB3eI/DpyBB+hqZ+USQ==; 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 1cmWgs-0001uh-Cg; Sat, 11 Mar 2017 02:23:30 +0000 Received: from mail-pg0-f42.google.com ([74.125.83.42]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cmWgN-0001kB-On for linux-rockchip@lists.infradead.org; Sat, 11 Mar 2017 02:23:01 +0000 Received: by mail-pg0-f42.google.com with SMTP id 25so45106171pgy.0 for ; Fri, 10 Mar 2017 18:22:37 -0800 (PST) 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=wEa58eP7WXnUe+YOBGY4G1hitH4buBWBqfMiffXeGI4=; b=lo6iZFcLEO3OLSdsWSMhDk69UoVkgY8cc1DYyOhaK+YsraESpvGNi36vT/Znbnnor2 KtGapcUB5svPqhLytSA/BEUGq0xM4vgBDyvYPYJYFWmwhlpo32bkuJZXIW6rcaEYVNsC n1d8uUGbPigw2Vutd81EUyVkH4brFFFXNzLG6CXmCkq3wyLs1Hg/hq/o0snxdlFwavg5 2js3m0Ba7qXRO2qhTgbFSXjbwrkRKw1lJtJB+ChY8gSQLxdFlWpYMD0ZJ45xIL+xYzqr zgqBf9ix/QgBNOnMxp1/+X3wT3uqLsCiVnBjqPi3PHLro/MJZmQdGjMBOjiHe3xx9UXt Hz+g== X-Gm-Message-State: AMke39mu+LDuwuKbbCMPFgKLPpcNmRQxkIcT3uOeUzp3ldVeutT7NrCd6Ru4wsjUemCIuayU X-Received: by 10.84.169.227 with SMTP id h90mr29803765plb.155.1489198956589; Fri, 10 Mar 2017 18:22:36 -0800 (PST) Received: from mka.mtv.corp.google.com ([172.22.66.174]) by smtp.gmail.com with ESMTPSA id g64sm20896909pfc.57.2017.03.10.18.22.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Mar 2017 18:22:35 -0800 (PST) From: Matthias Kaehlcke To: Heiko Stuebner , Elaine Zhang , Caesar Wang , Shawn Lin , Douglas Anderson , Grant Grundler Subject: [PATCH v1] soc: rockchip: power-domain: Fix clang warning about negative shift count Date: Fri, 10 Mar 2017 18:21:53 -0800 Message-Id: <20170311022153.139362-1-mka@chromium.org> X-Mailer: git-send-email 2.12.0.246.ga2ecc84866-goog X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170310_182259_841259_92FF0238 X-CRM114-Status: UNSURE ( 6.82 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rockchip@lists.infradead.org, Matthias Kaehlcke , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The following warning is generated when building with clang: drivers/soc/rockchip/pm_domains.c:726:22: error: shift count is negative [-Werror,-Wshift-count-negative] [RK3399_PD_TCPD0] = DOMAIN_RK3399(8, 8, -1, false), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/soc/rockchip/pm_domains.c:101:2: note: expanded from macro 'DOMAIN_RK3399' DOMAIN(pwr, status, req, req, req, wakeup) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/soc/rockchip/pm_domains.c:88:27: note: expanded from macro 'DOMAIN' .req_mask = (req >= 0) ? BIT(req) : 0, \ ^~~~~~~~ include/linux/bitops.h:6:24: note: expanded from macro 'BIT' The BIT macro is evaluated with the negative value -1, even though the resulting value would not be assigned. To fix this we only pass values between 0 and 63 to BIT(). Unfortunately this means that we lose the benefit of the compiler checking for out of bounds errors. Signed-off-by: Matthias Kaehlcke --- drivers/soc/rockchip/pm_domains.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/soc/rockchip/pm_domains.c b/drivers/soc/rockchip/pm_domains.c index 1c78c42416c6..6f2bb1222992 100644 --- a/drivers/soc/rockchip/pm_domains.c +++ b/drivers/soc/rockchip/pm_domains.c @@ -77,13 +77,15 @@ struct rockchip_pmu { #define to_rockchip_pd(gpd) container_of(gpd, struct rockchip_pm_domain, genpd) +#define RK_MASK(bit) ((bit >= 0) ? BIT(bit & 0x3f) : 0) + #define DOMAIN(pwr, status, req, idle, ack, wakeup) \ -{ \ - .pwr_mask = (pwr >= 0) ? BIT(pwr) : 0, \ - .status_mask = (status >= 0) ? BIT(status) : 0, \ - .req_mask = (req >= 0) ? BIT(req) : 0, \ - .idle_mask = (idle >= 0) ? BIT(idle) : 0, \ - .ack_mask = (ack >= 0) ? BIT(ack) : 0, \ +{ \ + .pwr_mask = RK_MASK(pwr), \ + .status_mask = RK_MASK(status), \ + .req_mask = RK_MASK(req), \ + .idle_mask = RK_MASK(idle), \ + .ack_mask = RK_MASK(ack), \ .active_wakeup = wakeup, \ }