Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750964AbdGZNdE (ORCPT ); Wed, 26 Jul 2017 09:33:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50156 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750783AbdGZNdC (ORCPT ); Wed, 26 Jul 2017 09:33:02 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 51014FB8D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lrichard@redhat.com Date: Wed, 26 Jul 2017 09:33:01 -0400 (EDT) From: Lance Richardson To: Stephen Boyd Cc: linux-sparse@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <1000702648.38599568.1501075981880.JavaMail.zimbra@redhat.com> In-Reply-To: <20170726013020.GL2146@codeaurora.org> References: <20170726013020.GL2146@codeaurora.org> Subject: Re: Sparse warnings on GENMASK + arm32 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.10.120.198, 10.4.195.24] Thread-Topic: Sparse warnings on GENMASK + arm32 Thread-Index: 7FHq/UgwhS3LhJ2f8xGZPnN6kEVNHg== X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 26 Jul 2017 13:33:02 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1740 Lines: 58 > From: "Stephen Boyd" > To: linux-sparse@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Sent: Tuesday, 25 July, 2017 9:30:20 PM > Subject: Sparse warnings on GENMASK + arm32 > > I see sparse warning when I check a clk driver file in the kernel > on a 32-bit ARM build. > > drivers/clk/sunxi/clk-sun6i-ar100.c:65:20: warning: cast truncates bits from > constant value (3ffffffff becomes ffffffff) > > The code in question looks like: > > static const struct factors_data sun6i_ar100_data = { > .mux = 16, > .muxmask = GENMASK(1, 0), > .table = &sun6i_ar100_config, > .getter = sun6i_get_ar100_factors, > }; > > where factors_data is > > struct factors_data { > int enable; > int mux; > int muxmask; > const struct clk_factors_config *table; > void (*getter)(struct factors_request *req); > void (*recalc)(struct factors_request *req); > const char *name; > }; > > > and sparse seems to be complaining about the muxmask assignment > here. Oddly, this doesn't happen on arm64 builds. Both times, I'm > checking this on an x86-64 machine. > > $ sparse --version > v0.5.1-rc4-1-gfa71b7ac0594 > > Is there something confusing to sparse in the GENMASK macro? > Hmm, it seems sparse is incorrectly taking ~0UL to be a 64-bit value while BITS_PER_LONG is (correctly) evaluated to be 32. #define GENMASK(h, l) \ (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) > -- > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, > a Linux Foundation Collaborative Project > -- > To unsubscribe from this list: send the line "unsubscribe linux-sparse" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >