[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0c68db10-5d3a-4fdb-ae7a-6465d17c0712@gmail.com>
Date: Tue, 13 Aug 2024 12:41:24 +0300
From: Matti Vaittinen <mazziesaccount@...il.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>, linux-kernel@...r.kernel.org
Cc: Herve Codina <herve.codina@...tlin.com>, Mark Brown <broonie@...nel.org>
Subject: Re: [PATCH v1 1/2] irqdomain: Unify checks for bus_token
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@...ux.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@...il.com>
Yours,
-- Matti
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
Powered by blists - more mailing lists