Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1357544ybs; Mon, 25 May 2020 14:00:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJze5K9ZjkgY718avKYl8G+EsieK66k4cl0XVj35T7XCRnLv30b/QEh/X0BUC3UriUfAB+yC X-Received: by 2002:aa7:d44a:: with SMTP id q10mr17416100edr.386.1590440439965; Mon, 25 May 2020 14:00:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590440439; cv=none; d=google.com; s=arc-20160816; b=RF6K2g9+lNrcwN5ZtsLc4vnlOVMNDJk5cPgrnLYwYEJd0REeCGquq/pkXvUTpjXfHx BP0K1qyeOdifEsV8qgR2kIK527vnCapF4xbhoWsEP00aoH4GFvdxAglTq00HrfuJ1HCH iMUGXbh/k+F6Ek3858pOfE0BLKzWKcH7D1udBbX0V7SyTujZHLLmGd3ICbenzNKVMhYs Ken7RnMI32qE8RSeCv1por1iUeqtnEFhg+6RHXweBm6PvDaSxVj8b8nTeGCWJErHS08a wdtkak+ul07i+HDgaQpwu3A+8FmAew4hIkyiykssGHO2U4xrEpM/jzn5+oIAiP+MeJTu B4bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7np4wDKRiMQQf5ldFNBXoJfzP9Qd8PYygwxPlZayMKg=; b=yy/ml6Z8D36xQzbFL0kWhjIb3gkBohqegq4/+tgQijj/4S9rjUF1yZmbSQTI1vgMDX PriMCuAXA85OubsF23C/unfWODj0A3iX3z9sSzfPeAB78hfqSn149xcc/VllGarVjVP/ iB0aBsOAQwDqBDPqFiBbzg8rGBAYhT9wLZ2jGbJiykADjWjOKn/07UcjR0RICEBTUL1T +qJKDwxThXtlWkHNNkmETG8T0kHB6NdZrZdo32fuck5tnZjOkRPpDu4unp5dcHvnGRA6 Gmf4NWdPbTjvwc+gSb6YEwtXQDm+ZzPAiUatIT2j8FPCsoffnd05vRKm0yJILKYnGBt/ d+0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=GVJ0tBXh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t24si9793984ejx.566.2020.05.25.14.00.17; Mon, 25 May 2020 14:00:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=GVJ0tBXh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391195AbgEYQH5 (ORCPT + 99 others); Mon, 25 May 2020 12:07:57 -0400 Received: from ssl.serverraum.org ([176.9.125.105]:40641 "EHLO ssl.serverraum.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391179AbgEYQH4 (ORCPT ); Mon, 25 May 2020 12:07:56 -0400 Received: from apollo.fritz.box (unknown [IPv6:2a02:810c:c200:2e91:6257:18ff:fec4:ca34]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 0CA3122FF5; Mon, 25 May 2020 18:07:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1590422874; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7np4wDKRiMQQf5ldFNBXoJfzP9Qd8PYygwxPlZayMKg=; b=GVJ0tBXhpS08q1dua9/Jxyf7DT4zdspHg9xtiS78CDzlbnqzDPgDG5DX3672msz7aTjprc e6bRUUFllkqMMs489JbnyjRr8l/xCTjGLLI6IObIDbaRX+1BhOZJNMv3AAIWZaAejJRok5 jSAE1Gn3LBq+f7oNj8sw/7qoyzsX5sE= From: Michael Walle To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Mark Brown , Pierre-Louis Bossart , Michael Walle Subject: [PATCH v4 1/2] gpiolib: Introduce gpiochip_irqchip_add_domain() Date: Mon, 25 May 2020 18:07:40 +0200 Message-Id: <20200525160741.21729-2-michael@walle.cc> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200525160741.21729-1-michael@walle.cc> References: <20200525160741.21729-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The function connects an IRQ domain to a gpiochip and reuses gpiochip_to_irq() which is provided by gpiolib. gpiochip_irqchip_* and regmap_irq partially provide the same functionality. This function will help to connect just the minimal functionality of the gpiochip_irqchip which is needed to work together with regmap-irq. Signed-off-by: Michael Walle --- drivers/gpio/gpiolib.c | 20 ++++++++++++++++++++ include/linux/gpio/driver.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index eaa0e209188d..d07f763c9c0b 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2756,6 +2756,26 @@ int gpiochip_irqchip_add_key(struct gpio_chip *gc, } EXPORT_SYMBOL_GPL(gpiochip_irqchip_add_key); +/** + * gpiochip_irqchip_add_domain() - adds an irqdomain to a gpiochip + * @gc: the gpiochip to add the irqchip to + * @domain: the irqdomain to add to the gpiochip + * + * This function adds an IRQ domain to the gpiochip. + */ +int gpiochip_irqchip_add_domain(struct gpio_chip *gc, + struct irq_domain *domain) +{ + if (!domain) + return -EINVAL; + + gc->to_irq = gpiochip_to_irq; + gc->irq.domain = domain; + + return 0; +} +EXPORT_SYMBOL_GPL(gpiochip_irqchip_add_domain); + #else /* CONFIG_GPIOLIB_IRQCHIP */ static inline int gpiochip_add_irqchip(struct gpio_chip *gc, diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 8c41ae41b6bb..ee30065b6f61 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -599,6 +599,9 @@ int gpiochip_irqchip_add_key(struct gpio_chip *gc, bool gpiochip_irqchip_irq_valid(const struct gpio_chip *gc, unsigned int offset); +int gpiochip_irqchip_add_domain(struct gpio_chip *gc, + struct irq_domain *domain); + #ifdef CONFIG_LOCKDEP /* -- 2.20.1