diff mbox series

[1/2] net: asix: Simplify return value check after asix_check_host_enable

Message ID 20221201175525.2733125-1-l.stach@pengutronix.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [1/2] net: asix: Simplify return value check after asix_check_host_enable | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 4 maintainers not CCed: andrew@lunn.ch shaozhengchao@huawei.com paskripkin@gmail.com linux@rempel-privat.de
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Lucas Stach Dec. 1, 2022, 5:55 p.m. UTC
Any negative return value from this function is indicative of an
error. Simplify the condition to cover all possible error codes.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/net/usb/asix_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Leon Romanovsky Dec. 4, 2022, 11:46 a.m. UTC | #1
On Thu, Dec 01, 2022 at 06:55:24PM +0100, Lucas Stach wrote:
> Any negative return value from this function is indicative of an
> error. Simplify the condition to cover all possible error codes.

Some calls to asix_read_cmd() in asix_check_host_enable() return -ENODATA
and such are simply skipped (... continue ...). It is unclear if it
indicates an error or not.

Thanks

> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  drivers/net/usb/asix_common.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
> index 72ffc89b477a..be1e103b7a95 100644
> --- a/drivers/net/usb/asix_common.c
> +++ b/drivers/net/usb/asix_common.c
> @@ -504,7 +504,7 @@ static int __asix_mdio_read(struct net_device *netdev, int phy_id, int loc,
>  	mutex_lock(&dev->phy_mutex);
>  
>  	ret = asix_check_host_enable(dev, in_pm);
> -	if (ret == -ENODEV || ret == -ETIMEDOUT) {
> +	if (ret < 0) {
>  		mutex_unlock(&dev->phy_mutex);
>  		return ret;
>  	}
> @@ -542,7 +542,7 @@ static int __asix_mdio_write(struct net_device *netdev, int phy_id, int loc,
>  	mutex_lock(&dev->phy_mutex);
>  
>  	ret = asix_check_host_enable(dev, in_pm);
> -	if (ret == -ENODEV)
> +	if (ret < 0)
>  		goto out;
>  
>  	ret = asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2,
> -- 
> 2.30.2
>
diff mbox series

Patch

diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index 72ffc89b477a..be1e103b7a95 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -504,7 +504,7 @@  static int __asix_mdio_read(struct net_device *netdev, int phy_id, int loc,
 	mutex_lock(&dev->phy_mutex);
 
 	ret = asix_check_host_enable(dev, in_pm);
-	if (ret == -ENODEV || ret == -ETIMEDOUT) {
+	if (ret < 0) {
 		mutex_unlock(&dev->phy_mutex);
 		return ret;
 	}
@@ -542,7 +542,7 @@  static int __asix_mdio_write(struct net_device *netdev, int phy_id, int loc,
 	mutex_lock(&dev->phy_mutex);
 
 	ret = asix_check_host_enable(dev, in_pm);
-	if (ret == -ENODEV)
+	if (ret < 0)
 		goto out;
 
 	ret = asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2,