Commit c0a1f3d7 authored by Wei Fang's avatar Wei Fang Committed by Paolo Abeni
Browse files

net: fec: do not allow enabling PPS and PEROUT simultaneously



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: 350749b9 ("net: fec: Add support for periodic output signal of PPS")
Signed-off-by: default avatarWei Fang <wei.fang@nxp.com>
Link: https://patch.msgid.link/20251125085210.1094306-4-wei.fang@nxp.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent e97faa0c
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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");