* [PATCH v1 0/2] irqdomain: A couple of fixes
@ 2024-08-12 19:29 Andy Shevchenko
2024-08-12 19:29 ` [PATCH v1 1/2] irqdomain: Unify checks for bus_token Andy Shevchenko
2024-08-12 19:29 ` [PATCH v1 2/2] irqdomain: Remove stray '-' in the IRQ domain name Andy Shevchenko
0 siblings, 2 replies; 9+ messages in thread
From: Andy Shevchenko @ 2024-08-12 19:29 UTC (permalink / raw)
To: Thomas Gleixner, linux-kernel
Cc: Herve Codina, Matti Vaittinen, Mark Brown, Andy Shevchenko
Recently added code has some issues of different severities.
Here are the fixes.
Assuming Thomas has an immutable branch/tag, I think it's worth
to pull them there, so if regmap needs that code it will be fixed.
Andy Shevchenko (2):
irqdomain: Unify checks for bus_token
irqdomain: Remove stray '-' in the IRQ domain name
kernel/irq/irqdomain.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v1 1/2] irqdomain: Unify checks for bus_token
2024-08-12 19:29 [PATCH v1 0/2] irqdomain: A couple of fixes Andy Shevchenko
@ 2024-08-12 19:29 ` Andy Shevchenko
2024-08-13 8:32 ` Thomas Gleixner
` (2 more replies)
2024-08-12 19:29 ` [PATCH v1 2/2] irqdomain: Remove stray '-' in the IRQ domain name Andy Shevchenko
1 sibling, 3 replies; 9+ messages in thread
From: Andy Shevchenko @ 2024-08-12 19:29 UTC (permalink / raw)
To: Thomas Gleixner, linux-kernel
Cc: Herve Codina, Matti Vaittinen, Mark Brown, Andy Shevchenko
The code uses if (bus_token) and if (bus_token == DOMAIN_BUS_ANY).
Since bus_token is enum, the later is more robust against changes.
Unify all checks to follow the latter variant.
Fixes: 0b21add71bd9 ("irqdomain: Handle domain bus token in irq_domain_create()")
Fixes: 1bf2c9282927 ("irqdomain: Cleanup domain name allocation")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
kernel/irq/irqdomain.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 01001eb615ec..18d253e10e87 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -130,8 +130,10 @@ EXPORT_SYMBOL_GPL(irq_domain_free_fwnode);
static int alloc_name(struct irq_domain *domain, char *base, enum irq_domain_bus_token bus_token)
{
- domain->name = bus_token ? kasprintf(GFP_KERNEL, "%s-%d", base, bus_token) :
- kasprintf(GFP_KERNEL, "%s", base);
+ if (bus_token == DOMAIN_BUS_ANY)
+ domain->name = kasprintf(GFP_KERNEL, "%s", base);
+ else
+ domain->name = kasprintf(GFP_KERNEL, "%s-%d", base, bus_token);
if (!domain->name)
return -ENOMEM;
@@ -146,8 +148,10 @@ static int alloc_fwnode_name(struct irq_domain *domain, const struct fwnode_hand
const char *suf = suffix ? : "";
char *name;
- name = bus_token ? kasprintf(GFP_KERNEL, "%pfw-%s%s%d", fwnode, suf, sep, bus_token) :
- kasprintf(GFP_KERNEL, "%pfw-%s", fwnode, suf);
+ if (bus_token == DOMAIN_BUS_ANY)
+ name = kasprintf(GFP_KERNEL, "%pfw-%s", fwnode, suf);
+ else
+ name = kasprintf(GFP_KERNEL, "%pfw-%s%s%d", fwnode, suf, sep, bus_token);
if (!name)
return -ENOMEM;
@@ -166,11 +170,13 @@ static int alloc_unknown_name(struct irq_domain *domain, enum irq_domain_bus_tok
static atomic_t unknown_domains;
int id = atomic_inc_return(&unknown_domains);
- domain->name = bus_token ? kasprintf(GFP_KERNEL, "unknown-%d-%d", id, bus_token) :
- kasprintf(GFP_KERNEL, "unknown-%d", id);
-
+ if (bus_token == DOMAIN_BUS_ANY)
+ domain->name = kasprintf(GFP_KERNEL, "unknown-%d", id);
+ else
+ domain->name = kasprintf(GFP_KERNEL, "unknown-%d-%d", id, bus_token);
if (!domain->name)
return -ENOMEM;
+
domain->flags |= IRQ_DOMAIN_NAME_ALLOCATED;
return 0;
}
@@ -200,7 +206,7 @@ static int irq_domain_set_name(struct irq_domain *domain, const struct irq_domai
return alloc_name(domain, fwid->name, bus_token);
default:
domain->name = fwid->name;
- if (bus_token)
+ if (bus_token != DOMAIN_BUS_ANY)
return alloc_name(domain, fwid->name, bus_token);
}
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 2/2] irqdomain: Remove stray '-' in the IRQ domain name
2024-08-12 19:29 [PATCH v1 0/2] irqdomain: A couple of fixes Andy Shevchenko
2024-08-12 19:29 ` [PATCH v1 1/2] irqdomain: Unify checks for bus_token Andy Shevchenko
@ 2024-08-12 19:29 ` Andy Shevchenko
2024-08-13 8:47 ` [tip: irq/core] irqdomain: Remove stray '-' in the " tip-bot2 for Andy Shevchenko
2024-08-13 9:46 ` [PATCH v1 2/2] irqdomain: Remove stray '-' in the IRQ " Matti Vaittinen
1 sibling, 2 replies; 9+ messages in thread
From: Andy Shevchenko @ 2024-08-12 19:29 UTC (permalink / raw)
To: Thomas Gleixner, linux-kernel
Cc: Herve Codina, Matti Vaittinen, Mark Brown, Andy Shevchenko
When domain suffix is not supplied the fwnode case (not irqchip-fwnode)
uses alloc_fwnode_name(). This currently unconditionally adds a
separator. Fix the logic to make it conditional and drop stray '-' in
the IRQ domain name.
Fixes: 1e7c05292531 ("irqdomain: Allow giving name suffix for domain")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
kernel/irq/irqdomain.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 18d253e10e87..1acc5308fcb7 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -149,9 +149,9 @@ static int alloc_fwnode_name(struct irq_domain *domain, const struct fwnode_hand
char *name;
if (bus_token == DOMAIN_BUS_ANY)
- name = kasprintf(GFP_KERNEL, "%pfw-%s", fwnode, suf);
+ name = kasprintf(GFP_KERNEL, "%pfw%s%s", fwnode, sep, suf);
else
- name = kasprintf(GFP_KERNEL, "%pfw-%s%s%d", fwnode, suf, sep, bus_token);
+ name = kasprintf(GFP_KERNEL, "%pfw%s%s-%d", fwnode, sep, suf, bus_token);
if (!name)
return -ENOMEM;
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/2] irqdomain: Unify checks for bus_token
2024-08-12 19:29 ` [PATCH v1 1/2] irqdomain: Unify checks for bus_token Andy Shevchenko
@ 2024-08-13 8:32 ` Thomas Gleixner
2024-08-13 8:58 ` Andy Shevchenko
2024-08-13 8:47 ` [tip: irq/core] irqdomain: Clarify " tip-bot2 for Andy Shevchenko
2024-08-13 9:41 ` [PATCH v1 1/2] irqdomain: Unify " Matti Vaittinen
2 siblings, 1 reply; 9+ messages in thread
From: Thomas Gleixner @ 2024-08-13 8:32 UTC (permalink / raw)
To: Andy Shevchenko, linux-kernel
Cc: Herve Codina, Matti Vaittinen, Mark Brown, Andy Shevchenko
On Mon, Aug 12 2024 at 22:29, Andy Shevchenko wrote:
> The code uses if (bus_token) and if (bus_token == DOMAIN_BUS_ANY).
> Since bus_token is enum, the later is more robust against changes.
> Unify all checks to follow the latter variant.
>
> Fixes: 0b21add71bd9 ("irqdomain: Handle domain bus token in irq_domain_create()")
> Fixes: 1bf2c9282927 ("irqdomain: Cleanup domain name allocation")
I'm fine with the change per se, but what does this fix? It's correct
code, no?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [tip: irq/core] irqdomain: Remove stray '-' in the domain name
2024-08-12 19:29 ` [PATCH v1 2/2] irqdomain: Remove stray '-' in the IRQ domain name Andy Shevchenko
@ 2024-08-13 8:47 ` tip-bot2 for Andy Shevchenko
2024-08-13 9:46 ` [PATCH v1 2/2] irqdomain: Remove stray '-' in the IRQ " Matti Vaittinen
1 sibling, 0 replies; 9+ messages in thread
From: tip-bot2 for Andy Shevchenko @ 2024-08-13 8:47 UTC (permalink / raw)
To: linux-tip-commits
Cc: Andy Shevchenko, Thomas Gleixner, x86, linux-kernel, maz
The following commit has been merged into the irq/core branch of tip:
Commit-ID: 7b9414cb2d370b7c5149b37f585b077af2ae211b
Gitweb: https://git.kernel.org/tip/7b9414cb2d370b7c5149b37f585b077af2ae211b
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
AuthorDate: Mon, 12 Aug 2024 22:29:40 +03:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Tue, 13 Aug 2024 10:40:10 +02:00
irqdomain: Remove stray '-' in the domain name
When the domain suffix is not supplied alloc_fwnode_name() unconditionally
adds a separator.
Fix the format strings to get rid of the stray '-' separator.
Fixes: 1e7c05292531 ("irqdomain: Allow giving name suffix for domain")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20240812193101.1266625-3-andriy.shevchenko@linux.intel.com
---
kernel/irq/irqdomain.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 18d253e..1acc530 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -149,9 +149,9 @@ static int alloc_fwnode_name(struct irq_domain *domain, const struct fwnode_hand
char *name;
if (bus_token == DOMAIN_BUS_ANY)
- name = kasprintf(GFP_KERNEL, "%pfw-%s", fwnode, suf);
+ name = kasprintf(GFP_KERNEL, "%pfw%s%s", fwnode, sep, suf);
else
- name = kasprintf(GFP_KERNEL, "%pfw-%s%s%d", fwnode, suf, sep, bus_token);
+ name = kasprintf(GFP_KERNEL, "%pfw%s%s-%d", fwnode, sep, suf, bus_token);
if (!name)
return -ENOMEM;
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [tip: irq/core] irqdomain: Clarify checks for bus_token
2024-08-12 19:29 ` [PATCH v1 1/2] irqdomain: Unify checks for bus_token Andy Shevchenko
2024-08-13 8:32 ` Thomas Gleixner
@ 2024-08-13 8:47 ` tip-bot2 for Andy Shevchenko
2024-08-13 9:41 ` [PATCH v1 1/2] irqdomain: Unify " Matti Vaittinen
2 siblings, 0 replies; 9+ messages in thread
From: tip-bot2 for Andy Shevchenko @ 2024-08-13 8:47 UTC (permalink / raw)
To: linux-tip-commits
Cc: Andy Shevchenko, Thomas Gleixner, x86, linux-kernel, maz
The following commit has been merged into the irq/core branch of tip:
Commit-ID: c0ece64497992473aabbcbb007e2afecc8d750a2
Gitweb: https://git.kernel.org/tip/c0ece64497992473aabbcbb007e2afecc8d750a2
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
AuthorDate: Mon, 12 Aug 2024 22:29:39 +03:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Tue, 13 Aug 2024 10:40:09 +02:00
irqdomain: Clarify checks for bus_token
The code uses if (bus_token) and if (bus_token == DOMAIN_BUS_ANY).
Since bus_token is an enum, the latter is more robust against changes.
Convert all !bus_token checks to explicitely check for DOMAIN_BUS_ANY.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20240812193101.1266625-2-andriy.shevchenko@linux.intel.com
---
kernel/irq/irqdomain.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 01001eb..18d253e 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -130,8 +130,10 @@ EXPORT_SYMBOL_GPL(irq_domain_free_fwnode);
static int alloc_name(struct irq_domain *domain, char *base, enum irq_domain_bus_token bus_token)
{
- domain->name = bus_token ? kasprintf(GFP_KERNEL, "%s-%d", base, bus_token) :
- kasprintf(GFP_KERNEL, "%s", base);
+ if (bus_token == DOMAIN_BUS_ANY)
+ domain->name = kasprintf(GFP_KERNEL, "%s", base);
+ else
+ domain->name = kasprintf(GFP_KERNEL, "%s-%d", base, bus_token);
if (!domain->name)
return -ENOMEM;
@@ -146,8 +148,10 @@ static int alloc_fwnode_name(struct irq_domain *domain, const struct fwnode_hand
const char *suf = suffix ? : "";
char *name;
- name = bus_token ? kasprintf(GFP_KERNEL, "%pfw-%s%s%d", fwnode, suf, sep, bus_token) :
- kasprintf(GFP_KERNEL, "%pfw-%s", fwnode, suf);
+ if (bus_token == DOMAIN_BUS_ANY)
+ name = kasprintf(GFP_KERNEL, "%pfw-%s", fwnode, suf);
+ else
+ name = kasprintf(GFP_KERNEL, "%pfw-%s%s%d", fwnode, suf, sep, bus_token);
if (!name)
return -ENOMEM;
@@ -166,11 +170,13 @@ static int alloc_unknown_name(struct irq_domain *domain, enum irq_domain_bus_tok
static atomic_t unknown_domains;
int id = atomic_inc_return(&unknown_domains);
- domain->name = bus_token ? kasprintf(GFP_KERNEL, "unknown-%d-%d", id, bus_token) :
- kasprintf(GFP_KERNEL, "unknown-%d", id);
-
+ if (bus_token == DOMAIN_BUS_ANY)
+ domain->name = kasprintf(GFP_KERNEL, "unknown-%d", id);
+ else
+ domain->name = kasprintf(GFP_KERNEL, "unknown-%d-%d", id, bus_token);
if (!domain->name)
return -ENOMEM;
+
domain->flags |= IRQ_DOMAIN_NAME_ALLOCATED;
return 0;
}
@@ -200,7 +206,7 @@ static int irq_domain_set_name(struct irq_domain *domain, const struct irq_domai
return alloc_name(domain, fwid->name, bus_token);
default:
domain->name = fwid->name;
- if (bus_token)
+ if (bus_token != DOMAIN_BUS_ANY)
return alloc_name(domain, fwid->name, bus_token);
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/2] irqdomain: Unify checks for bus_token
2024-08-13 8:32 ` Thomas Gleixner
@ 2024-08-13 8:58 ` Andy Shevchenko
0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2024-08-13 8:58 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: linux-kernel, Herve Codina, Matti Vaittinen, Mark Brown
On Tue, Aug 13, 2024 at 10:32:44AM +0200, Thomas Gleixner wrote:
> On Mon, Aug 12 2024 at 22:29, Andy Shevchenko wrote:
> > The code uses if (bus_token) and if (bus_token == DOMAIN_BUS_ANY).
> > Since bus_token is enum, the later is more robust against changes.
> > Unify all checks to follow the latter variant.
> >
> > Fixes: 0b21add71bd9 ("irqdomain: Handle domain bus token in irq_domain_create()")
> > Fixes: 1bf2c9282927 ("irqdomain: Cleanup domain name allocation")
>
> I'm fine with the change per se, but what does this fix? It's correct
> code, no?
Technically yes, it's correct code as long as nobody touches the mentioned enum.
It fixes the style and makes it robust against the changes.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/2] irqdomain: Unify checks for bus_token
2024-08-12 19:29 ` [PATCH v1 1/2] irqdomain: Unify checks for bus_token Andy Shevchenko
2024-08-13 8:32 ` Thomas Gleixner
2024-08-13 8:47 ` [tip: irq/core] irqdomain: Clarify " tip-bot2 for Andy Shevchenko
@ 2024-08-13 9:41 ` Matti Vaittinen
2 siblings, 0 replies; 9+ messages in thread
From: Matti Vaittinen @ 2024-08-13 9:41 UTC (permalink / raw)
To: Andy Shevchenko, Thomas Gleixner, linux-kernel; +Cc: Herve Codina, Mark Brown
On 8/12/24 22:29, Andy Shevchenko wrote:
> The code uses if (bus_token) and if (bus_token == DOMAIN_BUS_ANY).
> Since bus_token is enum, the later is more robust against changes.
> Unify all checks to follow the latter variant.
I don't really have a strong opinion on this but for me the
if (bus_token) reads better. Te bus_token is either set (and set to
something else but zero), or not. This logic is nicely reflected by the
check 'if (bus_token)'. Still, I suppose the 'DOMAIN_BUS_ANY' is for a
reason, and some people indeed claim that consistency matters ;)
> Fixes: 0b21add71bd9 ("irqdomain: Handle domain bus token in irq_domain_create()")
> Fixes: 1bf2c9282927 ("irqdomain: Cleanup domain name allocation")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> kernel/irq/irqdomain.c | 22 ++++++++++++++--------
> 1 file changed, 14 insertions(+), 8 deletions(-)
>
> diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
> index 01001eb615ec..18d253e10e87 100644
> --- a/kernel/irq/irqdomain.c
> +++ b/kernel/irq/irqdomain.c
> @@ -130,8 +130,10 @@ EXPORT_SYMBOL_GPL(irq_domain_free_fwnode);
>
> static int alloc_name(struct irq_domain *domain, char *base, enum irq_domain_bus_token bus_token)
> {
> - domain->name = bus_token ? kasprintf(GFP_KERNEL, "%s-%d", base, bus_token) :
> - kasprintf(GFP_KERNEL, "%s", base);
> + if (bus_token == DOMAIN_BUS_ANY)
> + domain->name = kasprintf(GFP_KERNEL, "%s", base);
> + else
> + domain->name = kasprintf(GFP_KERNEL, "%s-%d", base, bus_token);
You could do:
domain->name = bus_token == DOMAIN_BUS_ANY ? kasprintf(...
to squeeze this a bit more compact (and to maintain the previous style)
- but my personal preference is to not have a ternary. Well, again
nothing I would have a really strong opinion.
Anyways, the logic looks solid to me so, FWIW:
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
Yours,
-- Matti
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 2/2] irqdomain: Remove stray '-' in the IRQ domain name
2024-08-12 19:29 ` [PATCH v1 2/2] irqdomain: Remove stray '-' in the IRQ domain name Andy Shevchenko
2024-08-13 8:47 ` [tip: irq/core] irqdomain: Remove stray '-' in the " tip-bot2 for Andy Shevchenko
@ 2024-08-13 9:46 ` Matti Vaittinen
1 sibling, 0 replies; 9+ messages in thread
From: Matti Vaittinen @ 2024-08-13 9:46 UTC (permalink / raw)
To: Andy Shevchenko, Thomas Gleixner, linux-kernel; +Cc: Herve Codina, Mark Brown
On 8/12/24 22:29, Andy Shevchenko wrote:
> When domain suffix is not supplied the fwnode case (not irqchip-fwnode)
> uses alloc_fwnode_name(). This currently unconditionally adds a
> separator. Fix the logic to make it conditional and drop stray '-' in
> the IRQ domain name.
>
> Fixes: 1e7c05292531 ("irqdomain: Allow giving name suffix for domain")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks Andy.
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
Yours,
-- Matti
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-08-13 9:46 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-12 19:29 [PATCH v1 0/2] irqdomain: A couple of fixes Andy Shevchenko
2024-08-12 19:29 ` [PATCH v1 1/2] irqdomain: Unify checks for bus_token Andy Shevchenko
2024-08-13 8:32 ` Thomas Gleixner
2024-08-13 8:58 ` Andy Shevchenko
2024-08-13 8:47 ` [tip: irq/core] irqdomain: Clarify " tip-bot2 for Andy Shevchenko
2024-08-13 9:41 ` [PATCH v1 1/2] irqdomain: Unify " Matti Vaittinen
2024-08-12 19:29 ` [PATCH v1 2/2] irqdomain: Remove stray '-' in the IRQ domain name Andy Shevchenko
2024-08-13 8:47 ` [tip: irq/core] irqdomain: Remove stray '-' in the " tip-bot2 for Andy Shevchenko
2024-08-13 9:46 ` [PATCH v1 2/2] irqdomain: Remove stray '-' in the IRQ " Matti Vaittinen
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.