[PATCH] net: dsa: b53: mmap: fix device tree support

Álvaro Fernández Rojas posted 1 patch 3 years, 1 month ago
There is a newer version of this series
drivers/net/dsa/b53/b53_mmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] net: dsa: b53: mmap: fix device tree support
Posted by Álvaro Fernández Rojas 3 years, 1 month ago
B53_CPU_PORT should also be enabled in order to get a working switch.

Fixes: a5538a777b73 ("net: dsa: b53: mmap: Add device tree support")
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 drivers/net/dsa/b53/b53_mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/b53/b53_mmap.c b/drivers/net/dsa/b53/b53_mmap.c
index e968322dfbf0..24ea2e19dfa6 100644
--- a/drivers/net/dsa/b53/b53_mmap.c
+++ b/drivers/net/dsa/b53/b53_mmap.c
@@ -263,7 +263,7 @@ static int b53_mmap_probe_of(struct platform_device *pdev,
 		if (of_property_read_u32(of_port, "reg", &reg))
 			continue;
 
-		if (reg < B53_CPU_PORT)
+		if (reg <= B53_CPU_PORT)
 			pdata->enabled_ports |= BIT(reg);
 	}
 
-- 
2.30.2

Re: [PATCH] net: dsa: b53: mmap: fix device tree support
Posted by Jakub Kicinski 3 years ago
On Fri, 10 Mar 2023 13:10:59 +0100 Álvaro Fernández Rojas wrote:
> diff --git a/drivers/net/dsa/b53/b53_mmap.c b/drivers/net/dsa/b53/b53_mmap.c
> index e968322dfbf0..24ea2e19dfa6 100644
> --- a/drivers/net/dsa/b53/b53_mmap.c
> +++ b/drivers/net/dsa/b53/b53_mmap.c
> @@ -263,7 +263,7 @@ static int b53_mmap_probe_of(struct platform_device *pdev,
>  		if (of_property_read_u32(of_port, "reg", &reg))
>  			continue;
>  
> -		if (reg < B53_CPU_PORT)
> +		if (reg <= B53_CPU_PORT)
>  			pdata->enabled_ports |= BIT(reg);

Should we switch to B53_N_PORTS instead?
That's the bound used by the local "for each port" macro:

#define b53_for_each_port(dev, i) \      
        for (i = 0; i < B53_N_PORTS; i++) \
                if (dev->enabled_ports & BIT(i)) 
Re: [PATCH] net: dsa: b53: mmap: fix device tree support
Posted by Florian Fainelli 3 years ago
On 3/15/23 00:06, Jakub Kicinski wrote:
> On Fri, 10 Mar 2023 13:10:59 +0100 Álvaro Fernández Rojas wrote:
>> diff --git a/drivers/net/dsa/b53/b53_mmap.c b/drivers/net/dsa/b53/b53_mmap.c
>> index e968322dfbf0..24ea2e19dfa6 100644
>> --- a/drivers/net/dsa/b53/b53_mmap.c
>> +++ b/drivers/net/dsa/b53/b53_mmap.c
>> @@ -263,7 +263,7 @@ static int b53_mmap_probe_of(struct platform_device *pdev,
>>   		if (of_property_read_u32(of_port, "reg", &reg))
>>   			continue;
>>   
>> -		if (reg < B53_CPU_PORT)
>> +		if (reg <= B53_CPU_PORT)
>>   			pdata->enabled_ports |= BIT(reg);
> 
> Should we switch to B53_N_PORTS instead?
> That's the bound used by the local "for each port" macro:
> 
> #define b53_for_each_port(dev, i) \
>          for (i = 0; i < B53_N_PORTS; i++) \
>                  if (dev->enabled_ports & BIT(i))

Yes, checking against B53_N_PORTS would be a better check.
-- 
Florian

[PATCH v2] net: dsa: b53: mmap: fix device tree support
Posted by Álvaro Fernández Rojas 3 years ago
CPU port should also be enabled in order to get a working switch.

Fixes: a5538a777b73 ("net: dsa: b53: mmap: Add device tree support")
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v2: switch to B53_N_PORTS

 drivers/net/dsa/b53/b53_mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/b53/b53_mmap.c b/drivers/net/dsa/b53/b53_mmap.c
index e968322dfbf0..70887e0aece3 100644
--- a/drivers/net/dsa/b53/b53_mmap.c
+++ b/drivers/net/dsa/b53/b53_mmap.c
@@ -263,7 +263,7 @@ static int b53_mmap_probe_of(struct platform_device *pdev,
 		if (of_property_read_u32(of_port, "reg", &reg))
 			continue;
 
-		if (reg < B53_CPU_PORT)
+		if (reg < B53_N_PORTS)
 			pdata->enabled_ports |= BIT(reg);
 	}
 
-- 
2.30.2

Re: [PATCH v2] net: dsa: b53: mmap: fix device tree support
Posted by Florian Fainelli 3 years ago
On 3/16/23 10:28, Álvaro Fernández Rojas wrote:
> CPU port should also be enabled in order to get a working switch.
> 
> Fixes: a5538a777b73 ("net: dsa: b53: mmap: Add device tree support")
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian