diff mbox series

[net-next,02/10] net: mdio: mdiobus_register: Update validation test

Message ID 20220508153049.427227-3-andrew@lunn.ch (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: mdio: Start separating C22 and C45 | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
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 6 maintainers not CCed: linux-arm-kernel@lists.infradead.org linux-mediatek@lists.infradead.org edumazet@google.com pabeni@redhat.com kuba@kernel.org davem@davemloft.net
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/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, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Andrew Lunn May 8, 2022, 3:30 p.m. UTC
Now that C45 uses its own read/write methods, the validation performed
when a bus is registers needs updating. All combinations of C22 and
C45 are supported, but both read and write methods must be provided,
read only busses are not supported etc.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/phy/mdio_bus.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Sergey Shtylyov May 9, 2022, 7:49 a.m. UTC | #1
Hello!

On 5/8/22 6:30 PM, Andrew Lunn wrote:

> Now that C45 uses its own read/write methods, the validation performed
> when a bus is registers needs updating. All combinations of C22 and
> C45 are supported, but both read and write methods must be provided,
> read only busses are not supported etc.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
>  drivers/net/phy/mdio_bus.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> index 46a03c0b45e3..818d22fb3cb5 100644
> --- a/drivers/net/phy/mdio_bus.c
> +++ b/drivers/net/phy/mdio_bus.c
> @@ -526,8 +526,16 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner)
>  	int i, err;
>  	struct gpio_desc *gpiod;
>  
> -	if (NULL == bus || NULL == bus->name ||
> -	    NULL == bus->read || NULL == bus->write)
> +	if (NULL == bus || NULL == bus->name)

   I suggest (!bus || !bus->name) to be consistent with the code below.
   BTW, doesn't checkpatch.pl complain about NULL == bus?

> +		return -EINVAL;
> +
> +	if (!bus->read != !bus->write)
> +		return -EINVAL;
> +
> +	if (!bus->read_c45 != !bus->write_c45)
> +		return -EINVAL;

   Hm, that's complicated! :-)

> +
> +	if (!bus->read && !bus->read_c45)
>  		return -EINVAL;
>  
>  	if (bus->parent && bus->parent->of_node)

MBR, Sergey
diff mbox series

Patch

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 46a03c0b45e3..818d22fb3cb5 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -526,8 +526,16 @@  int __mdiobus_register(struct mii_bus *bus, struct module *owner)
 	int i, err;
 	struct gpio_desc *gpiod;
 
-	if (NULL == bus || NULL == bus->name ||
-	    NULL == bus->read || NULL == bus->write)
+	if (NULL == bus || NULL == bus->name)
+		return -EINVAL;
+
+	if (!bus->read != !bus->write)
+		return -EINVAL;
+
+	if (!bus->read_c45 != !bus->write_c45)
+		return -EINVAL;
+
+	if (!bus->read && !bus->read_c45)
 		return -EINVAL;
 
 	if (bus->parent && bus->parent->of_node)