From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752203AbdAMP5m (ORCPT ); Fri, 13 Jan 2017 10:57:42 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:48854 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752022AbdAMP5k (ORCPT ); Fri, 13 Jan 2017 10:57:40 -0500 Subject: Re: [PATCH 3/3] rtc: stm32: use 32-bit cast for BIT() macro To: Arnd Bergmann , Alexandre Belloni References: <20170113153311.2611510-1-arnd@arndb.de> <20170113153311.2611510-3-arnd@arndb.de> CC: Mark Brown , Alessandro Zummo , Maxime Coquelin , Alexandre TORGUE , Mathieu Poirier , "rtc-linux@googlegroups.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" From: Amelie DELAUNAY Message-ID: <26624cbe-7e71-35a4-b8df-f5ac5d15b1ec@st.com> Date: Fri, 13 Jan 2017 16:56:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20170113153311.2611510-3-arnd@arndb.de> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG3NODE3.st.com (10.75.127.9) To SFHDAG3NODE2.st.com (10.75.127.8) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-01-13_09:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnd, On 01/13/2017 04:32 PM, Arnd Bergmann wrote: > Using the ~ operator on a BIT() constant results in a large 'unsigned long' > constant that won't fit into an 'unsigned int' function argument on 64-bit > architectures, resulting in a harmless build warning in x86 allmodconfig: > > drivers/rtc/rtc-stm32.c: In function 'stm32_rtc_probe': > drivers/rtc/rtc-stm32.c:651:51: error: large integer implicitly truncated to unsigned type [-Werror=overflow] > regmap_update_bits(rtc->dbp, PWR_CR, PWR_CR_DBP, ~PWR_CR_DBP); I thought I would fix this warning by replacing all ~PWR_CR_DBP by 0, because the mask PWR_CR_DBP prevents other bits to be cleared. In this way, I avoid the ugly cast... > > This works around the warning by adding an explict cast to 'u32', but > that is unfortunately a bit ugly and I feel there should be a better > way to do this, possibly with some changes to either the bitops.h > header or the regmap API. > > Cc: Mark Brown > Fixes: 4e64350f42e2 ("rtc: add STM32 RTC driver") > Signed-off-by: Arnd Bergmann > --- > drivers/rtc/rtc-stm32.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/rtc/rtc-stm32.c b/drivers/rtc/rtc-stm32.c > index 8c599f52124c..05d3dc89e55f 100644 > --- a/drivers/rtc/rtc-stm32.c > +++ b/drivers/rtc/rtc-stm32.c > @@ -92,7 +92,7 @@ > /* STM32_PWR_CR */ > #define PWR_CR 0x00 > /* STM32_PWR_CR bit field */ > -#define PWR_CR_DBP BIT(8) > +#define PWR_CR_DBP (u32)BIT(8) > > struct stm32_rtc { > struct rtc_device *rtc_dev; > Regards, Amelie