From patchwork Mon Jun 10 17:10:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 166345 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1272921ilk; Mon, 10 Jun 2019 10:12:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVdgDvmppSLkXVnEwFaWt3w+1VVwuLKmTdWeUL11rlhz8aXvSqdLE8/SVCFFkNJNS+UY6O X-Received: by 2002:aa7:80d9:: with SMTP id a25mr74963147pfn.50.1560186751404; Mon, 10 Jun 2019 10:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560186751; cv=none; d=google.com; s=arc-20160816; b=USBuoMhwTQsXzOQoiIuepGyNBK4V5Mz2PnYm/5/qmCBFwE1l6q37mKxHQynXQRRe0k +77gFmomcwfIskh5JsgwZ/Hw0UzbrzWeuSkdNZg/RORlXo8dGs8bJcTzGtq7EIgu19BP E5GOwWpTFe3c5K40OuxRmTe/1Mlefvad096Us/nq50177dpKg++2HChBTVu7EPEGuYI1 tXT5Q7uvrakCqw4rkwr3pB5dUEOPZGya+ZfrZOz2K+IJ0Kghfly7Wfjzyd2sI6ZX5ChG RNvN1Y+i6+5fB+ES8uXf4TuN9OtcgWq9CFZ/ihQAMO97W38u2xQif11J+2YNbBi35HWr TIcw== 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=mRBjHVSGVjmh06j3YRgbF6k6lDaugFDHiLDKP+4u0kM=; b=DuJD6IE8eqO4bvK2wTyVLGsXC3BZr4ikMs5t2vRlD2nSX/DSTVcQwDteA9a0q75ZC5 L0HGgHO6HDCe0CfOStinc7w3Wl0DPPMIfETu1MJRc3WTtHkKq0tRySab8+uhmHRwOAUi 6WpKL4Ag82CCc1t9OizpQod/UsqY5dVZCyzaQmxIxjxGJWYMug3Zz2myPPwKszVHKwQe ZTfaTbqmyb/kylYiUyjtEgbT89dCjyvd8w6YA/GBEe0LDjqoYgrjWgDm9SQZRq9qPfyw l/I8JCmVrnpOrpTC53k7xs1sDrCR80nzWJUMQrVP6Ti/sJ7KvpK7cU9afFyNwDYDegUB M3Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=mANGvUlk; 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 a17si21913pjq.31.2019.06.10.10.12.31; Mon, 10 Jun 2019 10:12:31 -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=mANGvUlk; 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 S2388339AbfFJRM3 (ORCPT + 30 others); Mon, 10 Jun 2019 13:12:29 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:44446 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387898AbfFJRM0 (ORCPT ); Mon, 10 Jun 2019 13:12:26 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x5AHCG0p121555; Mon, 10 Jun 2019 12:12:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1560186736; bh=mRBjHVSGVjmh06j3YRgbF6k6lDaugFDHiLDKP+4u0kM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=mANGvUlk0EVPNp5Z1gQWmbIavoQghIE9hfDvbe6QKk8UJS37FVmxLbZBaogKEF9eJ ZfZRJ9iO1WmCHcOICvLc3rw4UQnM267VHI9znNJZZUYZkARaPl4OBHVU8xckyiEdm9 vlFM1zrhv0fmwAfPxn8qYMkqu6Oc6DezuHGewRD0= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x5AHCGXe011053 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 10 Jun 2019 12:12:16 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE109.ent.ti.com (157.170.170.41) 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:12 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE104.ent.ti.com (157.170.170.34) 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:12 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x5AHCBGW051427; Mon, 10 Jun 2019 12:12:11 -0500 From: Grygorii Strashko To: Russell King , Linus Walleij , Tony Lindgren CC: Bartosz Golaszewski , , , , Santosh Shilimkar , Russell King , Grygorii Strashko Subject: [PATCH-next 09/20] gpio: gpio-omap: simplify get_multiple() Date: Mon, 10 Jun 2019 20:10:52 +0300 Message-ID: <20190610171103.30903-10-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 There is no reason to have helper functions to read the datain and dataout registers when they are only used in one location. Simplify this code to make it more readable. Signed-off-by: Russell King Signed-off-by: Grygorii Strashko --- drivers/gpio/gpio-omap.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) -- 2.17.1 diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index bf1e6f1d0de7..a26decc5c611 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -175,22 +175,6 @@ static void omap_set_gpio_dataout_mask_multiple(struct gpio_bank *bank, bank->context.dataout = l; } -static unsigned long omap_get_gpio_datain_multiple(struct gpio_bank *bank, - unsigned long *mask) -{ - void __iomem *reg = bank->base + bank->regs->datain; - - return readl_relaxed(reg) & *mask; -} - -static unsigned long omap_get_gpio_dataout_multiple(struct gpio_bank *bank, - unsigned long *mask) -{ - void __iomem *reg = bank->base + bank->regs->dataout; - - return readl_relaxed(reg) & *mask; -} - static inline void omap_gpio_rmw(void __iomem *base, u32 reg, u32 mask, bool set) { int l = readl_relaxed(base + reg); @@ -987,18 +971,20 @@ static int omap_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask, unsigned long *bits) { struct gpio_bank *bank = gpiochip_get_data(chip); - void __iomem *reg = bank->base + bank->regs->direction; - unsigned long in = readl_relaxed(reg), l; + void __iomem *base = bank->base; + u32 direction, m, val = 0; + + direction = readl_relaxed(base + bank->regs->direction); - *bits = 0; + m = direction & *mask; + if (m) + val |= readl_relaxed(base + bank->regs->datain) & m; - l = in & *mask; - if (l) - *bits |= omap_get_gpio_datain_multiple(bank, &l); + m = ~direction & *mask; + if (m) + val |= readl_relaxed(base + bank->regs->dataout) & m; - l = ~in & *mask; - if (l) - *bits |= omap_get_gpio_dataout_multiple(bank, &l); + *bits = val; return 0; }