From patchwork Wed Aug 22 20:41:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 144859 Delivered-To: patch@linaro.org Received: by 2002:a2e:164a:0:0:0:0:0 with SMTP id 10-v6csp401676ljw; Wed, 22 Aug 2018 13:41:42 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb667bZV3HqRbijFfaecBk95sH7THWmyRkeqFNzDyFGVK4jnwPZ/8khPC9cg/o97brra0Uc X-Received: by 2002:a62:808c:: with SMTP id j134-v6mr8186747pfd.120.1534970502602; Wed, 22 Aug 2018 13:41:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534970502; cv=none; d=google.com; s=arc-20160816; b=H3yQ4Ly7tw4kHF5hRh5LY14U1h0aRJ/LGFvHBx07hv0DIzXzjKu4Jdtnx+HrpXAiDF EKbwB72SCkc0uTjILOihgXglpPFoGUupz/u0YRd+ZP63MyvAq6c4YF/wR4FH6vSA3ntA Zgey/IlMKcLXLF88dRPpfq5jwAVhhFJLFSmHz9jRQKO3yFX4LLK1Pw4lc+kW8IqrzlvT GqWejCZ3jk/JSIThJ5I0S3c+/icaAhDK58VBRabuAiNBtXiAY9xlsYOVRXRign3RChjx zWjPbHJqzqrhZEK/QaKYkm55dF+pzG1oDC3w45kWTlQbihg/cbcBRxWYBUR41Ha9+LTD wjxw== 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=5jyCrEmH3jOgnJsJFUlr60/lZCJAbMRBBSgurEP30XM=; b=cK53o/xUfrvCdJaIRklnDHtw9LKOf6LnHgeUV1pztLBTb9+AsZbhFJHyffpvJ/2vmS 32/y3MHslzN0tHUQVO2e5oHFQHKeVxq5AOdO3tDPJbpioMYAawFg/nHa52Dcuug9YlL2 nD0whfB6Ypa0slLG0kTsgZNM2BGBf/E424/sgBPUEwr5oAel3YPjcsGkvgPNsyP8T5n2 W95WA0Dwb0NANaHOSlUranMFQsSyRE8ipGN11VawghT+2EBoWwxViFn9hVIqLpmqbPQJ zQ8A2XSuNQ3LgRt8Mjr3GbV1S2RzkmYMU5xjZfZs/4JIJxlFF8KCSiR+hfRDn2LQSRdv K4ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TCMv3sVD; 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 t23-v6si2559068pgi.301.2018.08.22.13.41.42; Wed, 22 Aug 2018 13:41:42 -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=TCMv3sVD; 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 S1727499AbeHWAIF (ORCPT + 5 others); Wed, 22 Aug 2018 20:08:05 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:46189 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727395AbeHWAIF (ORCPT ); Wed, 22 Aug 2018 20:08:05 -0400 Received: by mail-lf1-f66.google.com with SMTP id e23-v6so2370180lfc.13 for ; Wed, 22 Aug 2018 13:41:40 -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=5jyCrEmH3jOgnJsJFUlr60/lZCJAbMRBBSgurEP30XM=; b=TCMv3sVDKGfy8VDf6PYFdYN4ITslozXIzuuYU7BPCy9WrQ6tceXUz9xeTajtpIZ0+Q /MbdyrFaAP93uP5U9goS+mfySSlehmkQLTvGuDcJewFveArJdt5JQzSmu0R6mTMUb6Go TACzAchTt6lU/4Gyz24YD++252DVAet+pjlWQ= 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=5jyCrEmH3jOgnJsJFUlr60/lZCJAbMRBBSgurEP30XM=; b=ATDzVN4PCb5Js+Ao6/5BQbJvyCDgdVkfQ4hzPKRSWaG+yhzeYS6SWxwHmKxf9+pj9a Kt1/i34iLU4tPDIU+RBnHK9y6G2H6QP1VwwhosGdWUnXkPDQjdozHOh7DlYo9gIVxTEZ XzWyM4iHp7h6/EHIOXcHWQ3+Fs7WDJdYRnLPAihRLP61akq7Dw9BD9O5js0EsnAzk/5X m/qKP3aR2jkUf2Y2VasMazO7tEWd2e2VRnroZ9WN/dvVkciKwJuQGU9AwuPsaDl6JG+f PObOKrLQuuEtKNp/3OJukKmsgUeqthw3KCC0VpZRKjliA+FjU3u7HBvoFo5aHVFA+V59 D4sw== X-Gm-Message-State: AOUpUlH2twsk/0mcndkt5dsn1tHNivkNneBNAXDYSS6kqSBMvjhianRj XVXHjIw9lVPwLxg+iMhEhCx3cg== X-Received: by 2002:a19:c5:: with SMTP id 188-v6mr17605146lfa.45.1534970499762; Wed, 22 Aug 2018 13:41:39 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id q128-v6sm431515ljq.72.2018.08.22.13.41.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Aug 2018 13:41:38 -0700 (PDT) From: Linus Walleij To: H Hartley Sweeten , Alexander Sverdlin Cc: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, Linus Walleij Subject: [PATCH 08/11] gpio: ep93xx: Use the hwirq and port Date: Wed, 22 Aug 2018 22:41:08 +0200 Message-Id: <20180822204111.9581-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180822204111.9581-1-linus.walleij@linaro.org> References: <20180822204111.9581-1-linus.walleij@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org In the IRQ-related functions, switch to using the hwirq and port number found from the current struct gpio_chip * As the lower 3 bits of the IRQ number is identical to the lower 3 bits of the GPIO number we can cut some corners. Call directly into the gpiochip to set up the direction and read the input instead of using the consumer API. This enabled us to cut the confusing irq_to_gpio() macro that is a remnant of the old generic GPIO API as well. Signed-off-by: Linus Walleij --- drivers/gpio/gpio-ep93xx.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) -- 2.17.1 diff --git a/drivers/gpio/gpio-ep93xx.c b/drivers/gpio/gpio-ep93xx.c index 3b235b25c028..b2139ec43ce2 100644 --- a/drivers/gpio/gpio-ep93xx.c +++ b/drivers/gpio/gpio-ep93xx.c @@ -16,11 +16,10 @@ #include #include #include +#include /* FIXME: this is here for gpio_to_irq() - get rid of this! */ #include -#define irq_to_gpio(irq) ((irq) - gpio_to_irq(0)) - #define EP93XX_GPIO_F_INT_STATUS 0x5c #define EP93XX_GPIO_A_INT_STATUS 0xa0 #define EP93XX_GPIO_B_INT_STATUS 0xbc @@ -151,9 +150,8 @@ static void ep93xx_gpio_irq_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct ep93xx_gpio *epg = gpiochip_get_data(gc); - int line = irq_to_gpio(d->irq); - int port = line >> 3; - int port_mask = 1 << (line & 7); + int port = ep93xx_gpio_port(gc); + int port_mask = BIT(d->irq & 7); if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) { gpio_int_type2[port] ^= port_mask; /* switch edge direction */ @@ -167,9 +165,8 @@ static void ep93xx_gpio_irq_mask_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct ep93xx_gpio *epg = gpiochip_get_data(gc); - int line = irq_to_gpio(d->irq); - int port = line >> 3; - int port_mask = 1 << (line & 7); + int port = ep93xx_gpio_port(gc); + int port_mask = BIT(d->irq & 7); if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) gpio_int_type2[port] ^= port_mask; /* switch edge direction */ @@ -184,10 +181,9 @@ static void ep93xx_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct ep93xx_gpio *epg = gpiochip_get_data(gc); - int line = irq_to_gpio(d->irq); - int port = line >> 3; + int port = ep93xx_gpio_port(gc); - gpio_int_unmasked[port] &= ~(1 << (line & 7)); + gpio_int_unmasked[port] &= ~BIT(d->irq & 7); ep93xx_gpio_update_int_params(epg, port); } @@ -195,10 +191,9 @@ static void ep93xx_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct ep93xx_gpio *epg = gpiochip_get_data(gc); - int line = irq_to_gpio(d->irq); - int port = line >> 3; + int port = ep93xx_gpio_port(gc); - gpio_int_unmasked[port] |= 1 << (line & 7); + gpio_int_unmasked[port] |= BIT(d->irq & 7); ep93xx_gpio_update_int_params(epg, port); } @@ -211,12 +206,12 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct ep93xx_gpio *epg = gpiochip_get_data(gc); - const int gpio = irq_to_gpio(d->irq); - const int port = gpio >> 3; - const int port_mask = 1 << (gpio & 7); + int port = ep93xx_gpio_port(gc); + int offset = d->irq & 7; + int port_mask = BIT(offset); irq_flow_handler_t handler; - gpio_direction_input(gpio); + gc->direction_input(gc, offset); switch (type) { case IRQ_TYPE_EDGE_RISING: @@ -242,7 +237,7 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type) case IRQ_TYPE_EDGE_BOTH: gpio_int_type1[port] |= port_mask; /* set initial polarity based on current input level */ - if (gpio_get_value(gpio)) + if (gc->get(gc, offset)) gpio_int_type2[port] &= ~port_mask; /* falling */ else gpio_int_type2[port] |= port_mask; /* rising */