net: mscc: ocelot: fix timestamp info if ptp clock does not work
authorYangbo Lu <yangbo.lu@nxp.com>
Mon, 20 Apr 2020 02:46:46 +0000 (10:46 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 21 Apr 2020 22:38:33 +0000 (15:38 -0700)
The timestamp info should be only software timestamp capabilities
if ptp clock does not work.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mscc/ocelot.c

index 7c4165a..a2b9b85 100644 (file)
@@ -1349,6 +1349,12 @@ int ocelot_get_ts_info(struct ocelot *ocelot, int port,
 {
        info->phc_index = ocelot->ptp_clock ?
                          ptp_clock_index(ocelot->ptp_clock) : -1;
+       if (info->phc_index == -1) {
+               info->so_timestamping |= SOF_TIMESTAMPING_TX_SOFTWARE |
+                                        SOF_TIMESTAMPING_RX_SOFTWARE |
+                                        SOF_TIMESTAMPING_SOFTWARE;
+               return 0;
+       }
        info->so_timestamping |= SOF_TIMESTAMPING_TX_SOFTWARE |
                                 SOF_TIMESTAMPING_RX_SOFTWARE |
                                 SOF_TIMESTAMPING_SOFTWARE |