public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Cc: Rob Herring <robh+dt@kernel.org>,
	Nicolas Saenz Julienne <nsaenz@kernel.org>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	bcm-kernel-feedback-list@broadcom.com,
	Chris Brandt <chris.brandt@renesas.com>,
	linux-i2c@vger.kernel.org, linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Prabhakar <prabhakar.csengg@gmail.com>
Subject: Re: [PATCH 2/3] i2c: sh_mobile: Use platform_get_irq_optional() to get the interrupt
Date: Mon, 20 Dec 2021 11:16:18 +0100	[thread overview]
Message-ID: <YcBX8iLzFaztwkeo@ninjato> (raw)
In-Reply-To: <20211218165258.16716-3-prabhakar.mahadev-lad.rj@bp.renesas.com>

[-- Attachment #1: Type: text/plain, Size: 1709 bytes --]

Hi Prabhakar,

> +	if (!np) {

Very minor nit: Maybe 'if (np)' and switch the blocks? Positive logic is
a tad easier to read.

> +		struct resource *res;
> +		resource_size_t n;
> +
> +		while ((res = platform_get_resource(dev, IORESOURCE_IRQ, k))) {
> +			for (n = res->start; n <= res->end; n++) {
> +				ret = devm_request_irq(&dev->dev, n, sh_mobile_i2c_isr,
> +						       0, dev_name(&dev->dev), pd);
> +				if (ret) {
> +					dev_err(&dev->dev, "cannot request IRQ %pa\n", &n);
> +					return ret;
> +				}
> +			}
> +			k++;
> +		}

Yeah, it is good to keep the legacy block as is.

> +		do {
> +			irq = platform_get_irq_optional(dev, k);
> +			if (irq <= 0 && irq != -ENXIO)
> +				return irq ? irq : -ENXIO;
> +			if (irq == -ENXIO)
> +				break;
> +			ret = devm_request_irq(&dev->dev, irq, sh_mobile_i2c_isr,
> +					       0, dev_name(&dev->dev), pd);
>  			if (ret) {
> -				dev_err(&dev->dev, "cannot request IRQ %pa\n", &n);
> +				dev_err(&dev->dev, "cannot request IRQ %d\n", irq);
>  				return ret;
>  			}
> -		}
> -		k++;
> +			k++;
> +		} while (irq);

In addition to the 'irq == 0' case from patch 1, I tried to shorten the
block for the np-case. I only came up with this. The assigntment and
comparison of the while-argument is not exactly pretty, but the block
itself is easier to read. I'll let you decide.

		while (irq = platform_get_irq_optional(dev, k) != -ENXIO) {
			if (irq < 0)
				return irq;

			ret = devm_request_irq(&dev->dev, irq, sh_mobile_i2c_isr,
					       0, dev_name(&dev->dev), pd);
			if (ret) {
				dev_err(&dev->dev, "cannot request IRQ %d\n", irq);
				return ret;
			}
			k++;
		}

Only brainstorming, not even build tested.

All the best,

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-12-20 10:16 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-18 16:52 [PATCH 0/3] i2c/busses: Use platform_get_irq/_optional() variants to fetch IRQ's Lad Prabhakar
2021-12-18 16:52 ` [PATCH 1/3] i2c: bcm2835: Use platform_get_irq() to get the interrupt Lad Prabhakar
2021-12-18 21:17   ` Florian Fainelli
2021-12-18 22:44     ` Lad, Prabhakar
2021-12-19  9:52       ` Lad, Prabhakar
2021-12-19 18:21         ` Florian Fainelli
2021-12-18 16:52 ` [PATCH 2/3] i2c: sh_mobile: Use platform_get_irq_optional() " Lad Prabhakar
2021-12-20 10:16   ` Wolfram Sang [this message]
2021-12-20 11:58     ` Lad, Prabhakar
2021-12-20 10:17   ` Geert Uytterhoeven
2021-12-20 11:53     ` Sergei Shtylyov
2022-02-08 12:31       ` Arnd Bergmann
2022-02-09 15:11         ` Sergei Shtylyov
2022-02-09 15:18           ` Arnd Bergmann
2022-02-09 15:48             ` Sergei Shtylyov
2022-02-09 16:02               ` Arnd Bergmann
2022-02-09 16:08                 ` Sergei Shtylyov
2022-02-09 22:56                   ` Arnd Bergmann
2022-02-10  8:54                   ` Geert Uytterhoeven
2022-02-10  9:32               ` Geert Uytterhoeven
2022-02-10  9:46                 ` Sergei Shtylyov
2021-12-20 11:55     ` Lad, Prabhakar
2021-12-20 12:54       ` Geert Uytterhoeven
2021-12-20 13:00         ` Lad, Prabhakar
2021-12-18 16:52 ` [PATCH 3/3] i2c: riic: Use platform_get_irq() " Lad Prabhakar
2021-12-20 10:16   ` Wolfram Sang
2021-12-20 10:20   ` Geert Uytterhoeven

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=YcBX8iLzFaztwkeo@ninjato \
    --to=wsa+renesas@sang-engineering.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=chris.brandt@renesas.com \
    --cc=f.fainelli@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=nsaenz@kernel.org \
    --cc=prabhakar.csengg@gmail.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=rjui@broadcom.com \
    --cc=robh+dt@kernel.org \
    --cc=sbranden@broadcom.com \
    /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