Skip to contentSkip to conversation

gpiolib: acpi: A couple of error checks amendmends

PATCH In review Andy Shevchenko 2 participants 5 messages Apr 10, 2024 – Apr 11, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover gpiolib: acpi: A couple of error checks amendmends

One error check is moved and one is dropped.
No functional changes intended.

Andy Shevchenko (2):
gpiolib: acpi: Remove never true check in acpi_get_gpiod_by_index()
gpiolib: acpi: Check for errors first in acpi_find_gpio()

 drivers/gpio/gpiolib-acpi.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#1 lore raw

PATCH 1/2 gpiolib: acpi: Remove never true check in acpi_get_gpiod_by_index()

The acpi_get_gpiod_by_index() never is called with adev being NULL. Remove the redundant check.

---
 drivers/gpio/gpiolib-acpi.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpio/gpiolib-acpi.c +0 -3
index 7f140df40f35..f596edf89451 100644
@@ -873,9 +873,6 @@ static struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev,
 	struct acpi_gpio_lookup lookup;
 	int ret;
 
-	if (!adev)
-		return ERR_PTR(-ENODEV);
-
 	memset(&lookup, 0, sizeof(lookup));
 	lookup.index = index;
 
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#2 lore raw

PATCH 2/2 gpiolib: acpi: Check for errors first in acpi_find_gpio()

In reply to Andy Shevchenko

It's better to parse the code when the usual pattern is being used, i.e. checking for error condition first.

There is no functional or code generation change (tested in LLVM).

---
 drivers/gpio/gpiolib-acpi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib-acpi.c +3 -2
index f596edf89451..c2a33beeec50 100644
@@ -973,10 +973,11 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
 		else
 			desc = acpi_get_gpiod_from_data(fwnode,
 						        propname, idx, &info);
-		if (!IS_ERR(desc))
-			break;
 		if (PTR_ERR(desc) == -EPROBE_DEFER)
 			return ERR_CAST(desc);
+
+		if (!IS_ERR(desc))
+			break;
 	}
 
 	/* Then from plain _CRS GPIOs */
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#4 lore raw
Quoted 11 lines · Mika Westerberg
Quoted 6 lines · Andy Shevchenko

One error check is moved and one is dropped.
No functional changes intended.

Andy Shevchenko (2):
gpiolib: acpi: Remove never true check in acpi_get_gpiod_by_index()
gpiolib: acpi: Check for errors first in acpi_find_gpio()

Both,

Pushed to my review and testing queue, thanks!

Signature · 2 lines
With Best Regards,
Andy Shevchenko