lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZXoLbt7jNrmC0VbQ@smile.fi.intel.com>
Date:   Wed, 13 Dec 2023 21:52:14 +0200
From:   Andy Shevchenko <andriy.shevchenko@...el.com>
To:     Mark Hasemeyer <markhas@...omium.org>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Raul Rangel <rrangel@...omium.org>,
        David Gow <davidgow@...gle.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Mark Brown <broonie@...nel.org>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Takashi Iwai <tiwai@...e.de>,
        Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>
Subject: Re: [PATCH v1 5/6] platform: Modify platform_get_irq_optional() to
 use resource

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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ