diff mbox series

net: dsa: b53: mmap: fix device tree support

Message ID 20230310121059.4498-1-noltari@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: b53: mmap: fix device tree support | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
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: 18 this patch: 18
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
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 Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 18 this patch: 18
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Álvaro Fernández Rojas March 10, 2023, 12:10 p.m. UTC
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(-)

Comments

Jakub Kicinski March 15, 2023, 7:06 a.m. UTC | #1
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))
Florian Fainelli March 15, 2023, 6:29 p.m. UTC | #2
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.
diff mbox series

Patch

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);
 	}