From patchwork Thu Mar 7 15:54:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 159874 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7592981jad; Thu, 7 Mar 2019 07:55:17 -0800 (PST) X-Google-Smtp-Source: APXvYqx2ItX8poDn30XTfDzyzLNRZj8iRM9bog/Q5TpD3ZA+BzFd1DnqgMK+XYmmr9tWFYcWRooz X-Received: by 2002:a62:6d81:: with SMTP id i123mr13318754pfc.235.1551974117047; Thu, 07 Mar 2019 07:55:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551974117; cv=none; d=google.com; s=arc-20160816; b=MOX9vx+QE2nkKNx/G5AqXgmlfnUh27+d0nv172bXcqtvbqDdfg/jy2vR64G/hzZJAQ kS7gzdAeWhlQ2FvhkCL8rZoWf2fdVJ43MG99RSPg51vJ4gxgdr2Ph7yAcC3sJSTS5Ndw rmkjSjRfLZ8CqbzmV/OCMC7W8Kx3Bt+L5Etr4CUtnraj06lklGBzy2O9/KeTmSZP5WQH vDWpG6d7hEXXzUmzM/Jh9mApt4+iqstlJzG7qsEGvCT3i/ghfYqBN6TXLaWsONfJrJi7 xjHOGTM/XmM/PDlNd7yAGoli4ycN67g0kXWDW1ITesot5Z5hYL0n955O+PVllilgDAP+ mtJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=BTm/7Yv7iMno0eJKNvUFktmhf9Z8ZXsImOWxv4zgKJ0=; b=0gT0wjviALWHQr1hAHIx8QRKvTgiczWF2/pajg4dMkNBU+Fy+cTh28neqFSLcDVg8H DEzez11/jCTIUgqKFL50goDMsU7x1FPqiosssSrHo/Wp+VwvUmHyCGG9TzxS98vrUJQf xQtf5m/8eZvjkxPs/v/BbqoYYbg70exw8+LL/YeTV5nA/zxo+S2zWPLDcQetplpbOsIu QRVE+hGQEWrmiWOlEbddGygERcXDCHvN7Fv2sAlz14eIG5fEjWup2T0lzB+7vC4MeDu1 hQuEGl1O4isxA97RaJhi8dnqn2MmSbd8z06hsyD+3aHdnwWhLhwQQPhm7gGmjCEGhIkU uy5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d5si4465290pla.312.2019.03.07.07.55.16; Thu, 07 Mar 2019 07:55:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726210AbfCGPzQ (ORCPT + 1 other); Thu, 7 Mar 2019 10:55:16 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:52649 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbfCGPzQ (ORCPT ); Thu, 7 Mar 2019 10:55:16 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MlfGs-1gcB010reU-00ihuN; Thu, 07 Mar 2019 16:55:11 +0100 From: Arnd Bergmann To: Mark Brown Cc: Rasmus Villemoes , Arnd Bergmann , Boris Brezillon , Linus Walleij , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v3] spi: work around clang bug in SPI_BPW_RANGE_MASK() Date: Thu, 7 Mar 2019 16:54:21 +0100 Message-Id: <20190307155506.2993868-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:L/LSRopOXQh6OeRW8D6OrIyx9PmpLgOLgU6/FG3n93lP0OQh/d1 W/xudIwXDI+JqGBr3ZJnjLT3gDcp8NROLWyDfIixB6xiFpQyuLN4xQBkivBZDHWZJ5OOcDe gn+/+rZDiG3S3vjd3xvBuuk73r3pQkbWYencG534b8Pv6lMMw67hnnSRHWzckmuCcqQAXyO F9WqyW8zr+i9bR4XNVqIA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:ExDB5wYZMpw=:Td4Qud0kQWOC55zMjsFQKy MCG0mdL5Z/2yDYM6Ceh3Wl/FCWdY7Kb0H4bVqKqG+8Emq/0Jnvdsykj8LpIR6Zf4VjCjJ19x5 5yK3xu4V632YR6EkfkX9M048ynRP9VgY+6hd2NO8E7X9AnJQ10UB6pJu+wET0J1sS4pv1LQy8 5geFAgxQI7ITwLf72J9ETf/FS/nfxNugDT6dH0PL0kXqtFrquLvWyMdw98gleIvC0iDdN3u3x u8mH7faiG35k4xc5pS2nOaqEoklFyaUOLTrjHZW/9M2iRVuvqUl86ZZI08C0/SLLrZbe1uCvc Yy3eIbxS2N7xZKUzFuGE+ACdi/ryxYzqdictW5muDfytyIIsg7kmgpNYR5GKGdSfMUQrfSlOw 0FVLXbUaLDhKMv2Zz5NfoI6AH73fXDWkF2+FJTFBJDZkYczH6EnHKHKJDtY2QiFJexSWEOrkk Z/+4+Pon+opwEX2GYT8Sh7Hmx3M+wsbZyhpcv4gp72MIz8jZWFjpOSSs5uqIfog6aRMrRa4Mi 4JX2dQjTWGoz+rP/s0+xPZ7mhao2FEZRBw5rgGFt5p5GiXt1G5WDII51vb89/ZLJloxNisiyB Pc+6+dRE6fL96ijMyz1NJoBuSPof/hteTFvs6s8gqSSitoXqTVnz/bNAq0vfLCsffL50oCu6u JPurQlC1IgnEQcOaCCk3JjexDGh2CeTxWtSQwnSvYlYoge1VpIB4pbLTsGIHLoEe73jG6iVVs g6qW28ayx/RptRqbvioW1L79MTbrSxu1gPmhKQ== Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Clang-8 evaluates both sides of a ?: expression to check for valid arithmetic even in the side that is never taken. This results in a build warning: drivers/spi/spi-sh-msiof.c:1052:24: error: shift count >= width of type [-Werror,-Wshift-count-overflow] .bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32), ^~~~~~~~~~~~~~~~~~~~~~~~~ Change the implementation to use the GENMASK() macro that does what we want here but does not have a problem with the shift count overflow. Link: https://bugs.llvm.org/show_bug.cgi?id=38789 Signed-off-by: Arnd Bergmann --- v3: use GENMASK() instead of open-coding it v2: add a code comment --- include/linux/spi/spi.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.20.0 diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 662b336aa2e4..b27386450089 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -444,8 +444,7 @@ struct spi_controller { /* bitmask of supported bits_per_word for transfers */ u32 bits_per_word_mask; #define SPI_BPW_MASK(bits) BIT((bits) - 1) -#define SPI_BIT_MASK(bits) (((bits) == 32) ? ~0U : (BIT(bits) - 1)) -#define SPI_BPW_RANGE_MASK(min, max) (SPI_BIT_MASK(max) - SPI_BIT_MASK(min - 1)) +#define SPI_BPW_RANGE_MASK(min, max) GENMASK((min) - 1, (max) - 1) /* limits on transfer speed */ u32 min_speed_hz;