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: <ZYRCz-FiG_w71qhB@smile.fi.intel.com>
Date: Thu, 21 Dec 2023 15:51:11 +0200
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Mark Hasemeyer <markhas@...omium.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
	AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
	Tzung-Bi Shih <tzungbi@...nel.org>,
	Raul Rangel <rrangel@...omium.org>,
	Konrad Dybcio <konrad.dybcio@...aro.org>,
	Rob Herring <robh@...nel.org>, Sudeep Holla <sudeep.holla@....com>,
	Mika Westerberg <mika.westerberg@...ux.intel.com>,
	Wolfram Sang <wsa@...nel.org>, linux-acpi@...r.kernel.org,
	linux-i2c@...r.kernel.org
Subject: Re: [PATCH v2 02/22] i2c: acpi: Modify i2c_acpi_get_irq() to use
 resource

On Wed, Dec 20, 2023 at 04:54:16PM -0700, Mark Hasemeyer wrote:
> The i2c_acpi_irq_context structure provides redundant information that
> can be provided with struct resource.
> 
> Refactor i2c_acpi_get_irq() to use struct resource instead of struct
> i2c_acpi_irq_context.

Suggested-by?

...

>  static int i2c_acpi_add_irq_resource(struct acpi_resource *ares, void *data)
>  {
> -	struct i2c_acpi_irq_context *irq_ctx = data;
> -	struct resource r;
> +	struct resource *r = data;

> -	if (irq_ctx->irq > 0)
> +	if (r->start > 0)
>  		return 1;

Checking flags is more robust.

	if (r->flags)
		return 1;

> -	if (!acpi_dev_resource_interrupt(ares, 0, &r))
> +	if (!acpi_dev_resource_interrupt(ares, 0, r))
>  		return 1;
>  
> -	irq_ctx->irq = i2c_dev_irq_from_resources(&r, 1);
> -	irq_ctx->wake_capable = r.flags & IORESOURCE_IRQ_WAKECAPABLE;
> +	i2c_dev_irq_from_resources(r, 1);
>  
>  	return 1; /* No need to add resource to the list */
>  }

...

> +	if (IS_ERR_OR_NULL(r))
> +		return -EINVAL;

Hmm... Do we expect this to be an error pointer in some cases?

...

> +	ret = acpi_dev_get_gpio_irq_resource(adev, NULL, 0, r);
> +	if (!ret)
> +		return r->start;
>  
> -	return irq_ctx.irq;
> +	return ret;

What's wrong with the standard pattern?

	if (ret)
		return ret;
	...
	return ...;

...

> +			struct resource r = {0};

'0' is redundant.

...

> +			irq = i2c_acpi_get_irq(client, &r);
> +			if (irq > 0 && r.flags & IORESOURCE_IRQ_WAKECAPABLE)

Why checking just flags is not enough?

>  				client->flags |= I2C_CLIENT_WAKE;

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ