diff mbox series

[net-next,2/2] net: dsa: mv88e6xxx: Return -ENODEV when C22/C45 not supported

Message ID 20240203-unify-c22-c45-scan-error-handling-v1-2-8aa9fa3c4fca@lunn.ch (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series Unify C22 and C45 error handling during bus enumeration | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1048 this patch: 1048
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 0 of 0 maintainers
netdev/build_clang success Errors and warnings before: 1065 this patch: 1065
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
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: 1065 this patch: 1065
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-04--21-00 (tests: 721)

Commit Message

Andrew Lunn Feb. 3, 2024, 8:52 p.m. UTC
MDIO bus drivers can return -ENODEV when they know the bus does not
have a device at the given address, e.g. because of hardware
limitation. One such limitation is that the bus does not support C22
or C45 at all. This is more efficient than returning 0xffff, since it
immediately stops the probing on the given address, where as further
reads can be made when 0xffff is returned.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Florian Fainelli Feb. 3, 2024, 9:07 p.m. UTC | #1
On 2/3/2024 12:52 PM, Andrew Lunn wrote:
> MDIO bus drivers can return -ENODEV when they know the bus does not
> have a device at the given address, e.g. because of hardware
> limitation. One such limitation is that the bus does not support C22
> or C45 at all. This is more efficient than returning 0xffff, since it
> immediately stops the probing on the given address, where as further
> reads can be made when 0xffff is returned.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
>   drivers/net/dsa/mv88e6xxx/chip.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
> index 6eec2e4aa031..ce4e4bdf475d 100644
> --- a/drivers/net/dsa/mv88e6xxx/chip.c
> +++ b/drivers/net/dsa/mv88e6xxx/chip.c
> @@ -3633,7 +3633,7 @@ static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
>   	int err;
>   
>   	if (!chip->info->ops->phy_read)
> -		return -EOPNOTSUPP;
> +		return -ENODEV;

Still not sure this is the right way to do do it here.

>   
>   	mv88e6xxx_reg_lock(chip);
>   	err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
> @@ -3659,7 +3659,7 @@ static int mv88e6xxx_mdio_read_c45(struct mii_bus *bus, int phy, int devad,
>   	int err;
>   
>   	if (!chip->info->ops->phy_read_c45)
> -		return 0xffff;
> +		return -ENODEV;

Whereas here it makes sense to me to switch to -ENODEV.
diff mbox series

Patch

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 6eec2e4aa031..ce4e4bdf475d 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -3633,7 +3633,7 @@  static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
 	int err;
 
 	if (!chip->info->ops->phy_read)
-		return -EOPNOTSUPP;
+		return -ENODEV;
 
 	mv88e6xxx_reg_lock(chip);
 	err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
@@ -3659,7 +3659,7 @@  static int mv88e6xxx_mdio_read_c45(struct mii_bus *bus, int phy, int devad,
 	int err;
 
 	if (!chip->info->ops->phy_read_c45)
-		return 0xffff;
+		return -ENODEV;
 
 	mv88e6xxx_reg_lock(chip);
 	err = chip->info->ops->phy_read_c45(chip, bus, phy, devad, reg, &val);