Message ID | 20180831143744.126063-1-hverkuil@xs4all.nl |
---|---|
Headers | show
Return-Path: <linux-gpio-owner@vger.kernel.org> 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=<UNKNOWN>) 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 42225Z0Dr9z9s1x for <incoming@patchwork.ozlabs.org>; Sat, 1 Sep 2018 00:37:54 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728623AbeHaSpe (ORCPT <rfc822;incoming@patchwork.ozlabs.org>); Fri, 31 Aug 2018 14:45:34 -0400 Received: from lb3-smtp-cloud8.xs4all.net ([194.109.24.29]:53725 "EHLO lb3-smtp-cloud8.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728594AbeHaSpe (ORCPT <rfc822;linux-gpio@vger.kernel.org>); Fri, 31 Aug 2018 14:45:34 -0400 Received: from marune.fritz.box ([80.101.105.217]) by smtp-cloud8.xs4all.net with ESMTPA id vkYSfoJHlaLLbvkYTf2rG1; Fri, 31 Aug 2018 16:37:45 +0200 From: Hans Verkuil <hverkuil@xs4all.nl> To: linux-gpio@vger.kernel.org Cc: Linus Walleij <linus.walleij@linaro.org>, ilina@codeaurora.org, Marc Zyngier <marc.zyngier@arm.com>, Thomas Gleixner <tglx@linutronix.de> Subject: [RFCv3 PATCH 0/4] gpiolib: track irq enabled/disabled state Date: Fri, 31 Aug 2018 16:37:40 +0200 Message-Id: <20180831143744.126063-1-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.18.0 X-CMAE-Envelope: MS4wfLZM2z93Cms+7x+WCHN6qyw+juQAEipCF+n59aSVSeYwLeOqoKdXV+l3U3QhU8LcaNa8C2lnCSlq8uLRfU4Pf9R7aCNTC8oLoL9wt5S7GBNNU8c4rh/p UREPmVR22/K93QqCQNOnqtpWNPz8l8AcxcXmkMNPF8jb1fy6V96FLvHpmozxjRbxYCrsWB24caQcwigd/Ru5zCKmkLVhgm2Y3lh9bc0/X+YwCYKqObblIbqZ wytzbSHMjd9Cua1dHZZSNKWnvdegSH8s2L9WFHbzIpUo+U1xrA82TJIuF5Bq7+nDAXhsEdaritjjS2HXnMu/ow== Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: <linux-gpio.vger.kernel.org> X-Mailing-List: linux-gpio@vger.kernel.org |
Series | gpiolib: track irq enabled/disabled state | expand |
From: Hans Verkuil <hans.verkuil@cisco.com> Hi all, This is the third RFC patch series which attempts to allow drivers to disable the irq and drive the gpio as an output. Please be gentle with me: I am neither an expert on the gpio internals, nor on the irq internals. My previous version moved the code that marked a gpio pin as 'used by an irq' to the places where the irq was enabled/disabled, but that is wrong. The problem is that userspace can also request to use an irq for a gpio pin, so the FLAG_USED_AS_IRQ flag really should be set when the irq is requested, otherwise a driver can request the irq, but userspace can do so as well if the irq is disabled since disabling the irq cleared the FLAG_USED_AS_IRQ flag and now gpiolib doesn't know that there already is an irq handler associated with the gpio. What is needed instead is a new flag FLAG_IRQ_IS_ENABLED that keeps track if the irq is enabled or not. The first patch adds that flag and allows the direction to be changed to output unless both FLAG_USED_AS_IRQ and FLAG_IRQ_IS_ENABLED are set. The second patch makes helper functions available for drivers that implement the irq_request/release_resources hooks: this should simplify such drivers as these helpers call try_module_get(chip->gpiodev->owner), something that none of the drivers currently implementing these hooks do. The third patch overrides the irq_disable and irq_enable hooks when using the irqchip helpers so gpiolib will know when the irq is enabled/disabled. Drivers that do not use these helpers will have to call this themselves, and the fourth patch converts one such driver. The nice thing is that as far as I can tell no drivers need to be patched. Drivers that do not use the helpers will need to be updated over time so they call gpiochip_en/disable_irq, but that can be done one by one. This patch series has been tested on my BeagleBone Black board with the tda998x driver. Regards, Hans Hans Verkuil (4): gpiolib: add flag to indicate if the irq is disabled gpiolib: export gpiochip_irq_reqres/relres() gpiolib: override irq_enable/disable gpio-bcm-kona: use new req/relres and dis/enable_irq funcs drivers/gpio/gpio-bcm-kona.c | 14 +-- drivers/gpio/gpiolib.c | 178 +++++++++++++++++++++++++---------- drivers/gpio/gpiolib.h | 1 + include/linux/gpio/driver.h | 7 ++ 4 files changed, 139 insertions(+), 61 deletions(-)