kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] phy: usb: sunplus: Fix return value check in update_disc_vol()
@ 2022-09-09  9:47 Wei Yongjun
  2022-09-13 15:28 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2022-09-09  9:47 UTC (permalink / raw)
  To: Vincent Shih, Kishon Vijay Abraham I, Vinod Koul, Philipp Zabel
  Cc: Wei Yongjun, linux-usb, linux-phy, kernel-janitors

From: Wei Yongjun <weiyongjun1@huawei.com>

In case of error, the function nvmem_cell_read() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check
should be replaced with IS_ERR().

Fixes: 99d9ccd97385 ("phy: usb: Add USB2.0 phy driver for Sunplus SP7021")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/phy/sunplus/phy-sunplus-usb2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/sunplus/phy-sunplus-usb2.c b/drivers/phy/sunplus/phy-sunplus-usb2.c
index 5269968b3060..b932087c55b2 100644
--- a/drivers/phy/sunplus/phy-sunplus-usb2.c
+++ b/drivers/phy/sunplus/phy-sunplus-usb2.c
@@ -92,13 +92,13 @@ static int update_disc_vol(struct sp_usbphy *usbphy)
 	otp_v = nvmem_cell_read(cell, &otp_l);
 	nvmem_cell_put(cell);
 
-	if (otp_v) {
+	if (!IS_ERR(otp_v)) {
 		set = *(otp_v + 1);
 		set = (set << (sizeof(char) * 8)) | *otp_v;
 		set = (set >> usbphy->disc_vol_addr_off) & J_DISC;
 	}
 
-	if (!otp_v || set == 0)
+	if (IS_ERR(otp_v) || set == 0)
 		set = OTP_DISC_LEVEL_DEFAULT;
 
 	val = readl(usbphy->phy_regs + CONFIG7);


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

* Re: [PATCH -next] phy: usb: sunplus: Fix return value check in update_disc_vol()
  2022-09-09  9:47 [PATCH -next] phy: usb: sunplus: Fix return value check in update_disc_vol() Wei Yongjun
@ 2022-09-13 15:28 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2022-09-13 15:28 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Vincent Shih, Kishon Vijay Abraham I, Philipp Zabel, Wei Yongjun,
	linux-usb, linux-phy, kernel-janitors

On 09-09-22, 09:47, Wei Yongjun wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> In case of error, the function nvmem_cell_read() returns ERR_PTR()
> and never returns NULL. The NULL test in the return value check
> should be replaced with IS_ERR().

Applied, thanks

-- 
~Vinod

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

end of thread, other threads:[~2022-09-13 17:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-09  9:47 [PATCH -next] phy: usb: sunplus: Fix return value check in update_disc_vol() Wei Yongjun
2022-09-13 15:28 ` Vinod Koul

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