Linux-ACPI Archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/2] gpiolib: acpi: A couple of error checks amendmends
@ 2024-04-10 20:21 Andy Shevchenko
  2024-04-10 20:21 ` [PATCH v1 1/2] gpiolib: acpi: Remove never true check in acpi_get_gpiod_by_index() Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andy Shevchenko @ 2024-04-10 20:21 UTC (permalink / raw
  To: Andy Shevchenko, linux-gpio, linux-acpi, linux-kernel, llvm
  Cc: Mika Westerberg, Linus Walleij, Bartosz Golaszewski,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt

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(-)

-- 
2.43.0.rc1.1336.g36b5255a03ac


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

* [PATCH v1 1/2] gpiolib: acpi: Remove never true check in acpi_get_gpiod_by_index()
  2024-04-10 20:21 [PATCH v1 0/2] gpiolib: acpi: A couple of error checks amendmends Andy Shevchenko
@ 2024-04-10 20:21 ` Andy Shevchenko
  2024-04-10 20:21 ` [PATCH v1 2/2] gpiolib: acpi: Check for errors first in acpi_find_gpio() Andy Shevchenko
  2024-04-11 13:28 ` [PATCH v1 0/2] gpiolib: acpi: A couple of error checks amendmends Mika Westerberg
  2 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2024-04-10 20:21 UTC (permalink / raw
  To: Andy Shevchenko, linux-gpio, linux-acpi, linux-kernel, llvm
  Cc: Mika Westerberg, Linus Walleij, Bartosz Golaszewski,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt

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

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib-acpi.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 7f140df40f35..f596edf89451 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -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;
 
-- 
2.43.0.rc1.1336.g36b5255a03ac


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

* [PATCH v1 2/2] gpiolib: acpi: Check for errors first in acpi_find_gpio()
  2024-04-10 20:21 [PATCH v1 0/2] gpiolib: acpi: A couple of error checks amendmends Andy Shevchenko
  2024-04-10 20:21 ` [PATCH v1 1/2] gpiolib: acpi: Remove never true check in acpi_get_gpiod_by_index() Andy Shevchenko
@ 2024-04-10 20:21 ` Andy Shevchenko
  2024-04-11 13:28 ` [PATCH v1 0/2] gpiolib: acpi: A couple of error checks amendmends Mika Westerberg
  2 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2024-04-10 20:21 UTC (permalink / raw
  To: Andy Shevchenko, linux-gpio, linux-acpi, linux-kernel, llvm
  Cc: Mika Westerberg, Linus Walleij, Bartosz Golaszewski,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt

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).

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

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index f596edf89451..c2a33beeec50 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -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 */
-- 
2.43.0.rc1.1336.g36b5255a03ac


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

* Re: [PATCH v1 0/2] gpiolib: acpi: A couple of error checks amendmends
  2024-04-10 20:21 [PATCH v1 0/2] gpiolib: acpi: A couple of error checks amendmends Andy Shevchenko
  2024-04-10 20:21 ` [PATCH v1 1/2] gpiolib: acpi: Remove never true check in acpi_get_gpiod_by_index() Andy Shevchenko
  2024-04-10 20:21 ` [PATCH v1 2/2] gpiolib: acpi: Check for errors first in acpi_find_gpio() Andy Shevchenko
@ 2024-04-11 13:28 ` Mika Westerberg
  2024-04-11 13:37   ` Andy Shevchenko
  2 siblings, 1 reply; 5+ messages in thread
From: Mika Westerberg @ 2024-04-11 13:28 UTC (permalink / raw
  To: Andy Shevchenko
  Cc: linux-gpio, linux-acpi, linux-kernel, llvm, Linus Walleij,
	Bartosz Golaszewski, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt

On Wed, Apr 10, 2024 at 11:21:45PM +0300, Andy Shevchenko wrote:
> 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,

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

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

* Re: [PATCH v1 0/2] gpiolib: acpi: A couple of error checks amendmends
  2024-04-11 13:28 ` [PATCH v1 0/2] gpiolib: acpi: A couple of error checks amendmends Mika Westerberg
@ 2024-04-11 13:37   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2024-04-11 13:37 UTC (permalink / raw
  To: Mika Westerberg
  Cc: linux-gpio, linux-acpi, linux-kernel, llvm, Linus Walleij,
	Bartosz Golaszewski, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt

On Thu, Apr 11, 2024 at 04:28:06PM +0300, Mika Westerberg wrote:
> On Wed, Apr 10, 2024 at 11:21:45PM +0300, Andy Shevchenko wrote:
> > 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,
> 
> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Pushed to my review and testing queue, thanks!

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2024-04-11 13:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-10 20:21 [PATCH v1 0/2] gpiolib: acpi: A couple of error checks amendmends Andy Shevchenko
2024-04-10 20:21 ` [PATCH v1 1/2] gpiolib: acpi: Remove never true check in acpi_get_gpiod_by_index() Andy Shevchenko
2024-04-10 20:21 ` [PATCH v1 2/2] gpiolib: acpi: Check for errors first in acpi_find_gpio() Andy Shevchenko
2024-04-11 13:28 ` [PATCH v1 0/2] gpiolib: acpi: A couple of error checks amendmends Mika Westerberg
2024-04-11 13:37   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).