From patchwork Mon Sep 3 08:15:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 145751 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp2214128ljw; Mon, 3 Sep 2018 01:22:45 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdah+eV+0CVjmYi+BDvJMSmrTl4mtnrU9rZo85NhU+fiwqM/HF6lUZ82qQbZvBBwjEyjq17V X-Received: by 2002:a63:7c50:: with SMTP id l16-v6mr25166952pgn.311.1535962965527; Mon, 03 Sep 2018 01:22:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535962965; cv=none; d=google.com; s=arc-20160816; b=J0caKvfjnib2mmhr8jqKGo7CfqzleUjEzurxT/kgOp8KGy0mJfKGL2yU45XDwC+eGk IWpEvYbrqgwHi03b0ll+Y+ImiF5z2dOTBcwCaNAiKXoVj7sDaCNRwz59pJDC84Dab5Xp GoD6ZDiRK8jwKBm1qhMLX96i6VKXlrO/6K2kRp0jvAqLyVC3LsvvTjzAdTaDPm57H6Aa EWjWsh+45XKeOQTPjL2hpMKx8GZPir6tk9ug8iniITuek6f8HEwdIRo3gy9aapJh52UN 5XBhz63QyKWTbtVvZZyKzLJQKZFbxBLlY4kKId3ljk+hsOB+nBzfdCPvMtkhBmTJceFU JB1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=wp/cFSaqUx27cbG8PfuowEvaZnX1T1NgrzlKkdJ/buc=; b=Xs3fcNve0Pnvk2W5wblhYbARI3c/4CAHMaftuDasIOSdeC0y9yaYYbboSpvMsQE0rT usZf+y7MiT2AK7atQwSMCd98tqW6OVrq6yR/NLm1fd44fGH3q1Xb8j678DxUnGgpj5QS GtxFu03VT1tH2gb4kdpPthmov4lWazBO9xF1Ux/kJAHEaGWRbwDndo7TFgJH33EwbiFI eWVj7SefW2MLWgY6OEsBCWQsqFEBVFo2YTk7WmdFaOWTOInzgQNgoY+pJ+nDOIU9Fzhk Nt83cEY+8Yw0hgqlD9NL5pyNJaTKyZTWzZMCLwP2lnP1Vlj8ebXp2fHNL3uRdGrUp/uA N9Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VoZZTkDh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x61-v6si18233629plb.216.2018.09.03.01.22.45; Mon, 03 Sep 2018 01:22:45 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=VoZZTkDh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726029AbeICMlr (ORCPT + 5 others); Mon, 3 Sep 2018 08:41:47 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:41757 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725901AbeICMlr (ORCPT ); Mon, 3 Sep 2018 08:41:47 -0400 Received: by mail-lf1-f65.google.com with SMTP id l26-v6so14485988lfc.8 for ; Mon, 03 Sep 2018 01:22:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wp/cFSaqUx27cbG8PfuowEvaZnX1T1NgrzlKkdJ/buc=; b=VoZZTkDh2EFo6D0+eOd6yBo762G04Ze14eT1mifVLQCZUIvHhoCbCMIJYIbQ8VZ0IK Zu44KUf/H2ycPj8bJkyFJ2ppNGgXdtdx3di6z9Id9F6BhpSF15IQfpUW3OZL2eqQj5z9 HBmvkoyKZ00Irn2Wh+Hy0nzC4uNXF9P/rVwkA= 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:in-reply-to :references; bh=wp/cFSaqUx27cbG8PfuowEvaZnX1T1NgrzlKkdJ/buc=; b=KO/TXiqzk2+n7KvY0w8JX3PEqvdjLb+2OUjjvBOOyH4qgL61anhTvE3r3jdeTxnLhe QxdKq+RgJjkeVMGXVDVwK3yX4dSd9mHAeUMpHlqBC6b9g8+KXvuCXRaqgGesxt0WJ9se omvf/N/08qAbYyz86RHpiYZPgpl7uRiIQ/CsV9n4JoQzudjHiEkSArfeSs2Nj03bYCnF xcaO3a6aYSZJr4FlcNTIg508ZKnx1228H2nWazP2WCtcnIS0kpwR4o7/l4kKMUngwRcf KoZ7hAF6XzUat1XZTMjAUZU5R3yfY+3whbBZMnx4WR6GjpPOAODcisJ4U74vl53rPlO3 obfw== X-Gm-Message-State: APzg51AMGxPBN6V/P1hmfPLW8Em24xBweaZqf5WOvMWJoaVAsvvWAmI1 vHUpJq2EXScXDhhYRUzf100wsi3dOPfgxA== X-Received: by 2002:a19:9601:: with SMTP id y1-v6mr17404372lfd.91.1535962962545; Mon, 03 Sep 2018 01:22:42 -0700 (PDT) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id r70-v6sm3316035lff.0.2018.09.03.01.22.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Sep 2018 01:22:41 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org Cc: Linus Walleij , Tony Lindgren Subject: [PATCH 6/7] gpio: twl6040: Use bitops Date: Mon, 3 Sep 2018 10:15:55 +0200 Message-Id: <20180903081556.1411-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180903081556.1411-1-linus.walleij@linaro.org> References: <20180903081556.1411-1-linus.walleij@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org It's nice to use BIT() macros rather than open coding the same. It's good practice as sometimes people use BIT(31) and forget that the constant must be cast unsigned long. Cc: Tony Lindgren Signed-off-by: Linus Walleij --- drivers/gpio/gpio-twl6040.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c index c0c18c80abbd..77d50542bf61 100644 --- a/drivers/gpio/gpio-twl6040.c +++ b/drivers/gpio/gpio-twl6040.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -28,7 +29,7 @@ static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset) if (ret < 0) return ret; - return (ret >> offset) & 1; + return !!(ret & BIT(offset)); } static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset, @@ -49,9 +50,9 @@ static void twl6040gpo_set(struct gpio_chip *chip, unsigned offset, int value) return; if (value) - gpoctl = ret | (1 << offset); + gpoctl = ret | BIT(offset); else - gpoctl = ret & ~(1 << offset); + gpoctl = ret & ~BIT(offset); twl6040_reg_write(twl6040, TWL6040_REG_GPOCTL, gpoctl); }