linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next v2] misc: microchip: pci1xxxx: fix return value in pci1xxxx_otp_eeprom_probe()
@ 2023-08-08 12:24 Yang Yingliang
  2023-08-09  9:04 ` Kumaravel.Thiagarajan
  2023-08-12 10:59 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Yang Yingliang @ 2023-08-08 12:24 UTC (permalink / raw)
  To: linux-gpio
  Cc: vaibhaavram.tl, kumaravel.thiagarajan, arnd, gregkh,
	tharunkumar.pasumarthi, yangyingliang

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.

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@huawei.com>
---
v1 -> v2:
  Use PTR_ERR_OR_ZERO().
---
 drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_otpe2p.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_otpe2p.c b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_otpe2p.c
index 3d3d1578119a..1b5b61cdacde 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,10 +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;
 
-	return ret;
+	return PTR_ERR_OR_ZERO(priv->nvmem_otp);
 }
 
 static void pci1xxxx_otp_eeprom_remove(struct auxiliary_device *aux_dev)
-- 
2.25.1


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

end of thread, other threads:[~2023-08-12 11:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-08 12:24 [PATCH -next v2] misc: microchip: pci1xxxx: fix return value in pci1xxxx_otp_eeprom_probe() Yang Yingliang
2023-08-09  9:04 ` Kumaravel.Thiagarajan
2023-08-12 10:59 ` Greg KH

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 NNTP newsgroup(s).