From patchwork Mon Jun 10 17:10:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 166348 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1273379ilk; Mon, 10 Jun 2019 10:12:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOBdIrCaU1bJJ1Y+e5KHbx35dvmnDb9QCYxEDtlA5aZZx+DH35i/15/aDKryidB9ylS+LF X-Received: by 2002:a17:902:9a06:: with SMTP id v6mr54129108plp.71.1560186771872; Mon, 10 Jun 2019 10:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560186771; cv=none; d=google.com; s=arc-20160816; b=MunyVN98oye8jr06odIza84HFyA6THBQjfnr+TAzuWbhwbPAfV6kXlM7NW9ZlyCDAc BFN2FKf1szblmAZXmX//YRQIrhW5vGnjtwfu4eLGE76+Gz9ILFWFxu55vHOedVLEkr2b 5qyoHeIDzOB/32I6rRAwapuVgHgcNfj/NhMPkmrkdv2hrKPRKCwoIU0fRC3CJrKFmL33 X6f806tGIPfjUmPzOXxa1T9vcA/GHDf4DJb2hZ8ZMJvHyn6CpjcVzBe6QvOr1sEOcyA7 6/tiM/KQHUvzRAo3vJ0AY1VPoiFibpnaMa2eZSs/5D6P6yz7X0PCc0Dx/9CPWW9EosJC gh1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=E2VsaT4+Yu4S9xAGSUBcnO1WYenuJ5B2QhgSL4vZl1M=; b=tqqIyzKOe4UQefUI/MmzN43XNacPMcqP3ET963MdtZ6JtcnHljC31BDceBpNlLtF0b 4FDWyCYnaw91iCADCK/tpDGUa0AJ0WIwfya3J7S2hpPWGHYYVvIacXuwfIRQ+oUAacDm OVhdOIIJc9nogzvXTH7gq2230ySaHvfAHsUt3tBARuU2k0Rwb0a0s7jvWEBumZw8yrCn H8jbHNTZRYXmy6axTMvkUdtflrXgd5Dp1dqEAqUs6yq/B1WfkHSOIUGgU9AD4QDy1Imb y2vubG7/rIUZPUjG3yS1RYRHyy1VK4fVbwb37P5ZXVymhnBLAuOlOTsYzMWkcdhTlTij McwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=aZVQyZpJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z34si5242842pgl.240.2019.06.10.10.12.51; Mon, 10 Jun 2019 10:12:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@ti.com header.s=ti-com-17Q1 header.b=aZVQyZpJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388521AbfFJRMv (ORCPT + 30 others); Mon, 10 Jun 2019 13:12:51 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:47490 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388374AbfFJRMt (ORCPT ); Mon, 10 Jun 2019 13:12:49 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x5AHCd4r069377; Mon, 10 Jun 2019 12:12:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1560186759; bh=E2VsaT4+Yu4S9xAGSUBcnO1WYenuJ5B2QhgSL4vZl1M=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=aZVQyZpJnzqXNlu95UrXSUjdES47+TJg7maxYlHxoB9U4kdBeb5P8eWYC6tfhe1sc 76JE45pFEcAh1LvwKKEbVDG2gcmIEctWBkWHMEZtwUzmqG0WL3Q0NsgIcvinCpBUgf IrLoDkLM1Ec4el5kTTZDnSiSsTpS9kryNJP5FZac= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x5AHCde2080910 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 10 Jun 2019 12:12:39 -0500 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 10 Jun 2019 12:12:39 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Mon, 10 Jun 2019 12:12:39 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x5AHCcbS039651; Mon, 10 Jun 2019 12:12:38 -0500 From: Grygorii Strashko To: Russell King , Linus Walleij , Tony Lindgren CC: Bartosz Golaszewski , , , , Santosh Shilimkar , Russell King , Grygorii Strashko Subject: [PATCH-next 13/20] gpio: gpio-omap: simplify omap_toggle_gpio_edge_triggering() Date: Mon, 10 Jun 2019 20:10:56 +0300 Message-ID: <20190610171103.30903-14-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190610171103.30903-1-grygorii.strashko@ti.com> References: <20190610171103.30903-1-grygorii.strashko@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Russell King This function open-codes an exclusive-or bitwise operation using an if() statement and explicitly setting or clearing the bit. Instead, use an exclusive-or operation instead, and simplify the function. We can combine the preprocessor conditional using IS_ENABLED() and gain some additional compilation coverage. Signed-off-by: Russell King Signed-off-by: Grygorii Strashko --- drivers/gpio/gpio-omap.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) -- 2.17.1 diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 1a0890586b45..097ed8d1a117 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -326,32 +326,18 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio, } } -#ifdef CONFIG_ARCH_OMAP1 /* * This only applies to chips that can't do both rising and falling edge * detection at once. For all other chips, this function is a noop. */ static void omap_toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio) { - void __iomem *reg = bank->base; - u32 l = 0; - - if (!bank->regs->irqctrl) - return; - - reg += bank->regs->irqctrl; + if (IS_ENABLED(CONFIG_ARCH_OMAP1) && bank->regs->irqctrl) { + void __iomem *reg = bank->base + bank->regs->irqctrl; - l = readl_relaxed(reg); - if ((l >> gpio) & 1) - l &= ~(BIT(gpio)); - else - l |= BIT(gpio); - - writel_relaxed(l, reg); + writel_relaxed(readl_relaxed(reg) ^ BIT(gpio), reg); + } } -#else -static void omap_toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio) {} -#endif static int omap_set_gpio_triggering(struct gpio_bank *bank, int gpio, unsigned trigger)