linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] irqdomain: clean up, add irq_domain_create_legacy()
@ 2020-10-30 16:59 Andy Shevchenko
  2020-10-30 16:59 ` [PATCH v2 1/5] irqdomain: Remove unused of_device_id forward declaration Andy Shevchenko
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Andy Shevchenko @ 2020-10-30 16:59 UTC (permalink / raw)
  To: Mark Brown, linux-kernel, Greg Kroah-Hartman, Rafael J. Wysocki,
	linux-acpi, Marc Zyngier, Thomas Gleixner
  Cc: Andy Shevchenko

In order to make users OF-independent provide irq_domain_create_legacy() API.

Last patch is an example of such user. First three patches are little cleanups.

Rafael, can you have a look at this series?

Changelog v2:
- rebased on top of v5.10-rc1
- dependency-free (they are in v5.10-rc1)
- added Ack (Mark)

Andy Shevchenko (5):
  irqdomain: Remove unused of_device_id forward declaration
  irqdomain: Add forward declaration of fwnode_handle
  irqdomain: Replace open coded of_node_to_fwnode()
  irqdomain: Introduce irq_domain_create_legacy() API
  regmap: irq: Convert to use fwnode directly

 Documentation/core-api/irq/irq-domain.rst |  6 ++++++
 drivers/base/regmap/regmap-irq.c          | 11 +++++------
 include/linux/irqdomain.h                 |  8 +++++++-
 kernel/irq/irqdomain.c                    | 19 +++++++++++++++----
 4 files changed, 33 insertions(+), 11 deletions(-)

-- 
2.28.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/5] irqdomain: Remove unused of_device_id forward declaration
  2020-10-30 16:59 [PATCH v2 0/5] irqdomain: clean up, add irq_domain_create_legacy() Andy Shevchenko
@ 2020-10-30 16:59 ` Andy Shevchenko
  2020-10-30 16:59 ` [PATCH v2 2/5] irqdomain: Add forward declaration of fwnode_handle Andy Shevchenko
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2020-10-30 16:59 UTC (permalink / raw)
  To: Mark Brown, linux-kernel, Greg Kroah-Hartman, Rafael J. Wysocki,
	linux-acpi, Marc Zyngier, Thomas Gleixner
  Cc: Andy Shevchenko

There is no users of of_device_id in irqdomain.h. Drop it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/irqdomain.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 71535e87109f..56642188ec21 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -38,7 +38,6 @@
 
 struct device_node;
 struct irq_domain;
-struct of_device_id;
 struct irq_chip;
 struct irq_data;
 struct cpumask;
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/5] irqdomain: Add forward declaration of fwnode_handle
  2020-10-30 16:59 [PATCH v2 0/5] irqdomain: clean up, add irq_domain_create_legacy() Andy Shevchenko
  2020-10-30 16:59 ` [PATCH v2 1/5] irqdomain: Remove unused of_device_id forward declaration Andy Shevchenko
@ 2020-10-30 16:59 ` Andy Shevchenko
  2020-10-30 16:59 ` [PATCH v2 3/5] irqdomain: Replace open coded of_node_to_fwnode() Andy Shevchenko
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2020-10-30 16:59 UTC (permalink / raw)
  To: Mark Brown, linux-kernel, Greg Kroah-Hartman, Rafael J. Wysocki,
	linux-acpi, Marc Zyngier, Thomas Gleixner
  Cc: Andy Shevchenko

irqdomain.h is a user of struct fwnode_handle. Add forward declaration of it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/irqdomain.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 56642188ec21..d21f75d294d7 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -37,6 +37,7 @@
 #include <linux/radix-tree.h>
 
 struct device_node;
+struct fwnode_handle;
 struct irq_domain;
 struct irq_chip;
 struct irq_data;
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/5] irqdomain: Replace open coded of_node_to_fwnode()
  2020-10-30 16:59 [PATCH v2 0/5] irqdomain: clean up, add irq_domain_create_legacy() Andy Shevchenko
  2020-10-30 16:59 ` [PATCH v2 1/5] irqdomain: Remove unused of_device_id forward declaration Andy Shevchenko
  2020-10-30 16:59 ` [PATCH v2 2/5] irqdomain: Add forward declaration of fwnode_handle Andy Shevchenko
@ 2020-10-30 16:59 ` Andy Shevchenko
  2020-10-30 16:59 ` [PATCH v2 4/5] irqdomain: Introduce irq_domain_create_legacy() API Andy Shevchenko
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2020-10-30 16:59 UTC (permalink / raw)
  To: Mark Brown, linux-kernel, Greg Kroah-Hartman, Rafael J. Wysocki,
	linux-acpi, Marc Zyngier, Thomas Gleixner
  Cc: Andy Shevchenko

We can convert device node to fwnode with of_node_to_fwnode().
Replace open coded variant of it in of_phandle_args_to_fwspec().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 kernel/irq/irqdomain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index cf8b374b892d..831526f2e728 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -737,7 +737,7 @@ static void of_phandle_args_to_fwspec(struct device_node *np, const u32 *args,
 {
 	int i;
 
-	fwspec->fwnode = np ? &np->fwnode : NULL;
+	fwspec->fwnode = of_node_to_fwnode(np);
 	fwspec->param_count = count;
 
 	for (i = 0; i < count; i++)
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 4/5] irqdomain: Introduce irq_domain_create_legacy() API
  2020-10-30 16:59 [PATCH v2 0/5] irqdomain: clean up, add irq_domain_create_legacy() Andy Shevchenko
                   ` (2 preceding siblings ...)
  2020-10-30 16:59 ` [PATCH v2 3/5] irqdomain: Replace open coded of_node_to_fwnode() Andy Shevchenko
@ 2020-10-30 16:59 ` Andy Shevchenko
  2020-10-30 16:59 ` [PATCH v2 5/5] regmap: irq: Convert to use fwnode directly Andy Shevchenko
  2020-11-02 19:23 ` [PATCH v2 0/5] irqdomain: clean up, add irq_domain_create_legacy() Rafael J. Wysocki
  5 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2020-10-30 16:59 UTC (permalink / raw)
  To: Mark Brown, linux-kernel, Greg Kroah-Hartman, Rafael J. Wysocki,
	linux-acpi, Marc Zyngier, Thomas Gleixner
  Cc: Andy Shevchenko

Introduce irq_domain_create_legacy() API which is functional equivalent
to the existing irq_domain_add_legacy(), but takes a pointer to the struct
fwnode_handle as a parameter.

Some users want to use it in non-OF cases.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 Documentation/core-api/irq/irq-domain.rst |  6 ++++++
 include/linux/irqdomain.h                 |  6 ++++++
 kernel/irq/irqdomain.c                    | 17 ++++++++++++++---
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/Documentation/core-api/irq/irq-domain.rst b/Documentation/core-api/irq/irq-domain.rst
index 096db12f32d5..a77c24c27f7b 100644
--- a/Documentation/core-api/irq/irq-domain.rst
+++ b/Documentation/core-api/irq/irq-domain.rst
@@ -147,6 +147,7 @@ Legacy
 	irq_domain_add_simple()
 	irq_domain_add_legacy()
 	irq_domain_add_legacy_isa()
+	irq_domain_create_legacy()
 
 The Legacy mapping is a special case for drivers that already have a
 range of irq_descs allocated for the hwirqs.  It is used when the
@@ -185,6 +186,11 @@ that the driver using the simple domain call irq_create_mapping()
 before any irq_find_mapping() since the latter will actually work
 for the static IRQ assignment case.
 
+irq_domain_add_legacy() and irq_domain_create_legacy() are functionally
+equivalent, except for the first argument is different - the former
+accepts an Open Firmware specific 'struct device_node', while the latter
+accepts a more general abstraction 'struct fwnode_handle'.
+
 Hierarchy IRQ domain
 --------------------
 
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index d21f75d294d7..77bf7d84c673 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -271,6 +271,12 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
 					 irq_hw_number_t first_hwirq,
 					 const struct irq_domain_ops *ops,
 					 void *host_data);
+struct irq_domain *irq_domain_create_legacy(struct fwnode_handle *fwnode,
+					    unsigned int size,
+					    unsigned int first_irq,
+					    irq_hw_number_t first_hwirq,
+					    const struct irq_domain_ops *ops,
+					    void *host_data);
 extern struct irq_domain *irq_find_matching_fwspec(struct irq_fwspec *fwspec,
 						   enum irq_domain_bus_token bus_token);
 extern bool irq_domain_check_msi_remap(void);
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 831526f2e728..9c9cb8829f7a 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -350,17 +350,28 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
 					 irq_hw_number_t first_hwirq,
 					 const struct irq_domain_ops *ops,
 					 void *host_data)
+{
+	return irq_domain_create_legacy(of_node_to_fwnode(of_node), size,
+					first_irq, first_hwirq, ops, host_data);
+}
+EXPORT_SYMBOL_GPL(irq_domain_add_legacy);
+
+struct irq_domain *irq_domain_create_legacy(struct fwnode_handle *fwnode,
+					 unsigned int size,
+					 unsigned int first_irq,
+					 irq_hw_number_t first_hwirq,
+					 const struct irq_domain_ops *ops,
+					 void *host_data)
 {
 	struct irq_domain *domain;
 
-	domain = __irq_domain_add(of_node_to_fwnode(of_node), first_hwirq + size,
-				  first_hwirq + size, 0, ops, host_data);
+	domain = __irq_domain_add(fwnode, first_hwirq + size, first_hwirq + size, 0, ops, host_data);
 	if (domain)
 		irq_domain_associate_many(domain, first_irq, first_hwirq, size);
 
 	return domain;
 }
-EXPORT_SYMBOL_GPL(irq_domain_add_legacy);
+EXPORT_SYMBOL_GPL(irq_domain_create_legacy);
 
 /**
  * irq_find_matching_fwspec() - Locates a domain for a given fwspec
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 5/5] regmap: irq: Convert to use fwnode directly
  2020-10-30 16:59 [PATCH v2 0/5] irqdomain: clean up, add irq_domain_create_legacy() Andy Shevchenko
                   ` (3 preceding siblings ...)
  2020-10-30 16:59 ` [PATCH v2 4/5] irqdomain: Introduce irq_domain_create_legacy() API Andy Shevchenko
@ 2020-10-30 16:59 ` Andy Shevchenko
  2020-11-02 19:23 ` [PATCH v2 0/5] irqdomain: clean up, add irq_domain_create_legacy() Rafael J. Wysocki
  5 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2020-10-30 16:59 UTC (permalink / raw)
  To: Mark Brown, linux-kernel, Greg Kroah-Hartman, Rafael J. Wysocki,
	linux-acpi, Marc Zyngier, Thomas Gleixner
  Cc: Andy Shevchenko

Since IRQ domain provides an API to take fwnode as a parameter,
switch regmap IRQ to use that directly instead of be limited
to OF case only.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
---
 drivers/base/regmap/regmap-irq.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index ad5c2de395d1..19db764ffa4a 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -803,13 +803,12 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 	}
 
 	if (irq_base)
-		d->domain = irq_domain_add_legacy(to_of_node(fwnode),
-						  chip->num_irqs, irq_base,
-						  0, &regmap_domain_ops, d);
+		d->domain = irq_domain_create_legacy(fwnode, chip->num_irqs,
+						     irq_base, 0,
+						     &regmap_domain_ops, d);
 	else
-		d->domain = irq_domain_add_linear(to_of_node(fwnode),
-						  chip->num_irqs,
-						  &regmap_domain_ops, d);
+		d->domain = irq_domain_create_linear(fwnode, chip->num_irqs,
+						     &regmap_domain_ops, d);
 	if (!d->domain) {
 		dev_err(map->dev, "Failed to create IRQ domain\n");
 		ret = -ENOMEM;
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/5] irqdomain: clean up, add irq_domain_create_legacy()
  2020-10-30 16:59 [PATCH v2 0/5] irqdomain: clean up, add irq_domain_create_legacy() Andy Shevchenko
                   ` (4 preceding siblings ...)
  2020-10-30 16:59 ` [PATCH v2 5/5] regmap: irq: Convert to use fwnode directly Andy Shevchenko
@ 2020-11-02 19:23 ` Rafael J. Wysocki
  5 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2020-11-02 19:23 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Mark Brown, Linux Kernel Mailing List, Greg Kroah-Hartman,
	Rafael J. Wysocki, ACPI Devel Maling List, Marc Zyngier,
	Thomas Gleixner

On Fri, Oct 30, 2020 at 5:59 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> In order to make users OF-independent provide irq_domain_create_legacy() API.
>
> Last patch is an example of such user. First three patches are little cleanups.
>
> Rafael, can you have a look at this series?

Done.

Feel free to add

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

to all of the patches in it.

Thanks!

> Changelog v2:
> - rebased on top of v5.10-rc1
> - dependency-free (they are in v5.10-rc1)
> - added Ack (Mark)
>
> Andy Shevchenko (5):
>   irqdomain: Remove unused of_device_id forward declaration
>   irqdomain: Add forward declaration of fwnode_handle
>   irqdomain: Replace open coded of_node_to_fwnode()
>   irqdomain: Introduce irq_domain_create_legacy() API
>   regmap: irq: Convert to use fwnode directly
>
>  Documentation/core-api/irq/irq-domain.rst |  6 ++++++
>  drivers/base/regmap/regmap-irq.c          | 11 +++++------
>  include/linux/irqdomain.h                 |  8 +++++++-
>  kernel/irq/irqdomain.c                    | 19 +++++++++++++++----
>  4 files changed, 33 insertions(+), 11 deletions(-)
>
> --
> 2.28.0
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-11-02 19:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-30 16:59 [PATCH v2 0/5] irqdomain: clean up, add irq_domain_create_legacy() Andy Shevchenko
2020-10-30 16:59 ` [PATCH v2 1/5] irqdomain: Remove unused of_device_id forward declaration Andy Shevchenko
2020-10-30 16:59 ` [PATCH v2 2/5] irqdomain: Add forward declaration of fwnode_handle Andy Shevchenko
2020-10-30 16:59 ` [PATCH v2 3/5] irqdomain: Replace open coded of_node_to_fwnode() Andy Shevchenko
2020-10-30 16:59 ` [PATCH v2 4/5] irqdomain: Introduce irq_domain_create_legacy() API Andy Shevchenko
2020-10-30 16:59 ` [PATCH v2 5/5] regmap: irq: Convert to use fwnode directly Andy Shevchenko
2020-11-02 19:23 ` [PATCH v2 0/5] irqdomain: clean up, add irq_domain_create_legacy() Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).