Message ID | 20180827130620.96232-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 41zXFw36Zcz9s4V for <incoming@patchwork.ozlabs.org>; Mon, 27 Aug 2018 23:06:28 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726953AbeH0Qw7 (ORCPT <rfc822;incoming@patchwork.ozlabs.org>); Mon, 27 Aug 2018 12:52:59 -0400 Received: from lb2-smtp-cloud9.xs4all.net ([194.109.24.26]:34707 "EHLO lb2-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726883AbeH0Qw7 (ORCPT <rfc822;linux-gpio@vger.kernel.org>); 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 uHDofV4VjEJtcuHDpfnRiN; Mon, 27 Aug 2018 15:06:22 +0200 From: Hans Verkuil <hverkuil@xs4all.nl> To: linux-gpio@vger.kernel.org Cc: ilina@codeaurora.org, Linus Walleij <linus.walleij@linaro.org>, Marc Zyngier <marc.zyngier@arm.com>, Thomas Gleixner <tglx@linutronix.de> Subject: [RFCv2 PATCH 0/4] gpiolib: chain irq callbacks Date: Mon, 27 Aug 2018 15:06:16 +0200 Message-Id: <20180827130620.96232-1-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.18.0 X-CMAE-Envelope: MS4wfO0raWBMx02USSDv/JqPqS7bcm3Rr6OCpQnW8nW8piE15X1Gh0u7ABltXer0mfiGN+DguwlxufnCq0bWeqVASJPlk9RKOOiI4CJJ9wnxH/9AzM5+yjjr oc1py9rg9XZfHyUI9n0V9uG9cBPK52Zjq8T7UkZPqGw1cjFwas1wff9kwF7rmUl1I0rxZ4VQ1Jhnxp/H3pRx5gtrvQ+UN0HcvW/nMiIjJqzqytChRucjCGV8 W7krzk/w0CpytkdW6ORgNvPPrJ9ATW7J6aMMeFTQPWDrE10D5euw445mBqI5cRg1/LKk7XxsI1F15YShpocvdVg3c6N4J3PbemRTJZ5nOQPJIOb08lEeTdYG nqauveLU 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: chain irq callbacks | expand |
From: Hans Verkuil <hans.verkuil@cisco.com> Hi all, This is the second 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. This patch lets gpiolib override the irq_chip's irq_request/release_resources, irq_startup/shutdown and irq_en/disable hooks. The old hooks (if any) are stored and called by gpiolib after taking care of the gpiolib-specific code. As a result, the gpiochip_(un)lock_as_irq functions can become static and can be removed from all drivers. Reviewing the removal of those calls in drivers should be fairly easy. The first patch implements the chaining of the irq callbacks. Compared to the first RFC patch I posted I added code to do the same for the startup/shutdown hooks since those also implicitly enable/disable irqs. If they are NULL, then the irq code will call the irq_en/disable hooks, so only override the startup/shutdown hooks when non-NULL. I do have one question: can the same struct irq_chip be added to different struct gpio_chip instances? Right now when the gpiolib hooks are installed for the irq_chip I check if that was already done. If the same irq_chip can be used for multiple gpio_chips, then I will need to count the irq_chip references and only remove the installed hooks when the last reference is removed. If this isn't possible, then I wonder if I need to keep a WARN_ON if someone attempts to do this. This first patch keeps the gpiochip_(un)lock_as_irq functions as stubs, so the second patch can remove all the calls safely. The third patch removes these stubs and the fourth patch removes the corresponding documentation. Should the second patch be split up in one patch per driver? Or perhaps one patch per subsystem (gpio/pinctrl/hid)? This patch series has been tested on my BeagleBone Black board with the tda998x driver and I tested the sysfs API as well. Regards, Hans Hans Verkuil (4): gpiolib: (un)mark gpio as irq when dis/enabling irq gpio: remove gpiochip_(un)lock_as_irq() from drivers gpiolib: remove gpiochip_(un)lock_as_irq gpio/driver.rst: drop gpiochip_(un)lock_as_irq section Documentation/driver-api/gpio/driver.rst | 19 --- 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/gpio/gpiolib.c | 142 ++++++++++++++++------- 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 --- include/linux/gpio.h | 13 --- include/linux/gpio/driver.h | 11 +- 21 files changed, 119 insertions(+), 357 deletions(-)