From patchwork Mon Aug 27 13:06:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 962509 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xs4all.nl Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41zXFy6pRDz9s47 for ; Mon, 27 Aug 2018 23:06:30 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726925AbeH0Qw7 (ORCPT ); Mon, 27 Aug 2018 12:52:59 -0400 Received: from lb1-smtp-cloud9.xs4all.net ([194.109.24.22]:47193 "EHLO lb1-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726918AbeH0Qw7 (ORCPT ); Mon, 27 Aug 2018 12:52:59 -0400 Received: from marune.fritz.box ([IPv6:2001:983:e9a7:1:8960:b49d:3b62:6d25]) by smtp-cloud9.xs4all.net with ESMTPA id uHDofV4VjEJtcuHDqfnRip; Mon, 27 Aug 2018 15:06:22 +0200 From: Hans Verkuil To: linux-gpio@vger.kernel.org Cc: ilina@codeaurora.org, Linus Walleij , Marc Zyngier , Thomas Gleixner , Hans Verkuil Subject: [RFCv2 PATCH 1/4] gpiolib: (un)mark gpio as irq when dis/enabling irq Date: Mon, 27 Aug 2018 15:06:17 +0200 Message-Id: <20180827130620.96232-2-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180827130620.96232-1-hverkuil@xs4all.nl> References: <20180827130620.96232-1-hverkuil@xs4all.nl> X-CMAE-Envelope: MS4wfO0raWBMx02USSDv/JqPqS7bcm3Rr6OCpQnW8nW8piE15X1Gh0u7ABltXer0mfiGN+DguwlxufnCq0bWeqVASJPlk9RKOOiI4CJJ9wnxH/9AzM5+yjjr oc1py9rg9XZfHyUI9n0V9uG9cBPK52Zjq8T7UkZPqGw1cjFwas1wff9kwF7rmUl1I0rxZ4VQ1Jhnxilqh6PLWNEawbtKHpfQ2kEuszJpV8Zpyp9zVYWUeRnf WsIk7mzwS6jXSTBT5h76umfe6Je6F6Pa88Y7/NlFW0CuoaoyfFQuVd87FaehxNjq8neyhcIaUNXRrw1WuBOPsSibsw1yEMaLkPh1bMEfi01yg8h5V7rEM9EJ BFpODkgEPTVd/DpKMHUaO6nAnr2gB0loHdyvRvnRKJ1CMQCtt+lW6EPiUvDJQIfPsWwT+ixP Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Hans Verkuil Drivers are currently required to call gpiochip_(un)lock_as_irq whenever they want to use a gpio as an interrupt. Unfortunately, this is generally done when the irq is requested, not when the irq is enabled/disabled. This is problematic for cases where a gpio pin is temporarily used as an interrupt pin, then, after the irq is disabled, is used as a regular gpio pin again. Currently it is not possible to do this other than by first freeing the interrupt so gpiochip_unlock_as_irq is called. There are currently two drivers that would like to be able to do this: the tda998x_drv.c driver where a regular gpio pin needs to be temporarily reconfigured as an interrupt pin during CEC calibration, and the cec-gpio driver where you want to configure the gpio pin as an interrupt while waiting for traffic over the CEC bus, or as a regular pin when receiving or transmitting a CEC message. The core problem is that gpiochip_(un)lock_as_irq is called when the interrupt is allocated/freed, not when the interrupt is enabled/disabled. Also, it is hit-and-miss whether drivers call these functions. This patch hooks gpiochip_irq_(un)lock into the irq_enable/disable callbacks of the irqchip. That way drivers no longer have to call these functions and this is all done transparently for drivers. The old gpiochip_(un)lock_as_irq() functions are now empty stubs that can be removed once all drivers that call them are updated. Signed-off-by: Hans Verkuil --- drivers/gpio/gpiolib.c | 155 +++++++++++++++++++++++++++--------- include/linux/gpio/driver.h | 7 ++ 2 files changed, 123 insertions(+), 39 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e8f8a1999393..0efa9ec4fec4 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -86,6 +86,8 @@ static int gpiochip_add_irqchip(struct gpio_chip *gpiochip, static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip); static int gpiochip_irqchip_init_valid_mask(struct gpio_chip *gpiochip); static void gpiochip_irqchip_free_valid_mask(struct gpio_chip *gpiochip); +static int gpiochip_irq_lock(struct gpio_chip *chip, unsigned int offset); +static void gpiochip_irq_unlock(struct gpio_chip *chip, unsigned int offset); static bool gpiolib_initialized; @@ -1807,30 +1809,65 @@ static const struct irq_domain_ops gpiochip_domain_ops = { static int gpiochip_irq_reqres(struct irq_data *d) { struct gpio_chip *chip = irq_data_get_irq_chip_data(d); - int ret; + int ret = 0; if (!try_module_get(chip->gpiodev->owner)) return -ENODEV; - ret = gpiochip_lock_as_irq(chip, d->hwirq); - if (ret) { - chip_err(chip, - "unable to lock HW IRQ %lu for IRQ\n", - d->hwirq); + if (chip->irq.irq_request_resources) + ret = chip->irq.irq_request_resources(d); + if (ret) module_put(chip->gpiodev->owner); - return ret; - } - return 0; + return ret; } static void gpiochip_irq_relres(struct irq_data *d) { struct gpio_chip *chip = irq_data_get_irq_chip_data(d); - gpiochip_unlock_as_irq(chip, d->hwirq); + if (chip->irq.irq_release_resources) + chip->irq.irq_release_resources(d); module_put(chip->gpiodev->owner); } +static unsigned int gpiochip_irq_startup(struct irq_data *d) +{ + struct gpio_chip *chip = irq_data_get_irq_chip_data(d); + + WARN_ON(gpiochip_irq_lock(chip, d->hwirq)); + return chip->irq.irq_startup(d); +} + +static void gpiochip_irq_shutdown(struct irq_data *d) +{ + struct gpio_chip *chip = irq_data_get_irq_chip_data(d); + + gpiochip_irq_unlock(chip, d->hwirq); + chip->irq.irq_shutdown(d); +} + +static void gpiochip_irq_enable(struct irq_data *d) +{ + struct gpio_chip *chip = irq_data_get_irq_chip_data(d); + + WARN_ON(gpiochip_irq_lock(chip, d->hwirq)); + if (chip->irq.irq_enable) + chip->irq.irq_enable(d); + else + chip->irq.chip->irq_unmask(d); +} + +static void gpiochip_irq_disable(struct irq_data *d) +{ + struct gpio_chip *chip = irq_data_get_irq_chip_data(d); + + gpiochip_irq_unlock(chip, d->hwirq); + if (chip->irq.irq_disable) + chip->irq.irq_disable(d); + else + chip->irq.chip->irq_mask(d); +} + static int gpiochip_to_irq(struct gpio_chip *chip, unsigned offset) { if (!gpiochip_irqchip_irq_valid(chip, offset)) @@ -1839,6 +1876,33 @@ static int gpiochip_to_irq(struct gpio_chip *chip, unsigned offset) return irq_create_mapping(chip->irq.domain, offset); } +static void gpiochip_set_irq_hooks(struct gpio_chip *gpiochip) +{ + struct irq_chip *irqchip = gpiochip->irq.chip; + + if (irqchip->irq_request_resources == gpiochip_irq_reqres) + return; + + gpiochip->irq.irq_request_resources = irqchip->irq_request_resources; + gpiochip->irq.irq_release_resources = irqchip->irq_release_resources; + gpiochip->irq.irq_enable = irqchip->irq_enable; + gpiochip->irq.irq_disable = irqchip->irq_disable; + + irqchip->irq_request_resources = gpiochip_irq_reqres; + irqchip->irq_release_resources = gpiochip_irq_relres; + irqchip->irq_enable = gpiochip_irq_enable; + irqchip->irq_disable = gpiochip_irq_disable; + + if (irqchip->irq_startup) { + gpiochip->irq.irq_startup = irqchip->irq_startup; + irqchip->irq_startup = gpiochip_irq_startup; + } + if (irqchip->irq_shutdown) { + gpiochip->irq.irq_shutdown = irqchip->irq_shutdown; + irqchip->irq_shutdown = gpiochip_irq_shutdown; + } +} + /** * gpiochip_add_irqchip() - adds an IRQ chip to a GPIO chip * @gpiochip: the GPIO chip to add the IRQ chip to @@ -1897,16 +1961,6 @@ static int gpiochip_add_irqchip(struct gpio_chip *gpiochip, if (!gpiochip->irq.domain) return -EINVAL; - /* - * It is possible for a driver to override this, but only if the - * alternative functions are both implemented. - */ - if (!irqchip->irq_request_resources && - !irqchip->irq_release_resources) { - irqchip->irq_request_resources = gpiochip_irq_reqres; - irqchip->irq_release_resources = gpiochip_irq_relres; - } - if (gpiochip->irq.parent_handler) { void *data = gpiochip->irq.parent_handler_data ?: gpiochip; @@ -1922,6 +1976,8 @@ static int gpiochip_add_irqchip(struct gpio_chip *gpiochip, } } + gpiochip_set_irq_hooks(gpiochip); + acpi_gpiochip_request_interrupts(gpiochip); return 0; @@ -1935,11 +1991,12 @@ static int gpiochip_add_irqchip(struct gpio_chip *gpiochip, */ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip) { + struct irq_chip *irqchip = gpiochip->irq.chip; unsigned int offset; acpi_gpiochip_free_interrupts(gpiochip); - if (gpiochip->irq.chip && gpiochip->irq.parent_handler) { + if (irqchip && gpiochip->irq.parent_handler) { struct gpio_irq_chip *irq = &gpiochip->irq; unsigned int i; @@ -1963,11 +2020,26 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip) irq_domain_remove(gpiochip->irq.domain); } - if (gpiochip->irq.chip) { - gpiochip->irq.chip->irq_request_resources = NULL; - gpiochip->irq.chip->irq_release_resources = NULL; - gpiochip->irq.chip = NULL; + if (irqchip && + irqchip->irq_request_resources == gpiochip_irq_reqres) { + irqchip->irq_request_resources = + gpiochip->irq.irq_request_resources; + irqchip->irq_release_resources = + gpiochip->irq.irq_release_resources; + irqchip->irq_enable = gpiochip->irq.irq_enable; + irqchip->irq_disable = gpiochip->irq.irq_disable; + if (gpiochip->irq.irq_startup) + irqchip->irq_startup = gpiochip->irq.irq_startup; + if (gpiochip->irq.irq_shutdown) + irqchip->irq_shutdown = gpiochip->irq.irq_shutdown; } + gpiochip->irq.irq_request_resources = NULL; + gpiochip->irq.irq_release_resources = NULL; + gpiochip->irq.irq_startup = NULL; + gpiochip->irq.irq_shutdown = NULL; + gpiochip->irq.irq_enable = NULL; + gpiochip->irq.irq_disable = NULL; + gpiochip->irq.chip = NULL; gpiochip_irqchip_free_valid_mask(gpiochip); } @@ -2056,15 +2128,7 @@ int gpiochip_irqchip_add_key(struct gpio_chip *gpiochip, return -EINVAL; } - /* - * It is possible for a driver to override this, but only if the - * alternative functions are both implemented. - */ - if (!irqchip->irq_request_resources && - !irqchip->irq_release_resources) { - irqchip->irq_request_resources = gpiochip_irq_reqres; - irqchip->irq_release_resources = gpiochip_irq_relres; - } + gpiochip_set_irq_hooks(gpiochip); acpi_gpiochip_request_interrupts(gpiochip); @@ -3255,14 +3319,14 @@ int gpiod_to_irq(const struct gpio_desc *desc) EXPORT_SYMBOL_GPL(gpiod_to_irq); /** - * gpiochip_lock_as_irq() - lock a GPIO to be used as IRQ + * gpiochip_irq_lock() - lock a GPIO to be used as IRQ * @chip: the chip the GPIO to lock belongs to * @offset: the offset of the GPIO to lock as IRQ * * This is used directly by GPIO drivers that want to lock down * a certain GPIO line to be used for IRQs. */ -int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset) +static int gpiochip_irq_lock(struct gpio_chip *chip, unsigned int offset) { struct gpio_desc *desc; @@ -3303,17 +3367,16 @@ int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset) return 0; } -EXPORT_SYMBOL_GPL(gpiochip_lock_as_irq); /** - * gpiochip_unlock_as_irq() - unlock a GPIO used as IRQ + * gpiochip_irq_unlock() - unlock a GPIO used as IRQ * @chip: the chip the GPIO to lock belongs to * @offset: the offset of the GPIO to lock as IRQ * * This is used directly by GPIO drivers that want to indicate * that a certain GPIO is no longer used exclusively for IRQ. */ -void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset) +static void gpiochip_irq_unlock(struct gpio_chip *chip, unsigned int offset) { struct gpio_desc *desc; @@ -3327,6 +3390,20 @@ void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset) if (desc->label && !strcmp(desc->label, "interrupt")) desc_set_label(desc, NULL); } + +/* + * Keep these two temporary stubs until all drivers stop calling these + * functions. + */ +int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset) +{ + return 0; +} +EXPORT_SYMBOL_GPL(gpiochip_lock_as_irq); + +void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset) +{ +} EXPORT_SYMBOL_GPL(gpiochip_unlock_as_irq); bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 0ea328e71ec9..0485bd339178 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -138,6 +138,13 @@ struct gpio_irq_chip { * will allocate and map all IRQs during initialization. */ unsigned int first; + + int (*irq_request_resources)(struct irq_data *data); + void (*irq_release_resources)(struct irq_data *data); + unsigned int (*irq_startup)(struct irq_data *data); + void (*irq_shutdown)(struct irq_data *data); + void (*irq_enable)(struct irq_data *data); + void (*irq_disable)(struct irq_data *data); }; static inline struct gpio_irq_chip *to_gpio_irq_chip(struct irq_chip *chip) From patchwork Mon Aug 27 13:06:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 962508 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xs4all.nl Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41zXFx1Sccz9s2P for ; Mon, 27 Aug 2018 23:06:29 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726883AbeH0Qw7 (ORCPT ); Mon, 27 Aug 2018 12:52:59 -0400 Received: from lb1-smtp-cloud9.xs4all.net ([194.109.24.22]:36082 "EHLO lb1-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726931AbeH0Qw7 (ORCPT ); Mon, 27 Aug 2018 12:52:59 -0400 Received: from marune.fritz.box ([IPv6:2001:983:e9a7:1:8960:b49d:3b62:6d25]) by smtp-cloud9.xs4all.net with ESMTPA id uHDofV4VjEJtcuHDqfnRix; Mon, 27 Aug 2018 15:06:22 +0200 From: Hans Verkuil To: linux-gpio@vger.kernel.org Cc: ilina@codeaurora.org, Linus Walleij , Marc Zyngier , Thomas Gleixner , Hans Verkuil Subject: [RFCv2 PATCH 2/4] gpio: remove gpiochip_(un)lock_as_irq() from drivers Date: Mon, 27 Aug 2018 15:06:18 +0200 Message-Id: <20180827130620.96232-3-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180827130620.96232-1-hverkuil@xs4all.nl> References: <20180827130620.96232-1-hverkuil@xs4all.nl> X-CMAE-Envelope: MS4wfO0raWBMx02USSDv/JqPqS7bcm3Rr6OCpQnW8nW8piE15X1Gh0u7ABltXer0mfiGN+DguwlxufnCq0bWeqVASJPlk9RKOOiI4CJJ9wnxH/9AzM5+yjjr oc1py9rg9XZfHyUI9n0V9uG9cBPK52Zjq8T7UkZPqGw1cjFwas1wff9kwF7rmUl1I0rxZ4VQ1Jhnxilqh6PLWNEawbtKHpfQ2kEuszJpV8Zpyp9zVYWUeRnf WsIk7mzwS6jXSTBT5h76umfe6Je6F6Pa88Y7/NlFW0CuoaoyfFQuVd87FaehxNjq8neyhcIaUNXRrw1WuBOPsSibsw1yEMaLkPh1bMEfi01yg8h5V7rEM9EJ BFpODkgEPTVd/DpKMHUaO6nAnr2gB0loHdyvRvnRKJ1CMQCtt+lW6EPiUvDJQIfPsWwT+ixP Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Hans Verkuil Remove all calls to gpiochip_(un)lock_as_irq from drivers as this is now done by gpiolib. Signed-off-by: Hans Verkuil --- drivers/gpio/gpio-bcm-kona.c | 24 ------------------ drivers/gpio/gpio-dwapb.c | 27 -------------------- drivers/gpio/gpio-em.c | 24 ------------------ drivers/gpio/gpio-tegra.c | 19 -------------- drivers/gpio/gpio-thunderx.c | 15 +++-------- drivers/gpio/gpio-uniphier.c | 20 --------------- drivers/gpio/gpio-vr41xx.c | 11 -------- drivers/gpio/gpio-xgene-sb.c | 10 -------- drivers/gpio/gpiolib-acpi.c | 13 ++-------- drivers/gpio/gpiolib-sysfs.c | 18 +------------ drivers/hid/hid-cp2112.c | 14 ++--------- drivers/pinctrl/intel/pinctrl-intel.c | 32 ------------------------ drivers/pinctrl/mediatek/mtk-eint.c | 9 ------- drivers/pinctrl/pinctrl-st.c | 10 +------- drivers/pinctrl/samsung/pinctrl-exynos.c | 10 -------- drivers/pinctrl/stm32/pinctrl-stm32.c | 16 ------------ drivers/pinctrl/sunxi/pinctrl-sunxi.c | 19 -------------- 17 files changed, 9 insertions(+), 282 deletions(-) diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c index d0707fc23afd..40afd1f39989 100644 --- a/drivers/gpio/gpio-bcm-kona.c +++ b/drivers/gpio/gpio-bcm-kona.c @@ -482,36 +482,12 @@ static void bcm_kona_gpio_irq_handler(struct irq_desc *desc) chained_irq_exit(chip, desc); } -static int bcm_kona_gpio_irq_reqres(struct irq_data *d) -{ - struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); - int ret; - - ret = gpiochip_lock_as_irq(&kona_gpio->gpio_chip, d->hwirq); - if (ret) { - dev_err(kona_gpio->gpio_chip.parent, - "unable to lock HW IRQ %lu for IRQ\n", - d->hwirq); - return ret; - } - return 0; -} - -static void bcm_kona_gpio_irq_relres(struct irq_data *d) -{ - struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); - - gpiochip_unlock_as_irq(&kona_gpio->gpio_chip, d->hwirq); -} - static struct irq_chip bcm_gpio_irq_chip = { .name = "bcm-kona-gpio", .irq_ack = bcm_kona_gpio_irq_ack, .irq_mask = bcm_kona_gpio_irq_mask, .irq_unmask = bcm_kona_gpio_irq_unmask, .irq_set_type = bcm_kona_gpio_irq_set_type, - .irq_request_resources = bcm_kona_gpio_irq_reqres, - .irq_release_resources = bcm_kona_gpio_irq_relres, }; static struct of_device_id const bcm_kona_gpio_of_match[] = { diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index 28da700f5f52..c9b84182e84e 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c @@ -250,31 +250,6 @@ static void dwapb_irq_disable(struct irq_data *d) spin_unlock_irqrestore(&gc->bgpio_lock, flags); } -static int dwapb_irq_reqres(struct irq_data *d) -{ - struct irq_chip_generic *igc = irq_data_get_irq_chip_data(d); - struct dwapb_gpio *gpio = igc->private; - struct gpio_chip *gc = &gpio->ports[0].gc; - int ret; - - ret = gpiochip_lock_as_irq(gc, irqd_to_hwirq(d)); - if (ret) { - dev_err(gpio->dev, "unable to lock HW IRQ %lu for IRQ\n", - irqd_to_hwirq(d)); - return ret; - } - return 0; -} - -static void dwapb_irq_relres(struct irq_data *d) -{ - struct irq_chip_generic *igc = irq_data_get_irq_chip_data(d); - struct dwapb_gpio *gpio = igc->private; - struct gpio_chip *gc = &gpio->ports[0].gc; - - gpiochip_unlock_as_irq(gc, irqd_to_hwirq(d)); -} - static int dwapb_irq_set_type(struct irq_data *d, u32 type) { struct irq_chip_generic *igc = irq_data_get_irq_chip_data(d); @@ -428,8 +403,6 @@ static void dwapb_configure_irqs(struct dwapb_gpio *gpio, ct->chip.irq_set_type = dwapb_irq_set_type; ct->chip.irq_enable = dwapb_irq_enable; ct->chip.irq_disable = dwapb_irq_disable; - ct->chip.irq_request_resources = dwapb_irq_reqres; - ct->chip.irq_release_resources = dwapb_irq_relres; #ifdef CONFIG_PM_SLEEP ct->chip.irq_set_wake = dwapb_irq_set_wake; #endif diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c index 982e699a5b81..a3532dccfc01 100644 --- a/drivers/gpio/gpio-em.c +++ b/drivers/gpio/gpio-em.c @@ -98,28 +98,6 @@ static void em_gio_irq_enable(struct irq_data *d) em_gio_write(p, GIO_IEN, BIT(irqd_to_hwirq(d))); } -static int em_gio_irq_reqres(struct irq_data *d) -{ - struct em_gio_priv *p = irq_data_get_irq_chip_data(d); - int ret; - - ret = gpiochip_lock_as_irq(&p->gpio_chip, irqd_to_hwirq(d)); - if (ret) { - dev_err(p->gpio_chip.parent, - "unable to lock HW IRQ %lu for IRQ\n", - irqd_to_hwirq(d)); - return ret; - } - return 0; -} - -static void em_gio_irq_relres(struct irq_data *d) -{ - struct em_gio_priv *p = irq_data_get_irq_chip_data(d); - - gpiochip_unlock_as_irq(&p->gpio_chip, irqd_to_hwirq(d)); -} - #define GIO_ASYNC(x) (x + 8) @@ -344,8 +322,6 @@ static int em_gio_probe(struct platform_device *pdev) irq_chip->irq_mask = em_gio_irq_disable; irq_chip->irq_unmask = em_gio_irq_enable; irq_chip->irq_set_type = em_gio_irq_set_type; - irq_chip->irq_request_resources = em_gio_irq_reqres; - irq_chip->irq_release_resources = em_gio_irq_relres; irq_chip->flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_MASK_ON_SUSPEND; p->irq_domain = irq_domain_add_simple(pdev->dev.of_node, ngpios, 0, diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c index 47dbd19751d0..e89defde2156 100644 --- a/drivers/gpio/gpio-tegra.c +++ b/drivers/gpio/gpio-tegra.c @@ -296,7 +296,6 @@ static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type) struct tegra_gpio_info *tgi = bank->tgi; unsigned long flags; u32 val; - int ret; switch (type & IRQ_TYPE_SENSE_MASK) { case IRQ_TYPE_EDGE_RISING: @@ -335,14 +334,6 @@ static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type) tegra_gpio_mask_write(tgi, GPIO_MSK_OE(tgi, gpio), gpio, 0); tegra_gpio_enable(tgi, gpio); - ret = gpiochip_lock_as_irq(&tgi->gc, gpio); - if (ret) { - dev_err(tgi->dev, - "unable to lock Tegra GPIO %u as IRQ\n", gpio); - tegra_gpio_disable(tgi, gpio); - return ret; - } - if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) irq_set_handler_locked(d, handle_level_irq); else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) @@ -351,15 +342,6 @@ static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type) return 0; } -static void tegra_gpio_irq_shutdown(struct irq_data *d) -{ - struct tegra_gpio_bank *bank = irq_data_get_irq_chip_data(d); - struct tegra_gpio_info *tgi = bank->tgi; - unsigned int gpio = d->hwirq; - - gpiochip_unlock_as_irq(&tgi->gc, gpio); -} - static void tegra_gpio_irq_handler(struct irq_desc *desc) { unsigned int port, pin, gpio; @@ -596,7 +578,6 @@ static int tegra_gpio_probe(struct platform_device *pdev) tgi->ic.irq_mask = tegra_gpio_irq_mask; tgi->ic.irq_unmask = tegra_gpio_irq_unmask; tgi->ic.irq_set_type = tegra_gpio_irq_set_type; - tgi->ic.irq_shutdown = tegra_gpio_irq_shutdown; #ifdef CONFIG_PM_SLEEP tgi->ic.irq_set_wake = tegra_gpio_irq_set_wake; #endif diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c index 1306722faa5a..dfc08ad5fd05 100644 --- a/drivers/gpio/gpio-thunderx.c +++ b/drivers/gpio/gpio-thunderx.c @@ -364,22 +364,15 @@ static int thunderx_gpio_irq_request_resources(struct irq_data *data) struct thunderx_line *txline = irq_data_get_irq_chip_data(data); struct thunderx_gpio *txgpio = txline->txgpio; struct irq_data *parent_data = data->parent_data; - int r; - - r = gpiochip_lock_as_irq(&txgpio->chip, txline->line); - if (r) - return r; if (parent_data && parent_data->chip->irq_request_resources) { - r = parent_data->chip->irq_request_resources(parent_data); + int r = parent_data->chip->irq_request_resources(parent_data); + if (r) - goto error; + return r; } return 0; -error: - gpiochip_unlock_as_irq(&txgpio->chip, txline->line); - return r; } static void thunderx_gpio_irq_release_resources(struct irq_data *data) @@ -390,8 +383,6 @@ static void thunderx_gpio_irq_release_resources(struct irq_data *data) if (parent_data && parent_data->chip->irq_release_resources) parent_data->chip->irq_release_resources(parent_data); - - gpiochip_unlock_as_irq(&txgpio->chip, txline->line); } /* diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c index 7fdac9060979..5000b6580b52 100644 --- a/drivers/gpio/gpio-uniphier.c +++ b/drivers/gpio/gpio-uniphier.c @@ -304,29 +304,9 @@ static int uniphier_gpio_irq_domain_alloc(struct irq_domain *domain, return irq_domain_alloc_irqs_parent(domain, virq, 1, &parent_fwspec); } -static int uniphier_gpio_irq_domain_activate(struct irq_domain *domain, - struct irq_data *data, bool early) -{ - struct uniphier_gpio_priv *priv = domain->host_data; - struct gpio_chip *chip = &priv->chip; - - return gpiochip_lock_as_irq(chip, data->hwirq + UNIPHIER_GPIO_IRQ_OFFSET); -} - -static void uniphier_gpio_irq_domain_deactivate(struct irq_domain *domain, - struct irq_data *data) -{ - struct uniphier_gpio_priv *priv = domain->host_data; - struct gpio_chip *chip = &priv->chip; - - gpiochip_unlock_as_irq(chip, data->hwirq + UNIPHIER_GPIO_IRQ_OFFSET); -} - static const struct irq_domain_ops uniphier_gpio_irq_domain_ops = { .alloc = uniphier_gpio_irq_domain_alloc, .free = irq_domain_free_irqs_common, - .activate = uniphier_gpio_irq_domain_activate, - .deactivate = uniphier_gpio_irq_domain_deactivate, .translate = uniphier_gpio_irq_domain_translate, }; diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c index 027699cec911..0d8fe307ebd2 100644 --- a/drivers/gpio/gpio-vr41xx.c +++ b/drivers/gpio/gpio-vr41xx.c @@ -138,16 +138,6 @@ static void unmask_giuint_low(struct irq_data *d) static unsigned int startup_giuint(struct irq_data *data) { - int ret; - - ret = gpiochip_lock_as_irq(&vr41xx_gpio_chip, irqd_to_hwirq(data)); - if (ret) { - dev_err(vr41xx_gpio_chip.parent, - "unable to lock HW IRQ %lu for IRQ\n", - data->hwirq); - return ret; - } - /* Satisfy the .enable semantics by unmasking the line */ unmask_giuint_low(data); return 0; @@ -156,7 +146,6 @@ static unsigned int startup_giuint(struct irq_data *data) static void shutdown_giuint(struct irq_data *data) { mask_giuint_low(data); - gpiochip_unlock_as_irq(&vr41xx_gpio_chip, data->hwirq); } static struct irq_chip giuint_low_irq_chip = { diff --git a/drivers/gpio/gpio-xgene-sb.c b/drivers/gpio/gpio-xgene-sb.c index 2eb76f35aa7e..7a488a9839af 100644 --- a/drivers/gpio/gpio-xgene-sb.c +++ b/drivers/gpio/gpio-xgene-sb.c @@ -143,15 +143,6 @@ static int xgene_gpio_sb_domain_activate(struct irq_domain *d, { struct xgene_gpio_sb *priv = d->host_data; u32 gpio = HWIRQ_TO_GPIO(priv, irq_data->hwirq); - int ret; - - ret = gpiochip_lock_as_irq(&priv->gc, gpio); - if (ret) { - dev_err(priv->gc.parent, - "Unable to configure XGene GPIO standby pin %d as IRQ\n", - gpio); - return ret; - } xgene_gpio_set_bit(&priv->gc, priv->regs + MPA_GPIO_SEL_LO, gpio * 2, 1); @@ -164,7 +155,6 @@ static void xgene_gpio_sb_domain_deactivate(struct irq_domain *d, struct xgene_gpio_sb *priv = d->host_data; u32 gpio = HWIRQ_TO_GPIO(priv, irq_data->hwirq); - gpiochip_unlock_as_irq(&priv->gc, gpio); xgene_gpio_set_bit(&priv->gc, priv->regs + MPA_GPIO_SEL_LO, gpio * 2, 0); } diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index c48ed9d89ff5..75384ec9c71d 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -188,16 +188,10 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares, value = gpiod_get_value(desc); - ret = gpiochip_lock_as_irq(chip, pin); - if (ret) { - dev_err(chip->parent, "Failed to lock GPIO as interrupt\n"); - goto fail_free_desc; - } - irq = gpiod_to_irq(desc); if (irq < 0) { dev_err(chip->parent, "Failed to translate GPIO to IRQ\n"); - goto fail_unlock_irq; + goto fail_free_desc; } irqflags = IRQF_ONESHOT; @@ -223,7 +217,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares, event = kzalloc(sizeof(*event), GFP_KERNEL); if (!event) - goto fail_unlock_irq; + goto fail_free_desc; event->handle = evt_handle; event->irq = irq; @@ -260,8 +254,6 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares, fail_free_event: kfree(event); -fail_unlock_irq: - gpiochip_unlock_as_irq(chip, pin); fail_free_desc: gpiochip_free_own_desc(desc); @@ -337,7 +329,6 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) desc = event->desc; if (WARN_ON(IS_ERR(desc))) continue; - gpiochip_unlock_as_irq(chip, event->pin); gpiochip_free_own_desc(desc); list_del(&event->node); kfree(event); diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 3dbaf489a8a5..5567e52a33d7 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c @@ -184,29 +184,15 @@ static int gpio_sysfs_request_irq(struct device *dev, unsigned char flags) irq_flags |= test_bit(FLAG_ACTIVE_LOW, &desc->flags) ? IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING; - /* - * FIXME: This should be done in the irq_request_resources callback - * when the irq is requested, but a few drivers currently fail - * to do so. - * - * Remove this redundant call (along with the corresponding - * unlock) when those drivers have been fixed. - */ - ret = gpiochip_lock_as_irq(desc->gdev->chip, gpio_chip_hwgpio(desc)); - if (ret < 0) - goto err_put_kn; - ret = request_any_context_irq(data->irq, gpio_sysfs_irq, irq_flags, "gpiolib", data); if (ret < 0) - goto err_unlock; + goto err_put_kn; data->irq_flags = flags; return 0; -err_unlock: - gpiochip_unlock_as_irq(desc->gdev->chip, gpio_chip_hwgpio(desc)); err_put_kn: sysfs_put(data->value_kn); @@ -220,11 +206,9 @@ static int gpio_sysfs_request_irq(struct device *dev, unsigned char flags) static void gpio_sysfs_free_irq(struct device *dev) { struct gpiod_data *data = dev_get_drvdata(dev); - struct gpio_desc *desc = data->desc; data->irq_flags = 0; free_irq(data->irq, data); - gpiochip_unlock_as_irq(desc->gdev->chip, gpio_chip_hwgpio(desc)); sysfs_put(data->value_kn); } diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 271f31461da4..d583b3567bda 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -1209,22 +1209,14 @@ static int __maybe_unused cp2112_allocate_irq(struct cp2112_device *dev, return PTR_ERR(dev->desc[pin]); } - ret = gpiochip_lock_as_irq(&dev->gc, pin); - if (ret) { - dev_err(dev->gc.parent, "Failed to lock GPIO as interrupt\n"); - goto err_desc; - } - ret = gpiod_to_irq(dev->desc[pin]); if (ret < 0) { dev_err(dev->gc.parent, "Failed to translate GPIO to IRQ\n"); - goto err_lock; + goto err_desc; } return ret; -err_lock: - gpiochip_unlock_as_irq(&dev->gc, pin); err_desc: gpiochip_free_own_desc(dev->desc[pin]); dev->desc[pin] = NULL; @@ -1391,10 +1383,8 @@ static void cp2112_remove(struct hid_device *hdev) cancel_delayed_work_sync(&dev->gpio_poll_worker); } - for (i = 0; i < ARRAY_SIZE(dev->desc); i++) { - gpiochip_unlock_as_irq(&dev->gc, i); + for (i = 0; i < ARRAY_SIZE(dev->desc); i++) gpiochip_free_own_desc(dev->desc[i]); - } gpiochip_remove(&dev->gc); /* i2c_del_adapter has finished removing all i2c devices from our diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index 62b009b27eda..3d0bd7b99725 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -872,36 +872,6 @@ static int intel_gpio_to_pin(struct intel_pinctrl *pctrl, unsigned offset, return -EINVAL; } -static int intel_gpio_irq_reqres(struct irq_data *d) -{ - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct intel_pinctrl *pctrl = gpiochip_get_data(gc); - int pin; - int ret; - - pin = intel_gpio_to_pin(pctrl, irqd_to_hwirq(d), NULL, NULL); - if (pin >= 0) { - ret = gpiochip_lock_as_irq(gc, pin); - if (ret) { - dev_err(pctrl->dev, "unable to lock HW IRQ %d for IRQ\n", - pin); - return ret; - } - } - return 0; -} - -static void intel_gpio_irq_relres(struct irq_data *d) -{ - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - struct intel_pinctrl *pctrl = gpiochip_get_data(gc); - int pin; - - pin = intel_gpio_to_pin(pctrl, irqd_to_hwirq(d), NULL, NULL); - if (pin >= 0) - gpiochip_unlock_as_irq(gc, pin); -} - static void intel_gpio_irq_ack(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); @@ -1117,8 +1087,6 @@ static irqreturn_t intel_gpio_irq(int irq, void *data) static struct irq_chip intel_gpio_irqchip = { .name = "intel-gpio", - .irq_request_resources = intel_gpio_irq_reqres, - .irq_release_resources = intel_gpio_irq_relres, .irq_enable = intel_gpio_irq_enable, .irq_ack = intel_gpio_irq_ack, .irq_mask = intel_gpio_irq_mask, diff --git a/drivers/pinctrl/mediatek/mtk-eint.c b/drivers/pinctrl/mediatek/mtk-eint.c index a613e546717a..e86ca9e252e6 100644 --- a/drivers/pinctrl/mediatek/mtk-eint.c +++ b/drivers/pinctrl/mediatek/mtk-eint.c @@ -244,13 +244,6 @@ static int mtk_eint_irq_request_resources(struct irq_data *d) return err; } - err = gpiochip_lock_as_irq(gpio_c, gpio_n); - if (err < 0) { - dev_err(eint->dev, "unable to lock HW IRQ %lu for IRQ\n", - irqd_to_hwirq(d)); - return err; - } - err = eint->gpio_xlate->set_gpio_as_eint(eint->pctl, d->hwirq); if (err < 0) { dev_err(eint->dev, "Can not eint mode\n"); @@ -268,8 +261,6 @@ static void mtk_eint_irq_release_resources(struct irq_data *d) eint->gpio_xlate->get_gpio_n(eint->pctl, d->hwirq, &gpio_n, &gpio_c); - - gpiochip_unlock_as_irq(gpio_c, gpio_n); } static struct irq_chip mtk_eint_irq_chip = { diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 0966bb0bf71f..96a0e93ffd79 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -1291,14 +1291,7 @@ static int st_gpio_irq_request_resources(struct irq_data *d) st_gpio_direction_input(gc, d->hwirq); - return gpiochip_lock_as_irq(gc, d->hwirq); -} - -static void st_gpio_irq_release_resources(struct irq_data *d) -{ - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); - - gpiochip_unlock_as_irq(gc, d->hwirq); + return 0; } static int st_gpio_irq_set_type(struct irq_data *d, unsigned type) @@ -1456,7 +1449,6 @@ static const struct gpio_chip st_gpio_template = { static struct irq_chip st_gpio_irqchip = { .name = "GPIO", .irq_request_resources = st_gpio_irq_request_resources, - .irq_release_resources = st_gpio_irq_release_resources, .irq_disable = st_gpio_irq_mask, .irq_mask = st_gpio_irq_mask, .irq_unmask = st_gpio_irq_unmask, diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c index f49ea3d92aa1..0cc8a5622abd 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos.c @@ -155,14 +155,6 @@ static int exynos_irq_request_resources(struct irq_data *irqd) unsigned int shift, mask, con; int ret; - ret = gpiochip_lock_as_irq(&bank->gpio_chip, irqd->hwirq); - if (ret) { - dev_err(bank->gpio_chip.parent, - "unable to lock pin %s-%lu IRQ\n", - bank->name, irqd->hwirq); - return ret; - } - reg_con = bank->pctl_offset + bank_type->reg_offset[PINCFG_TYPE_FUNC]; shift = irqd->hwirq * bank_type->fld_width[PINCFG_TYPE_FUNC]; mask = (1 << bank_type->fld_width[PINCFG_TYPE_FUNC]) - 1; @@ -198,8 +190,6 @@ static void exynos_irq_release_resources(struct irq_data *irqd) writel(con, bank->pctl_base + reg_con); spin_unlock_irqrestore(&bank->slock, flags); - - gpiochip_unlock_as_irq(&bank->gpio_chip, irqd->hwirq); } /* diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c index a9bec6e6fdd1..06d0ec24f324 100644 --- a/drivers/pinctrl/stm32/pinctrl-stm32.c +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c @@ -245,30 +245,15 @@ static const struct gpio_chip stm32_gpio_template = { static int stm32_gpio_irq_request_resources(struct irq_data *irq_data) { struct stm32_gpio_bank *bank = irq_data->domain->host_data; - struct stm32_pinctrl *pctl = dev_get_drvdata(bank->gpio_chip.parent); int ret; ret = stm32_gpio_direction_input(&bank->gpio_chip, irq_data->hwirq); if (ret) return ret; - ret = gpiochip_lock_as_irq(&bank->gpio_chip, irq_data->hwirq); - if (ret) { - dev_err(pctl->dev, "unable to lock HW IRQ %lu for IRQ\n", - irq_data->hwirq); - return ret; - } - return 0; } -static void stm32_gpio_irq_release_resources(struct irq_data *irq_data) -{ - struct stm32_gpio_bank *bank = irq_data->domain->host_data; - - gpiochip_unlock_as_irq(&bank->gpio_chip, irq_data->hwirq); -} - static struct irq_chip stm32_gpio_irq_chip = { .name = "stm32gpio", .irq_eoi = irq_chip_eoi_parent, @@ -278,7 +263,6 @@ static struct irq_chip stm32_gpio_irq_chip = { .irq_set_type = irq_chip_set_type_parent, .irq_set_wake = irq_chip_set_wake_parent, .irq_request_resources = stm32_gpio_irq_request_resources, - .irq_release_resources = stm32_gpio_irq_release_resources, }; static int stm32_gpio_domain_translate(struct irq_domain *d, diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index 4d9bf9b3e9f3..1aaa91a1e79f 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -803,35 +803,18 @@ static int sunxi_pinctrl_irq_request_resources(struct irq_data *d) { struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d); struct sunxi_desc_function *func; - int ret; func = sunxi_pinctrl_desc_find_function_by_pin(pctl, pctl->irq_array[d->hwirq], "irq"); if (!func) return -EINVAL; - ret = gpiochip_lock_as_irq(pctl->chip, - pctl->irq_array[d->hwirq] - pctl->desc->pin_base); - if (ret) { - dev_err(pctl->dev, "unable to lock HW IRQ %lu for IRQ\n", - irqd_to_hwirq(d)); - return ret; - } - /* Change muxing to INT mode */ sunxi_pmx_set(pctl->pctl_dev, pctl->irq_array[d->hwirq], func->muxval); return 0; } -static void sunxi_pinctrl_irq_release_resources(struct irq_data *d) -{ - struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d); - - gpiochip_unlock_as_irq(pctl->chip, - pctl->irq_array[d->hwirq] - pctl->desc->pin_base); -} - static int sunxi_pinctrl_irq_set_type(struct irq_data *d, unsigned int type) { struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d); @@ -935,7 +918,6 @@ static struct irq_chip sunxi_pinctrl_edge_irq_chip = { .irq_mask = sunxi_pinctrl_irq_mask, .irq_unmask = sunxi_pinctrl_irq_unmask, .irq_request_resources = sunxi_pinctrl_irq_request_resources, - .irq_release_resources = sunxi_pinctrl_irq_release_resources, .irq_set_type = sunxi_pinctrl_irq_set_type, .flags = IRQCHIP_SKIP_SET_WAKE, }; @@ -950,7 +932,6 @@ static struct irq_chip sunxi_pinctrl_level_irq_chip = { .irq_enable = sunxi_pinctrl_irq_ack_unmask, .irq_disable = sunxi_pinctrl_irq_mask, .irq_request_resources = sunxi_pinctrl_irq_request_resources, - .irq_release_resources = sunxi_pinctrl_irq_release_resources, .irq_set_type = sunxi_pinctrl_irq_set_type, .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_EOI_THREADED | IRQCHIP_EOI_IF_HANDLED, From patchwork Mon Aug 27 13:06:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 962505 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xs4all.nl Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41zXFs36LJz9s2P for ; Mon, 27 Aug 2018 23:06:25 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726958AbeH0Qw6 (ORCPT ); Mon, 27 Aug 2018 12:52:58 -0400 Received: from lb2-smtp-cloud9.xs4all.net ([194.109.24.26]:33863 "EHLO lb2-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726911AbeH0Qw6 (ORCPT ); Mon, 27 Aug 2018 12:52:58 -0400 Received: from marune.fritz.box ([IPv6:2001:983:e9a7:1:8960:b49d:3b62:6d25]) by smtp-cloud9.xs4all.net with ESMTPA id uHDofV4VjEJtcuHDqfnRj5; Mon, 27 Aug 2018 15:06:22 +0200 From: Hans Verkuil To: linux-gpio@vger.kernel.org Cc: ilina@codeaurora.org, Linus Walleij , Marc Zyngier , Thomas Gleixner , Hans Verkuil Subject: [RFCv2 PATCH 3/4] gpiolib: remove gpiochip_(un)lock_as_irq Date: Mon, 27 Aug 2018 15:06:19 +0200 Message-Id: <20180827130620.96232-4-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180827130620.96232-1-hverkuil@xs4all.nl> References: <20180827130620.96232-1-hverkuil@xs4all.nl> X-CMAE-Envelope: MS4wfO0raWBMx02USSDv/JqPqS7bcm3Rr6OCpQnW8nW8piE15X1Gh0u7ABltXer0mfiGN+DguwlxufnCq0bWeqVASJPlk9RKOOiI4CJJ9wnxH/9AzM5+yjjr oc1py9rg9XZfHyUI9n0V9uG9cBPK52Zjq8T7UkZPqGw1cjFwas1wff9kwF7rmUl1I0rxZ4VQ1Jhnxilqh6PLWNEawbtKHpfQ2kEuszJpV8Zpyp9zVYWUeRnf WsIk7mzwS6jXSTBT5h76umfe6Je6F6Pa88Y7/NlFW0CuoaoyfFQuVd87FaehxNjq8neyhcIaUNXRrw1WuBOPsSibsw1yEMaLkPh1bMEfi01yg8h5V7rEM9EJ BFpODkgEPTVd/DpKMHUaO6nAnr2gB0loHdyvRvnRKJ1CMQCtt+lW6EPiUvDJQIfPsWwT+ixP Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Hans Verkuil Now that these functions are no longer called we can remove them from gpiolib. Signed-off-by: Hans Verkuil --- drivers/gpio/gpiolib.c | 15 --------------- include/linux/gpio.h | 13 ------------- include/linux/gpio/driver.h | 4 +--- 3 files changed, 1 insertion(+), 31 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 0efa9ec4fec4..b48857ade55c 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3391,21 +3391,6 @@ static void gpiochip_irq_unlock(struct gpio_chip *chip, unsigned int offset) desc_set_label(desc, NULL); } -/* - * Keep these two temporary stubs until all drivers stop calling these - * functions. - */ -int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset) -{ - return 0; -} -EXPORT_SYMBOL_GPL(gpiochip_lock_as_irq); - -void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset) -{ -} -EXPORT_SYMBOL_GPL(gpiochip_unlock_as_irq); - bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset) { if (offset >= chip->ngpio) diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 39745b8bdd65..4c8e984db29c 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -220,19 +220,6 @@ static inline int gpio_to_irq(unsigned gpio) return -EINVAL; } -static inline int gpiochip_lock_as_irq(struct gpio_chip *chip, - unsigned int offset) -{ - WARN_ON(1); - return -EINVAL; -} - -static inline void gpiochip_unlock_as_irq(struct gpio_chip *chip, - unsigned int offset) -{ - WARN_ON(1); -} - static inline int irq_to_gpio(unsigned irq) { /* irq can never have been returned from gpio_to_irq() */ diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 0485bd339178..70367b056062 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -398,9 +398,7 @@ extern void devm_gpiochip_remove(struct device *dev, struct gpio_chip *chip); extern struct gpio_chip *gpiochip_find(void *data, int (*match)(struct gpio_chip *chip, void *data)); -/* lock/unlock as IRQ */ -int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset); -void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset); +/* line is configure as IRQ */ bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset); /* Line status inquiry for drivers */ From patchwork Mon Aug 27 13:06:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 962506 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xs4all.nl Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41zXFv295Pz9s47 for ; Mon, 27 Aug 2018 23:06:27 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726911AbeH0Qw6 (ORCPT ); Mon, 27 Aug 2018 12:52:58 -0400 Received: from lb3-smtp-cloud9.xs4all.net ([194.109.24.30]:52408 "EHLO lb3-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726953AbeH0Qw6 (ORCPT ); Mon, 27 Aug 2018 12:52:58 -0400 Received: from marune.fritz.box ([IPv6:2001:983:e9a7:1:8960:b49d:3b62:6d25]) by smtp-cloud9.xs4all.net with ESMTPA id uHDofV4VjEJtcuHDqfnRjG; Mon, 27 Aug 2018 15:06:22 +0200 From: Hans Verkuil To: linux-gpio@vger.kernel.org Cc: ilina@codeaurora.org, Linus Walleij , Marc Zyngier , Thomas Gleixner , Hans Verkuil Subject: [RFCv2 PATCH 4/4] gpio/driver.rst: drop gpiochip_(un)lock_as_irq section Date: Mon, 27 Aug 2018 15:06:20 +0200 Message-Id: <20180827130620.96232-5-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180827130620.96232-1-hverkuil@xs4all.nl> References: <20180827130620.96232-1-hverkuil@xs4all.nl> X-CMAE-Envelope: MS4wfO0raWBMx02USSDv/JqPqS7bcm3Rr6OCpQnW8nW8piE15X1Gh0u7ABltXer0mfiGN+DguwlxufnCq0bWeqVASJPlk9RKOOiI4CJJ9wnxH/9AzM5+yjjr oc1py9rg9XZfHyUI9n0V9uG9cBPK52Zjq8T7UkZPqGw1cjFwas1wff9kwF7rmUl1I0rxZ4VQ1Jhnxilqh6PLWNEawbtKHpfQ2kEuszJpV8Zpyp9zVYWUeRnf WsIk7mzwS6jXSTBT5h76umfe6Je6F6Pa88Y7/NlFW0CuoaoyfFQuVd87FaehxNjq8neyhcIaUNXRrw1WuBOPsSibsw1yEMaLkPh1bMEfi01yg8h5V7rEM9EJ BFpODkgEPTVd/DpKMHUaO6nAnr2gB0loHdyvRvnRKJ1CMQCtt+lW6EPiUvDJQIfPsWwT+ixP Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Hans Verkuil These functions no longer need to be called by drivers, so just drop this section from the documentation. Signed-off-by: Hans Verkuil --- Documentation/driver-api/gpio/driver.rst | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/Documentation/driver-api/gpio/driver.rst b/Documentation/driver-api/gpio/driver.rst index cbe0242842d1..15e22df72076 100644 --- a/Documentation/driver-api/gpio/driver.rst +++ b/Documentation/driver-api/gpio/driver.rst @@ -358,25 +358,6 @@ keep track of usage inside of the gpiolib subsystem. This is why the API below exists. -Locking IRQ usage ------------------ -Input GPIOs can be used as IRQ signals. When this happens, a driver is requested -to mark the GPIO as being used as an IRQ:: - - int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset) - -This will prevent the use of non-irq related GPIO APIs until the GPIO IRQ lock -is released:: - - void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset) - -When implementing an irqchip inside a GPIO driver, these two functions should -typically be called in the .startup() and .shutdown() callbacks from the -irqchip. - -When using the gpiolib irqchip helpers, these callback are automatically -assigned. - Real-Time compliance for GPIO IRQ chips ---------------------------------------