public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] i2c: acpi: Ad-hoc cleanup and kernel-doc fix
@ 2025-11-25  9:40 Andy Shevchenko
  2025-11-25  9:40 ` [PATCH v1 1/2] i2c: acpi: Return -ENOENT when no resources found in i2c_acpi_client_count() Andy Shevchenko
  2025-11-25  9:40 ` [PATCH v1 2/2] platform/x86: serial-multi-instantiate: Remove duplicate check Andy Shevchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2025-11-25  9:40 UTC (permalink / raw)
  To: Andy Shevchenko, Baojun Xu, linux-i2c, linux-acpi, linux-kernel,
	platform-driver-x86
  Cc: Wolfram Sang, Mika Westerberg, Hans de Goede, Ilpo Järvinen

Here are an ad-hoc cleanup and a kernel-doc fix while I was looking
into serial-multi-instantiate.c for other reasons. Note, the other
users of i2c_acpi_client_count() are not affected by the change as
they are only interested in positive value returned from it.

Assumed to go via I2C core tree, Ilpo, please, Ack the second change.

Andy Shevchenko (2):
  i2c: acpi: Return -ENOENT when no resources found in
    i2c_acpi_client_count()
  platform/x86: serial-multi-instantiate: Remove duplicate check

 drivers/i2c/i2c-core-acpi.c                     | 7 +++++--
 drivers/platform/x86/serial-multi-instantiate.c | 3 ---
 2 files changed, 5 insertions(+), 5 deletions(-)

-- 
2.50.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v1 1/2] i2c: acpi: Return -ENOENT when no resources found in i2c_acpi_client_count()
  2025-11-25  9:40 [PATCH v1 0/2] i2c: acpi: Ad-hoc cleanup and kernel-doc fix Andy Shevchenko
@ 2025-11-25  9:40 ` Andy Shevchenko
  2025-11-25  9:50   ` Mika Westerberg
  2025-11-25  9:40 ` [PATCH v1 2/2] platform/x86: serial-multi-instantiate: Remove duplicate check Andy Shevchenko
  1 sibling, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2025-11-25  9:40 UTC (permalink / raw)
  To: Andy Shevchenko, Baojun Xu, linux-i2c, linux-acpi, linux-kernel,
	platform-driver-x86
  Cc: Wolfram Sang, Mika Westerberg, Hans de Goede, Ilpo Järvinen

Some users want to return an error to the upper layers when
i2c_acpi_client_count() returns 0. Follow the common pattern
in such cases, i.e. return -ENOENT instead of 0.

While at it, fix the kernel-doc warning about missing return value
description.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/i2c-core-acpi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index ed90858a27b7..a7d36f8d7f2f 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -84,8 +84,11 @@ static int i2c_acpi_resource_count(struct acpi_resource *ares, void *data)
  * i2c_acpi_client_count - Count the number of I2cSerialBus resources
  * @adev:	ACPI device
  *
- * Returns the number of I2cSerialBus resources in the ACPI-device's
+ * Return:
+ * The number of I2cSerialBus resources in the ACPI-device's
  * resource-list; or a negative error code.
+ *
+ * Specifically returns -ENOENT when no resources found.
  */
 int i2c_acpi_client_count(struct acpi_device *adev)
 {
@@ -97,7 +100,7 @@ int i2c_acpi_client_count(struct acpi_device *adev)
 		return ret;
 
 	acpi_dev_free_resource_list(&r);
-	return count;
+	return count ?: -ENOENT;
 }
 EXPORT_SYMBOL_GPL(i2c_acpi_client_count);
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 2/2] platform/x86: serial-multi-instantiate: Remove duplicate check
  2025-11-25  9:40 [PATCH v1 0/2] i2c: acpi: Ad-hoc cleanup and kernel-doc fix Andy Shevchenko
  2025-11-25  9:40 ` [PATCH v1 1/2] i2c: acpi: Return -ENOENT when no resources found in i2c_acpi_client_count() Andy Shevchenko
@ 2025-11-25  9:40 ` Andy Shevchenko
  2025-11-27  9:54   ` Ilpo Järvinen
  1 sibling, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2025-11-25  9:40 UTC (permalink / raw)
  To: Andy Shevchenko, Baojun Xu, linux-i2c, linux-acpi, linux-kernel,
	platform-driver-x86
  Cc: Wolfram Sang, Mika Westerberg, Hans de Goede, Ilpo Järvinen

Since i2c_acpi_client_count() stopped returning 0 and instead
uses -ENOENT, remove the duplicated check in smi_i2c_probe().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/platform/x86/serial-multi-instantiate.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/platform/x86/serial-multi-instantiate.c b/drivers/platform/x86/serial-multi-instantiate.c
index db030b0f176a..3f6f5d51442c 100644
--- a/drivers/platform/x86/serial-multi-instantiate.c
+++ b/drivers/platform/x86/serial-multi-instantiate.c
@@ -198,9 +198,6 @@ static int smi_i2c_probe(struct platform_device *pdev, struct smi *smi,
 	ret = i2c_acpi_client_count(adev);
 	if (ret < 0)
 		return ret;
-	if (!ret)
-		return -ENOENT;
-
 	count = ret;
 
 	smi->i2c_devs = devm_kcalloc(dev, count, sizeof(*smi->i2c_devs), GFP_KERNEL);
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/2] i2c: acpi: Return -ENOENT when no resources found in i2c_acpi_client_count()
  2025-11-25  9:40 ` [PATCH v1 1/2] i2c: acpi: Return -ENOENT when no resources found in i2c_acpi_client_count() Andy Shevchenko
@ 2025-11-25  9:50   ` Mika Westerberg
  2025-11-25 10:10     ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Mika Westerberg @ 2025-11-25  9:50 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Baojun Xu, linux-i2c, linux-acpi, linux-kernel,
	platform-driver-x86, Wolfram Sang, Mika Westerberg, Hans de Goede,
	Ilpo Järvinen

On Tue, Nov 25, 2025 at 10:40:11AM +0100, Andy Shevchenko wrote:
> Some users want to return an error to the upper layers when
> i2c_acpi_client_count() returns 0. Follow the common pattern
> in such cases, i.e. return -ENOENT instead of 0.

Well what does 0 mean then?

To me it's logical that i2c_acpi_client_count() as it returns count,
returns 0 if the count is 0. Let's not make it any more complex than that.
;-)

> While at it, fix the kernel-doc warning about missing return value
> description.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/i2c/i2c-core-acpi.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
> index ed90858a27b7..a7d36f8d7f2f 100644
> --- a/drivers/i2c/i2c-core-acpi.c
> +++ b/drivers/i2c/i2c-core-acpi.c
> @@ -84,8 +84,11 @@ static int i2c_acpi_resource_count(struct acpi_resource *ares, void *data)
>   * i2c_acpi_client_count - Count the number of I2cSerialBus resources
>   * @adev:	ACPI device
>   *
> - * Returns the number of I2cSerialBus resources in the ACPI-device's
> + * Return:
> + * The number of I2cSerialBus resources in the ACPI-device's
>   * resource-list; or a negative error code.
> + *
> + * Specifically returns -ENOENT when no resources found.
>   */
>  int i2c_acpi_client_count(struct acpi_device *adev)
>  {
> @@ -97,7 +100,7 @@ int i2c_acpi_client_count(struct acpi_device *adev)
>  		return ret;
>  
>  	acpi_dev_free_resource_list(&r);
> -	return count;
> +	return count ?: -ENOENT;
>  }
>  EXPORT_SYMBOL_GPL(i2c_acpi_client_count);
>  
> -- 
> 2.50.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/2] i2c: acpi: Return -ENOENT when no resources found in i2c_acpi_client_count()
  2025-11-25  9:50   ` Mika Westerberg
@ 2025-11-25 10:10     ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2025-11-25 10:10 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: Baojun Xu, linux-i2c, linux-acpi, linux-kernel,
	platform-driver-x86, Wolfram Sang, Mika Westerberg, Hans de Goede,
	Ilpo Järvinen

On Tue, Nov 25, 2025 at 10:50:46AM +0100, Mika Westerberg wrote:
> On Tue, Nov 25, 2025 at 10:40:11AM +0100, Andy Shevchenko wrote:
> > Some users want to return an error to the upper layers when
> > i2c_acpi_client_count() returns 0. Follow the common pattern
> > in such cases, i.e. return -ENOENT instead of 0.
> 
> Well what does 0 mean then?

There is no 0.

> To me it's logical that i2c_acpi_client_count() as it returns count,
> returns 0 if the count is 0. Let's not make it any more complex than that.
> ;-)

The same approach used elsewhere, e.g., gpiod_count(),
   of_reset_control_get_count() / reset_control_get_count().
And other count methods used for IRQ resource, for example.
However PCI MSI/MSI-X counters never return 0.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 2/2] platform/x86: serial-multi-instantiate: Remove duplicate check
  2025-11-25  9:40 ` [PATCH v1 2/2] platform/x86: serial-multi-instantiate: Remove duplicate check Andy Shevchenko
@ 2025-11-27  9:54   ` Ilpo Järvinen
  0 siblings, 0 replies; 6+ messages in thread
From: Ilpo Järvinen @ 2025-11-27  9:54 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Baojun Xu, linux-i2c, linux-acpi, LKML, platform-driver-x86,
	Wolfram Sang, Mika Westerberg, Hans de Goede

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

On Tue, 25 Nov 2025, Andy Shevchenko wrote:

> Since i2c_acpi_client_count() stopped returning 0 and instead
> uses -ENOENT, remove the duplicated check in smi_i2c_probe().
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/platform/x86/serial-multi-instantiate.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/serial-multi-instantiate.c b/drivers/platform/x86/serial-multi-instantiate.c
> index db030b0f176a..3f6f5d51442c 100644
> --- a/drivers/platform/x86/serial-multi-instantiate.c
> +++ b/drivers/platform/x86/serial-multi-instantiate.c
> @@ -198,9 +198,6 @@ static int smi_i2c_probe(struct platform_device *pdev, struct smi *smi,
>  	ret = i2c_acpi_client_count(adev);
>  	if (ret < 0)
>  		return ret;
> -	if (!ret)
> -		return -ENOENT;
> -
>  	count = ret;
>  
>  	smi->i2c_devs = devm_kcalloc(dev, count, sizeof(*smi->i2c_devs), GFP_KERNEL);
> 

Acked-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-11-27  9:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-25  9:40 [PATCH v1 0/2] i2c: acpi: Ad-hoc cleanup and kernel-doc fix Andy Shevchenko
2025-11-25  9:40 ` [PATCH v1 1/2] i2c: acpi: Return -ENOENT when no resources found in i2c_acpi_client_count() Andy Shevchenko
2025-11-25  9:50   ` Mika Westerberg
2025-11-25 10:10     ` Andy Shevchenko
2025-11-25  9:40 ` [PATCH v1 2/2] platform/x86: serial-multi-instantiate: Remove duplicate check Andy Shevchenko
2025-11-27  9:54   ` Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox