All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Thomas Gleixner <tglx@linutronix.de>,
	Marc Zyngier <marc.zyngier@arm.com>,
	Jonathan Corbet <corbet@lwn.net>
Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	Bartosz Golaszewski <brgl@bgdev.pl>
Subject: [PATCH 4/5] irq: generic-chip: provide devm_irq_alloc_generic_chip()
Date: Wed, 31 May 2017 18:06:59 +0200	[thread overview]
Message-ID: <1496246820-13250-5-git-send-email-brgl@bgdev.pl> (raw)
In-Reply-To: <1496246820-13250-1-git-send-email-brgl@bgdev.pl>

Provide a resource managed variant of irq_alloc_generic_chip().

Signed-off-by: Bartosz Golaszewski <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 a5d298e..c6e70e9 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -952,6 +952,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 <linux/gfp.h>
 #include <linux/irq.h>
 
+#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 */
-- 
2.9.3

  parent reply	other threads:[~2017-05-31 16:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-31 16:06 [PATCH 0/5] irq: generic-chip: resource management improvements Bartosz Golaszewski
2017-05-31 16:06 ` [PATCH 1/5] irq: generic-chip: provide irq_free_generic_chip() Bartosz Golaszewski
2017-06-01 18:59   ` kbuild test robot
2017-06-21 13:58   ` [tip:irq/core] irq/generic-chip: Provide irq_free_generic_chip() tip-bot for Bartosz Golaszewski
2017-05-31 16:06 ` [PATCH 2/5] irq: generic-chip: provide irq_destroy_generic_chip() Bartosz Golaszewski
2017-06-21 13:59   ` [tip:irq/core] irq/generic-chip: Provide irq_destroy_generic_chip() tip-bot for Bartosz Golaszewski
2017-05-31 16:06 ` [PATCH 3/5] irq: generic-chip: export irq_init_generic_chip() locally Bartosz Golaszewski
2017-06-21 13:59   ` [tip:irq/core] irq/generic-chip: Export " tip-bot for Bartosz Golaszewski
2017-05-31 16:06 ` Bartosz Golaszewski [this message]
2017-06-21 14:00   ` [tip:irq/core] irq/generic-chip: Provide devm_irq_alloc_generic_chip() tip-bot for Bartosz Golaszewski
2017-05-31 16:07 ` [PATCH 5/5] irq: generic-chip: provide devm_irq_setup_generic_chip() Bartosz Golaszewski
2017-06-21 14:01   ` [tip:irq/core] irq/generic-chip: Provide devm_irq_setup_generic_chip() tip-bot for Bartosz Golaszewski
2017-06-20 10:31 ` [PATCH 0/5] irq: generic-chip: resource management improvements Bartosz Golaszewski
2017-06-20 10:41   ` Marc Zyngier
2017-06-20 10:47     ` Bartosz Golaszewski
2017-06-20 14:14       ` Thomas Gleixner
2017-06-21 10:35         ` Bartosz Golaszewski
2017-06-21 10:42 ` Marc Zyngier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1496246820-13250-5-git-send-email-brgl@bgdev.pl \
    --to=brgl@bgdev.pl \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.