Re: [PATCH -next] misc: microchip: pci1xxxx: fix return value in pci1xxxx_otp_eeprom_probe()

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

 



Hi,

On 2023/8/8 19:27, Kumaravel.Thiagarajan@xxxxxxxxxxxxx wrote:
-----Original Message-----
From: Yang Yingliang <yangyingliang@xxxxxxxxxx>
Sent: Tuesday, August 8, 2023 1:40 PM
To: linux-gpio@xxxxxxxxxxxxxxx

devm_nvmem_register() never returns NULL pointer, it will return
ERR_PTR() when it fails, so replace the check with IS_ERR() and use PTR_ERR()
as return code.
Is it even better to use PTR_ERR_OR_ZERO like below?
priv->nvmem_eeprom = devm_nvmem_register(&aux_dev->dev,
                                                          &priv->nvmem_config_eeprom);
return PTR_ERR_OR_ZERO(priv->nvmem_eeprom);
It can not return directly here, there is another code after this calling in the probe function. But the check after 'priv->nvmem_otp = devm_nvmem_register()' is at end of the probe function.
It can be simplify like this way. I will send a v2.

Thanks,
Yang

Fixes: 9ab5465349c0 ("misc: microchip: pci1xxxx: Add support to read and
write into PCI1XXXX EEPROM via NVMEM sysfs")
Fixes: 0969001569e4 ("misc: microchip: pci1xxxx: Add support to read and
write into PCI1XXXX OTP via NVMEM sysfs")
Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
---
  drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_otpe2p.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_otpe2p.c
b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_otpe2p.c
index 3d3d1578119a..16695cb5e69c 100644
--- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_otpe2p.c
+++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_otpe2p.c
@@ -379,8 +379,8 @@ static int pci1xxxx_otp_eeprom_probe(struct
auxiliary_device *aux_dev,

                 priv->nvmem_eeprom = devm_nvmem_register(&aux_dev->dev,
                                                          &priv->nvmem_config_eeprom);
-               if (!priv->nvmem_eeprom)
-                       return -ENOMEM;
+               if (IS_ERR(priv->nvmem_eeprom))
+                       return PTR_ERR(priv->nvmem_eeprom);
         }

         release_sys_lock(priv);
@@ -398,8 +398,8 @@ static int pci1xxxx_otp_eeprom_probe(struct
auxiliary_device *aux_dev,

         priv->nvmem_otp = devm_nvmem_register(&aux_dev->dev,
                                               &priv->nvmem_config_otp);
-       if (!priv->nvmem_otp)
-               return -ENOMEM;
+       if (IS_ERR(priv->nvmem_otp))
+               return PTR_ERR(priv->nvmem_otp);

         return ret;
  }
--
2.25.1
Thank You.

Regards,
Kumar

.



[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