diff mbox series

ACPI / PMIC: Remove unneeded check in tps68470_pmic_opregion_probe()

Message ID 20240705113434.17249-1-amishin@t-argos.ru
State New
Headers show
Series ACPI / PMIC: Remove unneeded check in tps68470_pmic_opregion_probe() | expand

Commit Message

Aleksandr Mishin July 5, 2024, 11:34 a.m. UTC
In tps68470_pmic_opregion_probe() pointer 'dev' is compared to NULL which
is useless.

Fix this issue by removing unneeded check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: e13452ac3790 ("ACPI / PMIC: Add TI PMIC TPS68470 operation region driver")
Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
---
 drivers/acpi/pmic/tps68470_pmic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sakari Ailus July 6, 2024, 11:56 a.m. UTC | #1
On Fri, Jul 05, 2024 at 02:34:34PM +0300, Aleksandr Mishin wrote:
> In tps68470_pmic_opregion_probe() pointer 'dev' is compared to NULL which
> is useless.
> 
> Fix this issue by removing unneeded check.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: e13452ac3790 ("ACPI / PMIC: Add TI PMIC TPS68470 operation region driver")
> Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>

Thanks!

Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>

> ---
>  drivers/acpi/pmic/tps68470_pmic.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/pmic/tps68470_pmic.c b/drivers/acpi/pmic/tps68470_pmic.c
> index ebd03e472955..f8de8d0a528b 100644
> --- a/drivers/acpi/pmic/tps68470_pmic.c
> +++ b/drivers/acpi/pmic/tps68470_pmic.c
> @@ -376,7 +376,7 @@ static int tps68470_pmic_opregion_probe(struct platform_device *pdev)
>  	struct tps68470_pmic_opregion *opregion;
>  	acpi_status status;
>  
> -	if (!dev || !tps68470_regmap) {
> +	if (!tps68470_regmap) {
>  		dev_warn(dev, "dev or regmap is NULL\n");
>  		return -EINVAL;
>  	}
Markus Elfring July 6, 2024, 1:47 p.m. UTC | #2
> In tps68470_pmic_opregion_probe() pointer 'dev' is compared to NULL which
> is useless.

            because …?


> Fix this issue by removing unneeded check.

Another wording suggestion:
  Thus remove a redundant check (and …?).


…
> +++ b/drivers/acpi/pmic/tps68470_pmic.c
> @@ -376,7 +376,7 @@ static int tps68470_pmic_opregion_probe(struct platform_device *pdev)
>  	struct tps68470_pmic_opregion *opregion;
>  	acpi_status status;
>
> -	if (!dev || !tps68470_regmap) {
> +	if (!tps68470_regmap) {
>  		dev_warn(dev, "dev or regmap is NULL\n");
…

Would you like to adjust the passed string literal accordingly?

Regards,
Markus
Andy Shevchenko July 30, 2024, 7:38 p.m. UTC | #3
On Fri, Jul 5, 2024 at 1:36 PM Aleksandr Mishin <amishin@t-argos.ru> wrote:
>
> In tps68470_pmic_opregion_probe() pointer 'dev' is compared to NULL which
> is useless.
>
> Fix this issue by removing unneeded check.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.

...

> -       if (!dev || !tps68470_regmap) {
> +       if (!tps68470_regmap) {
>                 dev_warn(dev, "dev or regmap is NULL\n");

Now this message is misleading.

>                 return -EINVAL;
>         }

And I dunno why it's a warning and not an error level.

With all above being said, I would recommend to update to

  if (!tps68470_regmap)
    return dev_err_probe(dev, -EINVAL, "regmap is missing\n");
diff mbox series

Patch

diff --git a/drivers/acpi/pmic/tps68470_pmic.c b/drivers/acpi/pmic/tps68470_pmic.c
index ebd03e472955..f8de8d0a528b 100644
--- a/drivers/acpi/pmic/tps68470_pmic.c
+++ b/drivers/acpi/pmic/tps68470_pmic.c
@@ -376,7 +376,7 @@  static int tps68470_pmic_opregion_probe(struct platform_device *pdev)
 	struct tps68470_pmic_opregion *opregion;
 	acpi_status status;
 
-	if (!dev || !tps68470_regmap) {
+	if (!tps68470_regmap) {
 		dev_warn(dev, "dev or regmap is NULL\n");
 		return -EINVAL;
 	}