]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
i2c: acpi: Return -ENOENT when no resources found in i2c_acpi_client_count()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 25 Nov 2025 09:40:11 +0000 (10:40 +0100)
committerAndi Shyti <andi.shyti@kernel.org>
Tue, 9 Jun 2026 11:00:32 +0000 (13:00 +0200)
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>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
drivers/i2c/i2c-core-acpi.c

index 2cbd31f77667aa3965d62f66eeabfe186182d787..b25e6b04e9d74b2d209e4fef04b12bab88aadb4d 100644 (file)
@@ -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);