Re: [PATCH] gpiolib: acpi: Add ACPI device NULL check to acpi_can_fallback_to_crs()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 09, 2024 at 12:46:05PM +0200, Laura Nao wrote:
> Check ACPI device for NULL inside acpi_can_fallback_to_crs(), so callers
> won't need to.

Thank you for the patch, one change seems good to have along this.

...

>  	/* Never allow fallback if the device has properties */
> -	if (acpi_dev_has_props(adev) || adev->driver_gpios)
> +	if (!adev || acpi_dev_has_props(adev) || adev->driver_gpios)

Right, since it was adev || _crs() combined.

>  		return false;

Now we may remove that check from __acpi_find_gpio():

--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -988,10 +988,10 @@ __acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int
 	}
 
 	/* Then from plain _CRS GPIOs */
-	if (!adev || !can_fallback)
-		return ERR_PTR(-ENOENT);
+	if (can_fallback)
+		return acpi_get_gpiod_by_index(adev, NULL, idx, info);
 
-	return acpi_get_gpiod_by_index(adev, NULL, idx, info);
+	return ERR_PTR(-ENOENT);
 }
 
 struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,


As a side effect it will make the comment better to understand.

With above suggestion applied, feel free to add mine
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>

You might need to rephrase the commit message to say that

 "We also move the check in additional to the moving the function call
 outside of __acpi_find_gpio()."

or something similar, up to you.

-- 
With Best Regards,
Andy Shevchenko






[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux