net: microchip: sparx5: fix PTP init/deinit not checking all ports
authorCasper Andersson <casper.casan@gmail.com>
Fri, 3 Feb 2023 08:55:57 +0000 (09:55 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 Feb 2023 09:26:04 +0000 (09:26 +0000)
Check all ports instead of just port_count ports. PTP init was only
checking ports 0 to port_count. If the hardware ports are not mapped
starting from 0 then they would be missed, e.g. if only ports 20-30 were
mapped it would attempt to init ports 0-10, resulting in NULL pointers
when attempting to timestamp. Now it will init all mapped ports.

Fixes: 70dfe25cd866 ("net: sparx5: Update extraction/injection for timestamping")
Signed-off-by: Casper Andersson <casper.casan@gmail.com>
Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c

index 0ed1ea7727c54ea4183118f7e7db94a09b7d1129..69e76634f9aa836e33c88f163382b2f1884886ca 100644 (file)
@@ -633,7 +633,7 @@ int sparx5_ptp_init(struct sparx5 *sparx5)
        /* Enable master counters */
        spx5_wr(PTP_PTP_DOM_CFG_PTP_ENA_SET(0x7), sparx5, PTP_PTP_DOM_CFG);
 
-       for (i = 0; i < sparx5->port_count; i++) {
+       for (i = 0; i < SPX5_PORTS; i++) {
                port = sparx5->ports[i];
                if (!port)
                        continue;
@@ -649,7 +649,7 @@ void sparx5_ptp_deinit(struct sparx5 *sparx5)
        struct sparx5_port *port;
        int i;
 
-       for (i = 0; i < sparx5->port_count; i++) {
+       for (i = 0; i < SPX5_PORTS; i++) {
                port = sparx5->ports[i];
                if (!port)
                        continue;