From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752583AbdFUODr (ORCPT ); Wed, 21 Jun 2017 10:03:47 -0400 Received: from terminus.zytor.com ([65.50.211.136]:52971 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751458AbdFUODp (ORCPT ); Wed, 21 Jun 2017 10:03:45 -0400 Date: Wed, 21 Jun 2017 07:00:27 -0700 From: tip-bot for Bartosz Golaszewski Message-ID: Cc: marc.zyngier@arm.com, mingo@kernel.org, corbet@lwn.net, brgl@bgdev.pl, linux-kernel@vger.kernel.org, tglx@linutronix.de, hpa@zytor.com Reply-To: tglx@linutronix.de, hpa@zytor.com, linux-kernel@vger.kernel.org, brgl@bgdev.pl, corbet@lwn.net, mingo@kernel.org, marc.zyngier@arm.com In-Reply-To: <1496246820-13250-5-git-send-email-brgl@bgdev.pl> References: <1496246820-13250-5-git-send-email-brgl@bgdev.pl> To: linux-tip-commits@vger.kernel.org Subject: [tip:irq/core] irq/generic-chip: Provide devm_irq_alloc_generic_chip() Git-Commit-ID: 1c3e36309fe2e94b8a889fa32cb5c871434f8ed6 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 1c3e36309fe2e94b8a889fa32cb5c871434f8ed6 Gitweb: http://git.kernel.org/tip/1c3e36309fe2e94b8a889fa32cb5c871434f8ed6 Author: Bartosz Golaszewski AuthorDate: Wed, 31 May 2017 18:06:59 +0200 Committer: Thomas Gleixner CommitDate: Wed, 21 Jun 2017 15:53:11 +0200 irq/generic-chip: Provide devm_irq_alloc_generic_chip() Provide a resource managed variant of irq_alloc_generic_chip(). Signed-off-by: Bartosz Golaszewski Signed-off-by: Thomas Gleixner Acked-by: Marc Zyngier Cc: linux-doc@vger.kernel.org Cc: Jonathan Corbet Link: http://lkml.kernel.org/r/1496246820-13250-5-git-send-email-brgl@bgdev.pl --- Documentation/driver-model/devres.txt | 1 + include/linux/irq.h | 5 +++++ kernel/irq/devres.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index e72587f..d473be8 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -311,6 +311,7 @@ IRQ devm_irq_alloc_desc_at() devm_irq_alloc_desc_from() devm_irq_alloc_descs_from() + devm_irq_alloc_generic_chip() LED devm_led_classdev_register() diff --git a/include/linux/irq.h b/include/linux/irq.h index dc63aa1..64ae546 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -958,6 +958,11 @@ int irq_setup_alt_chip(struct irq_data *d, unsigned int type); void irq_remove_generic_chip(struct irq_chip_generic *gc, u32 msk, unsigned int clr, unsigned int set); +struct irq_chip_generic * +devm_irq_alloc_generic_chip(struct device *dev, const char *name, int num_ct, + unsigned int irq_base, void __iomem *reg_base, + irq_flow_handler_t handler); + struct irq_chip_generic *irq_get_domain_generic_chip(struct irq_domain *d, unsigned int hw_irq); int __irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip, diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c index 1613bfd..21ee0ae 100644 --- a/kernel/irq/devres.c +++ b/kernel/irq/devres.c @@ -4,6 +4,8 @@ #include #include +#include "internals.h" + /* * Device resource management aware IRQ request/free implementation. */ @@ -198,3 +200,35 @@ int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from, return base; } EXPORT_SYMBOL_GPL(__devm_irq_alloc_descs); + +#ifdef CONFIG_GENERIC_IRQ_CHIP +/** + * devm_irq_alloc_generic_chip - Allocate and initialize a generic chip + * for a managed device + * @dev: Device to allocate the generic chip for + * @name: Name of the irq chip + * @num_ct: Number of irq_chip_type instances associated with this + * @irq_base: Interrupt base nr for this chip + * @reg_base: Register base address (virtual) + * @handler: Default flow handler associated with this chip + * + * Returns an initialized irq_chip_generic structure. The chip defaults + * to the primary (index 0) irq_chip_type and @handler + */ +struct irq_chip_generic * +devm_irq_alloc_generic_chip(struct device *dev, const char *name, int num_ct, + unsigned int irq_base, void __iomem *reg_base, + irq_flow_handler_t handler) +{ + struct irq_chip_generic *gc; + unsigned long sz = sizeof(*gc) + num_ct * sizeof(struct irq_chip_type); + + gc = devm_kzalloc(dev, sz, GFP_KERNEL); + if (gc) + irq_init_generic_chip(gc, name, num_ct, + irq_base, reg_base, handler); + + return gc; +} +EXPORT_SYMBOL_GPL(devm_irq_alloc_generic_chip); +#endif /* CONFIG_GENERIC_IRQ_CHIP */