From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Mark Hasemeyer <markhas@chromium.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
"Raul Rangel" <rrangel@chromium.org>,
"David Gow" <davidgow@google.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Mark Brown" <broonie@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Takashi Iwai" <tiwai@suse.de>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Subject: Re: [PATCH v1 5/6] platform: Modify platform_get_irq_optional() to use resource
Date: Wed, 13 Dec 2023 21:52:14 +0200 [thread overview]
Message-ID: <ZXoLbt7jNrmC0VbQ@smile.fi.intel.com> (raw)
In-Reply-To: <20231213110009.v1.5.Ife9ebad2bbfbab3a05e90040f344d750aa0aac7e@changeid>
On Wed, Dec 13, 2023 at 11:00:23AM -0700, Mark Hasemeyer wrote:
> Unify handling of ACPI, GPIO, devictree, and platform resource
> interrupts in platform_get_irq_optional(). Each of these subsystems
> provide their own apis which provide IRQ information as a struct
> resource. This simplifies the logic of the function and allows callers
> to get more information about the irq by looking at the resource flags.
IRQ
> For example, whether or not an irq is wake capable.
IRQ
> Rename the function to platform_get_irq_resource() to better describe
> the function's new behavior.
...
> - * platform_get_irq_optional - get an optional IRQ for a device
> + * platform_get_irq_resource - get an IRQ for a device and populate resource struct
> * @dev: platform device
> * @num: IRQ number index
> + * @r: pointer to resource to populate with irq information. It is not modified on failure.
IRQ
It's inconsistent with just a few lines above!
Also same comment about second remark, no need to have it. It's implied.
...
> + *r = (struct resource)DEFINE_RES_IRQ(ret);
Why is the annotation needed?
...
> - struct resource *r;
> + struct resource *platform_res;
>
> if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) {
> - ret = of_irq_get(dev->dev.of_node, num);
> + ret = of_irq_to_resource(dev->dev.of_node, num, r);
> if (ret > 0 || ret == -EPROBE_DEFER)
> goto out;
> }
> + if (has_acpi_companion(&dev->dev)) {
> + ret = acpi_irq_get(ACPI_HANDLE(&dev->dev), num, r);
> + if (!ret || ret == -EPROBE_DEFER) {
> + ret = ret ?: r->start;
> + goto out;
> + }
> + }
Consider combine the above to use fwnode_irq_get() in the separate prerequisite
change.
...
> + /*
> + * The resources may pass trigger flags to the irqs that need
> + * to be set up. It so happens that the trigger flags for
> + * IORESOURCE_BITS correspond 1-to-1 to the IRQF_TRIGGER*
> + * settings.
> + */
> + if (ret > 0 && r->flags & IORESOURCE_BITS) {
> + struct irq_data *irqd;
> + irqd = irq_get_irq_data(r->start);
> + if (!irqd)
> + ret = -ENXIO;
> + else
Redundant.
Just return directly from the above.
> + irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
NIH resource_type().
> + }
> return ret;
...
What you need to add to all the functions is either
- check that resource pointer is not NULL, and/or
- documentation that explain this requirement or mark it optional
(but second seems nonsense)
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-12-13 19:53 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-13 18:00 [PATCH v1 1/6] gpiolib: acpi: Modify acpi_dev_irq_wake_get_by to use resource Mark Hasemeyer
2023-12-13 18:00 ` [PATCH v1 2/6] arm: arm64: dts: Enable cros-ec-spi as wake source Mark Hasemeyer
2023-12-13 18:08 ` Krzysztof Kozlowski
2023-12-13 22:11 ` Rob Herring
2023-12-14 21:04 ` Mark Hasemeyer
2023-12-14 22:20 ` Rob Herring
2023-12-14 10:55 ` AngeloGioacchino Del Regno
2023-12-14 11:53 ` Konrad Dybcio
2023-12-13 18:00 ` [PATCH v1 3/6] of: irq: add wake capable bit to of_irq_resource() Mark Hasemeyer
2023-12-13 19:44 ` Andy Shevchenko
2023-12-13 22:19 ` Rob Herring
2023-12-14 21:05 ` Mark Hasemeyer
2023-12-15 15:30 ` Rob Herring
2023-12-15 20:56 ` Mark Hasemeyer
2023-12-18 10:49 ` Sudeep Holla
2023-12-13 18:00 ` [PATCH v1 4/6] of: irq: Add default implementation for of_irq_to_resource() Mark Hasemeyer
2023-12-13 19:45 ` Andy Shevchenko
2023-12-13 18:00 ` [PATCH v1 5/6] platform: Modify platform_get_irq_optional() to use resource Mark Hasemeyer
2023-12-13 19:52 ` Andy Shevchenko [this message]
2023-12-18 20:23 ` Mark Hasemeyer
2023-12-19 14:58 ` Andy Shevchenko
2023-12-13 22:04 ` Rob Herring
2023-12-13 18:00 ` [PATCH v1 6/6] platform/chrome: cros_ec: Use PM subsystem to manage wakeirq Mark Hasemeyer
2023-12-14 3:09 ` Tzung-Bi Shih
2023-12-15 21:02 ` Mark Hasemeyer
2023-12-13 19:34 ` [PATCH v1 1/6] gpiolib: acpi: Modify acpi_dev_irq_wake_get_by to use resource Andy Shevchenko
2023-12-14 20:56 ` Mark Hasemeyer
2023-12-13 19:40 ` Andy Shevchenko
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=ZXoLbt7jNrmC0VbQ@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=broonie@kernel.org \
--cc=davidgow@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=markhas@chromium.org \
--cc=rafael@kernel.org \
--cc=rrangel@chromium.org \
--cc=tiwai@suse.de \
--cc=u.kleine-koenig@pengutronix.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