]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: fec: do not allow enabling PPS and PEROUT simultaneously
authorWei Fang <wei.fang@nxp.com>
Tue, 25 Nov 2025 08:52:09 +0000 (16:52 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 27 Nov 2025 10:57:45 +0000 (11:57 +0100)
In the current driver, PPS and PEROUT use the same channel to generate
the events, so they cannot be enabled at the same time. Otherwise, the
later configuration will overwrite the earlier configuration. Therefore,
when configuring PPS, the driver will check whether PEROUT is enabled.
Similarly, when configuring PEROUT, the driver will check whether PPS
is enabled.

Fixes: 350749b909bf ("net: fec: Add support for periodic output signal of PPS")
Signed-off-by: Wei Fang <wei.fang@nxp.com>
Link: https://patch.msgid.link/20251125085210.1094306-4-wei.fang@nxp.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/freescale/fec_ptp.c

index f31b1626c12f75e15da5ab94b9baf901f44b2913..ed5d59abeb5373e264e2cebf342ba8f0106b1238 100644 (file)
@@ -128,6 +128,12 @@ static int fec_ptp_enable_pps(struct fec_enet_private *fep, uint enable)
 
        spin_lock_irqsave(&fep->tmreg_lock, flags);
 
+       if (fep->perout_enable) {
+               spin_unlock_irqrestore(&fep->tmreg_lock, flags);
+               dev_err(&fep->pdev->dev, "PEROUT is running");
+               return -EBUSY;
+       }
+
        if (fep->pps_enable == enable) {
                spin_unlock_irqrestore(&fep->tmreg_lock, flags);
                return 0;
@@ -571,6 +577,12 @@ static int fec_ptp_enable(struct ptp_clock_info *ptp,
                        }
                        spin_lock_irqsave(&fep->tmreg_lock, flags);
 
+                       if (fep->pps_enable) {
+                               dev_err(&fep->pdev->dev, "PPS is running");
+                               ret = -EBUSY;
+                               goto unlock;
+                       }
+
                        if (fep->perout_enable) {
                                dev_err(&fep->pdev->dev,
                                        "PEROUT has been enabled\n");