From patchwork Tue Jan 5 10:16:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 59176 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp5877975lbb; Tue, 5 Jan 2016 02:17:05 -0800 (PST) X-Received: by 10.66.160.100 with SMTP id xj4mr133562008pab.14.1451989025027; Tue, 05 Jan 2016 02:17:05 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id eg4si66120822pac.40.2016.01.05.02.17.04; Tue, 05 Jan 2016 02:17:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-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-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751616AbcAEKRE (ORCPT + 4 others); Tue, 5 Jan 2016 05:17:04 -0500 Received: from mail-lf0-f46.google.com ([209.85.215.46]:34113 "EHLO mail-lf0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751543AbcAEKRD (ORCPT ); Tue, 5 Jan 2016 05:17:03 -0500 Received: by mail-lf0-f46.google.com with SMTP id y184so291101895lfc.1 for ; Tue, 05 Jan 2016 02:17:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=dAhQVarLhsi3MPYxe6MED1GgZLVJrfrg67cgKLKbmXE=; b=aK6S/w9z8Mmct/eLZ2keriJc/L1kq8iGyR0VwtvZnVUefy2w8gLsTA4VEjjs3nB5rj S2dTj8U1jbVfJyfPc7lx8OKxee+K1+iISlURh7MmmS8GLyQKNWPwMWmybeMqCjojsEms 2a8xUxDONZeFAtwzwiQAtAnc0/Rs3rVG96r30= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dAhQVarLhsi3MPYxe6MED1GgZLVJrfrg67cgKLKbmXE=; b=AC6UVrFJswGAJ9TbPBzR+OJsk6M3b5GdWneQJwBMjdjn6ybwQ6zrcaHVo/lKvh7Pyd 6qh7fkBAoaAT9Vp/hAAINAZeDE4XhuHvRRXdfJttTVBgJ7GmHAvMVgo1UUBSHDwer4oI a4/F60sItsy56SiuDIPTXLzBDElJOO6/KfWXDdA70YbTh25DGahSmmnWCm4r9rwzzcPR Xul3coV/GXD0GVPZra33s5u2GnaqAG1SP/W9guHU99+xK0/KZ09cpfv14eTdUmXRwLb2 v4m665HbpNQLLLzJnDIuwsoFVbsugH19/BFZwAu+BqJJNAnktuo/2DV87440tspKkjF8 ktfg== X-Gm-Message-State: ALoCoQl9Swfn41vgEyW+ogY9ZMvsRB9Du5Jd86qLYbUGR9EMTbyoAgkJH14rCysLxQkeS4oATlSJSxtHPlDB/v0Qw4NS0Q22Iw== X-Received: by 10.25.41.193 with SMTP id p184mr16673826lfp.150.1451989021313; Tue, 05 Jan 2016 02:17:01 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id k64sm10811636lfi.23.2016.01.05.02.17.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2016 02:17:00 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot , David Binderman Cc: Linus Walleij Subject: [PATCH] gpio: generic: fix signedness bug found by cppcheck Date: Tue, 5 Jan 2016 11:16:56 +0100 Message-Id: <1451989016-4126-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org cppcheck reports this: (style) int result is returned as long value. If the return value is long to avoid loss of information, then you have loss of information. This can be fixed with (1UL << pin) but that is the same as using that already use 1UL so take this approach. Reported-by: David Binderman Signed-off-by: Linus Walleij --- drivers/gpio/gpio-generic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c index ea581dc23d44..053a7f0a83e6 100644 --- a/drivers/gpio/gpio-generic.c +++ b/drivers/gpio/gpio-generic.c @@ -58,6 +58,7 @@ o ` ~~~~\___/~~~~ ` controller in FPGA is ,.` #include #include #include +#include #include #include #include @@ -126,13 +127,13 @@ static unsigned long bgpio_read32be(void __iomem *reg) static unsigned long bgpio_pin2mask(struct bgpio_chip *bgc, unsigned int pin) { - return 1 << pin; + return BIT(pin); } static unsigned long bgpio_pin2mask_be(struct bgpio_chip *bgc, unsigned int pin) { - return 1 << (bgc->bits - 1 - pin); + return BIT(bgc->bits - 1 - pin); } static int bgpio_get_set(struct gpio_chip *gc, unsigned int gpio)