diff mbox series

[2/9] net: fec: use device sequence vs index when fetching fec

Message ID 20210630235010.27536-3-tharvey@gateworks.com
State Accepted
Commit b247fa7b178084cb6f71849a5ebbcb5ac107e688
Delegated to: Stefano Babic
Headers show
Series Add support for imx8mm-venice-gw7901 and DSA switch | expand

Commit Message

Tim Harvey June 30, 2021, 11:50 p.m. UTC
When using uclass_get_device* to get the FEC device we need to use
device sequence instead of index into UCLASS_ETH. In systems where for
example a I2C based DSA switch exists it will probe before the FEC
master and its ports will be registered first and have the first
indexes yet the FEC's sequence comes from the device-tree alias.

Take for example the imx8mm-venice-gw7901 board which has an i2c based
DSA switch:

u-boot=> net list
eth1 : lan1 00:0d:8d:aa:00:2f
eth2 : lan2 00:0d:8d:aa:00:30
eth3 : lan3 00:0d:8d:aa:00:31
eth4 : lan4 00:0d:8d:aa:00:32
eth0 : ethernet@30be0000 00:0d:8d:aa:00:2e active

Thus in this case uclass_get_device(UCLASS_ETH, 0, &dev) returns lan1
which is wrong but uclass_get_device_seq(UCLASS_ETH, 0, &dev) returns
ethernet@30be000 which is correct.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
 drivers/net/fec_mxc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ramon Fried July 2, 2021, 9:44 a.m. UTC | #1
On Thu, Jul 1, 2021 at 2:50 AM Tim Harvey <tharvey@gateworks.com> wrote:
>
> When using uclass_get_device* to get the FEC device we need to use
> device sequence instead of index into UCLASS_ETH. In systems where for
> example a I2C based DSA switch exists it will probe before the FEC
> master and its ports will be registered first and have the first
> indexes yet the FEC's sequence comes from the device-tree alias.
>
> Take for example the imx8mm-venice-gw7901 board which has an i2c based
> DSA switch:
>
> u-boot=> net list
> eth1 : lan1 00:0d:8d:aa:00:2f
> eth2 : lan2 00:0d:8d:aa:00:30
> eth3 : lan3 00:0d:8d:aa:00:31
> eth4 : lan4 00:0d:8d:aa:00:32
> eth0 : ethernet@30be0000 00:0d:8d:aa:00:2e active
>
> Thus in this case uclass_get_device(UCLASS_ETH, 0, &dev) returns lan1
> which is wrong but uclass_get_device_seq(UCLASS_ETH, 0, &dev) returns
> ethernet@30be000 which is correct.
>
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
> ---
>  drivers/net/fec_mxc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index 4fd5c01b4a..3abf914833 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -146,7 +146,7 @@ static int fec_get_clk_rate(void *udev, int idx)
>             CONFIG_IS_ENABLED(CLK_CCF)) {
>                 dev = udev;
>                 if (!dev) {
> -                       ret = uclass_get_device(UCLASS_ETH, idx, &dev);
> +                       ret = uclass_get_device_by_seq(UCLASS_ETH, idx, &dev);
>                         if (ret < 0) {
>                                 debug("Can't get FEC udev: %d\n", ret);
>                                 return ret;
> --
> 2.17.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Stefano Babic July 10, 2021, 7:35 p.m. UTC | #2
> When using uclass_get_device* to get the FEC device we need to use
> device sequence instead of index into UCLASS_ETH. In systems where for
> example a I2C based DSA switch exists it will probe before the FEC
> master and its ports will be registered first and have the first
> indexes yet the FEC's sequence comes from the device-tree alias.
> Take for example the imx8mm-venice-gw7901 board which has an i2c based
> DSA switch:
> u-boot=> net list
> eth1 : lan1 00:0d:8d:aa:00:2f
> eth2 : lan2 00:0d:8d:aa:00:30
> eth3 : lan3 00:0d:8d:aa:00:31
> eth4 : lan4 00:0d:8d:aa:00:32
> eth0 : ethernet@30be0000 00:0d:8d:aa:00:2e active
> Thus in this case uclass_get_device(UCLASS_ETH, 0, &dev) returns lan1
> which is wrong but uclass_get_device_seq(UCLASS_ETH, 0, &dev) returns
> ethernet@30be000 which is correct.
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 4fd5c01b4a..3abf914833 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -146,7 +146,7 @@  static int fec_get_clk_rate(void *udev, int idx)
 	    CONFIG_IS_ENABLED(CLK_CCF)) {
 		dev = udev;
 		if (!dev) {
-			ret = uclass_get_device(UCLASS_ETH, idx, &dev);
+			ret = uclass_get_device_by_seq(UCLASS_ETH, idx, &dev);
 			if (ret < 0) {
 				debug("Can't get FEC udev: %d\n", ret);
 				return ret;