The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org
Cc: Herve Codina <herve.codina@bootlin.com>, Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH v1 1/2] irqdomain: Unify checks for bus_token
Date: Tue, 13 Aug 2024 12:41:24 +0300	[thread overview]
Message-ID: <0c68db10-5d3a-4fdb-ae7a-6465d17c0712@gmail.com> (raw)
In-Reply-To: <20240812193101.1266625-2-andriy.shevchenko@linux.intel.com>

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! ~~


  parent reply	other threads:[~2024-08-13  9:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Matti Vaittinen [this message]
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

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=0c68db10-5d3a-4fdb-ae7a-6465d17c0712@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=herve.codina@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox