From 26d9bd1ccd6b344d1cc9ddb3d50981b106fed3b8 Mon Sep 17 00:00:00 2001 From: Andrew Goodbody Date: Wed, 6 Aug 2025 16:47:46 +0100 Subject: phy: keystone-usb: Do not negate return code In keystone_usb_init the return code from psc_enable_module should be returned as is rather than being negated. This issue was found by Smatch. Signed-off-by: Andrew Goodbody --- drivers/phy/keystone-usb-phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/phy') diff --git a/drivers/phy/keystone-usb-phy.c b/drivers/phy/keystone-usb-phy.c index cfc15203d63..460efbe768d 100644 --- a/drivers/phy/keystone-usb-phy.c +++ b/drivers/phy/keystone-usb-phy.c @@ -41,7 +41,7 @@ static int keystone_usb_init(struct phy *phy) rc = psc_enable_module(keystone->psc_domain); if (rc) { debug("Cannot enable USB module"); - return -rc; + return rc; } mdelay(10); -- cgit v1.2.3 From fc96c1de5b719561db15259009a9ef22e671ee3d Mon Sep 17 00:00:00 2001 From: Andrew Goodbody Date: Wed, 6 Aug 2025 18:03:26 +0100 Subject: phy: ti: j721e-wiz: Set error code before goto In j721e_wiz_probe the test for too many lanes jumps to the error exit path without assigning an error code which could lead to calling code silently ignoring the failure. Set the error code. This issue was found by Smatch. Signed-off-by: Andrew Goodbody --- drivers/phy/ti/phy-j721e-wiz.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/phy') diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c index c69a342e2b4..6e2d4bc2b05 100644 --- a/drivers/phy/ti/phy-j721e-wiz.c +++ b/drivers/phy/ti/phy-j721e-wiz.c @@ -1201,6 +1201,7 @@ static int j721e_wiz_probe(struct udevice *dev) if (num_lanes > WIZ_MAX_LANES) { dev_err(dev, "Cannot support %d lanes\n", num_lanes); + rc = -EINVAL; goto err_addr_to_resource; } -- cgit v1.2.3 From c6a4b44cdcc11431223a9d9db17de0c587d49c72 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 7 Sep 2025 01:00:44 +0200 Subject: phy: Reset init count on phy exit failure In case the PHY exit callback reports failure, reset init_count to 0 anyway, so the next attempt at PHY initialization might try to reinitialize the PHY and restore it to normal operation. Signed-off-by: Marek Vasut Reviewed-by: Siddharth Vadapalli --- drivers/phy/phy-uclass.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/phy') diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c index 714be123856..f8d4fb3b41b 100644 --- a/drivers/phy/phy-uclass.c +++ b/drivers/phy/phy-uclass.c @@ -274,7 +274,7 @@ int generic_phy_exit(struct phy *phy) { struct phy_counts *counts; struct phy_ops const *ops; - int ret; + int ret = 0; if (!generic_phy_valid(phy)) return 0; @@ -292,12 +292,11 @@ int generic_phy_exit(struct phy *phy) if (ret) { dev_err(phy->dev, "PHY: Failed to exit %s: %d.\n", phy->dev->name, ret); - return ret; } } counts->init_count = 0; - return 0; + return ret; } int generic_phy_power_on(struct phy *phy) -- cgit v1.2.3