]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: stmmac: ptp: conditionally populate getcrosststamp() method
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Wed, 3 Sep 2025 14:00:51 +0000 (15:00 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 6 Sep 2025 01:45:14 +0000 (18:45 -0700)
drivers/char/ptp_chardev.c::ptp_clock_getcaps() uses the presence of
the getcrosststamp() method to indicate to userspace whether
crosststamping is supported or not. Therefore, we should not provide
this method unless it is functional. Only set this method pointer
in stmmac_ptp_register() if the platform glue provides the
necessary functionality.

This does not mean that it will be supported (see intel_crosststamp(),
which is the only implementation that may have support) but at least
we won't be suggesting that it is supported on many platforms where
there is no hope.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1uto2d-00000001se4-0JSY@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c

index ecbff20771f4ecd50b34ab3f84a279ba6a7939c5..69bd8ace139cd8411e49cf11e60248910272cf98 100644 (file)
@@ -279,10 +279,7 @@ static int stmmac_get_syncdevicetime(ktime_t *device,
 {
        struct stmmac_priv *priv = (struct stmmac_priv *)ctx;
 
-       if (priv->plat->crosststamp)
-               return priv->plat->crosststamp(device, system, ctx);
-       else
-               return -EOPNOTSUPP;
+       return priv->plat->crosststamp(device, system, ctx);
 }
 
 static int stmmac_getcrosststamp(struct ptp_clock_info *ptp,
@@ -310,7 +307,6 @@ const struct ptp_clock_info stmmac_ptp_clock_ops = {
        .gettime64 = stmmac_get_time,
        .settime64 = stmmac_set_time,
        .enable = stmmac_enable,
-       .getcrosststamp = stmmac_getcrosststamp,
 };
 
 /* structure describing a PTP hardware clock */
@@ -328,7 +324,6 @@ const struct ptp_clock_info dwmac1000_ptp_clock_ops = {
        .gettime64 = stmmac_get_time,
        .settime64 = stmmac_set_time,
        .enable = dwmac1000_ptp_enable,
-       .getcrosststamp = stmmac_getcrosststamp,
 };
 
 /**
@@ -364,6 +359,9 @@ void stmmac_ptp_register(struct stmmac_priv *priv)
        if (priv->plat->ptp_max_adj)
                priv->ptp_clock_ops.max_adj = priv->plat->ptp_max_adj;
 
+       if (priv->plat->crosststamp)
+               priv->ptp_clock_ops.getcrosststamp = stmmac_getcrosststamp;
+
        rwlock_init(&priv->ptp_lock);
        mutex_init(&priv->aux_ts_lock);