Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4576095imu; Sat, 19 Jan 2019 12:47:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN6fciYFJ449EK3cvxjcg5Ii9Gm/rYo0bVCK8wODEpReYdFRc/NrVIZHVBmVTrgFkFrJ7czf X-Received: by 2002:a63:ee0e:: with SMTP id e14mr22073630pgi.8.1547930862868; Sat, 19 Jan 2019 12:47:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547930862; cv=none; d=google.com; s=arc-20160816; b=KGjcGmbLJHKU9r9+bitEXfKuvWyWeNuKt5gAGasYqczk4VS0No5gAqGCFuun5dTvEE w1l82ow/virtskzil9GGGGam6BuoFanOF8K5ctkqZinjlI/G14RLP9Whwf+qGsn+/+Y1 P5H2b4bDcMnPoDgY6BCgQfEyXNFsvo4Njk2U0BiwrjarbW/mywFiblVZHG+Dr9Wr3idY VnOXDsJO76auMl74cegbxTPpTeRq0vg4t1VN302WPhYS1l9mFoJNWvm58JUzMPDRGGgm PtsV9DmIZMxWiDXDEornTyiAM5wiH8RB/VkCvS5TZVOmkQjGnZ/+PZGzhmHpwdkPhL2U g+lQ== 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; bh=DkKABC42khAoCKb0aVj9537mLZropj2FyCkmpLNOfKs=; b=Ie9VUqKX/N6jN3pI7WPJeiRlZ1BqZ/RSyCzTC//ea7qXdNbQK+1R+j62O2gh/MLCHG IVBYdULFTagAjbEzU9OHARhOe1qSspdw0Zv5x7AzPx7EpRluo/2FeolhTwVJOechGBOG cgGUBQRriyu+XQdOvVBUpeC3atWS2DxkwQqsKAN1zlkPjauQpToQiJk/IAvhUjp3aAOY I1DdvyopeLmyPMYBDOqm1EnF/HpAe5ZqBKQ1Ioc9xY94h6sJ+YrhT9pymxLuO6+GgJml chVTKQNabv84/TuvyaVpgVgd0exnXb110BZRuGTunbDqjeGa22VRlKH0rUIK/Wh8KeEK ccfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@onstation.org header.s=default header.b=si1vkpyp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 145si8559485pga.396.2019.01.19.12.47.22; Sat, 19 Jan 2019 12:47:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@onstation.org header.s=default header.b=si1vkpyp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729514AbfASUne (ORCPT + 99 others); Sat, 19 Jan 2019 15:43:34 -0500 Received: from onstation.org ([52.200.56.107]:35202 "EHLO onstation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729380AbfASUne (ORCPT ); Sat, 19 Jan 2019 15:43:34 -0500 Received: from localhost.localdomain (c-98-239-145-235.hsd1.wv.comcast.net [98.239.145.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: masneyb) by onstation.org (Postfix) with ESMTPSA id DDA2517F; Sat, 19 Jan 2019 20:43:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=onstation.org; s=default; t=1547930613; bh=SpfqiR+GnxcIUU9K76B9e9gNGUpiM8w58ukN/idI/vw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=si1vkpypZMGZVtQ9W7flyixD4wuRCJLzyBmldR475YCWk3f/eX+p7FlUg+HeXM+/s ZpnNiG3ST/nlmGL1KPkynIoZ8rNJiGycTYro1JIdLpl1ZfMqfGuQJl9gJR6zZfIiT2 yaDjOwb01PEwrvvfVfZ3nEv44JFz419UlMdF9eNs= From: Brian Masney To: linus.walleij@linaro.org, sboyd@kernel.org, bjorn.andersson@linaro.org, andy.gross@linaro.org, marc.zyngier@arm.com Cc: shawnguo@kernel.org, dianders@chromium.org, linux-gpio@vger.kernel.org, nicolas.dechesne@linaro.org, niklas.cassel@linaro.org, david.brown@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, thierry.reding@gmail.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v6 05/15] gpio: add irq domain activate/deactivate functions Date: Sat, 19 Jan 2019 15:42:42 -0500 Message-Id: <20190119204252.18370-6-masneyb@onstation.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190119204252.18370-1-masneyb@onstation.org> References: <20190119204252.18370-1-masneyb@onstation.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds the two new functions gpiochip_irq_domain_activate and gpiochip_irq_domain_deactivate that can be used as the activate and deactivate functions in the struct irq_domain_ops. This is for situations where only gpiochip_{lock,unlock}_as_irq needs to be called. SPMI and SSBI GPIO are two users that will initially use these functions. Signed-off-by: Brian Masney Suggested-by: Stephen Boyd Reviewed-by: Stephen Boyd --- Changes since v5: - None Changes since v4: - Change '&struct gpiochip' in kernel doc to '&struct gpio_chip' Changes since v3: - Correct kernel doc syntax: 'struct &foo' -> '&struct foo' '&func' -> 'func()' drivers/gpio/gpiolib.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/gpio/driver.h | 5 +++++ 2 files changed, 42 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 1651d7f0a303..361a09c8138a 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1775,6 +1775,43 @@ static const struct irq_domain_ops gpiochip_domain_ops = { .xlate = irq_domain_xlate_twocell, }; +/** + * gpiochip_irq_domain_activate() - Lock a GPIO to be used as an IRQ + * @domain: The IRQ domain used by this IRQ chip + * @data: Outermost irq_data associated with the IRQ + * @reserve: If set, only reserve an interrupt vector instead of assigning one + * + * This function is a wrapper that calls gpiochip_lock_as_irq() and is to be + * used as the activate function for the &struct irq_domain_ops. The host_data + * for the IRQ domain must be the &struct gpio_chip. + */ +int gpiochip_irq_domain_activate(struct irq_domain *domain, + struct irq_data *data, bool reserve) +{ + struct gpio_chip *chip = domain->host_data; + + return gpiochip_lock_as_irq(chip, data->hwirq); +} +EXPORT_SYMBOL_GPL(gpiochip_irq_domain_activate); + +/** + * gpiochip_irq_domain_deactivate() - Unlock a GPIO used as an IRQ + * @domain: The IRQ domain used by this IRQ chip + * @data: Outermost irq_data associated with the IRQ + * + * This function is a wrapper that will call gpiochip_unlock_as_irq() and is to + * be used as the deactivate function for the &struct irq_domain_ops. The + * host_data for the IRQ domain must be the &struct gpio_chip. + */ +void gpiochip_irq_domain_deactivate(struct irq_domain *domain, + struct irq_data *data) +{ + struct gpio_chip *chip = domain->host_data; + + return gpiochip_unlock_as_irq(chip, data->hwirq); +} +EXPORT_SYMBOL_GPL(gpiochip_irq_domain_deactivate); + static int gpiochip_to_irq(struct gpio_chip *chip, unsigned offset) { if (!gpiochip_irqchip_irq_valid(chip, offset)) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 07cddbf45186..01497910f023 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -472,6 +472,11 @@ int gpiochip_irq_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hwirq); void gpiochip_irq_unmap(struct irq_domain *d, unsigned int irq); +int gpiochip_irq_domain_activate(struct irq_domain *domain, + struct irq_data *data, bool reserve); +void gpiochip_irq_domain_deactivate(struct irq_domain *domain, + struct irq_data *data); + void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip, struct irq_chip *irqchip, unsigned int parent_irq, -- 2.17.2