From 61c77126278eb950010d2ed944c3bc09d10e0eb4 Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Sat, 12 Oct 2019 02:18:14 +0300 Subject: net: dsa: sja1105: Make all public PTP functions take dsa_switch as argument The new rule (as already started for sja1105_tas.h) is for functions of optional driver components (ones which may be disabled via Kconfig - PTP and TAS) to take struct dsa_switch *ds instead of struct sja1105_private *priv as first argument. This is so that forward-declarations of struct sja1105_private can be avoided. So make sja1105_ptp.h the second user of this rule. Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller --- drivers/net/dsa/sja1105/sja1105_ptp.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'drivers/net/dsa/sja1105/sja1105_ptp.c') diff --git a/drivers/net/dsa/sja1105/sja1105_ptp.c b/drivers/net/dsa/sja1105/sja1105_ptp.c index 6b0bfa0444a2..d9cae68d544c 100644 --- a/drivers/net/dsa/sja1105/sja1105_ptp.c +++ b/drivers/net/dsa/sja1105/sja1105_ptp.c @@ -78,10 +78,10 @@ int sja1105_get_ts_info(struct dsa_switch *ds, int port, return 0; } -int sja1105et_ptp_cmd(const void *ctx, const void *data) +int sja1105et_ptp_cmd(const struct dsa_switch *ds, const void *data) { + const struct sja1105_private *priv = ds->priv; const struct sja1105_ptp_cmd *cmd = data; - const struct sja1105_private *priv = ctx; const struct sja1105_regs *regs = priv->info->regs; const int size = SJA1105_SIZE_PTP_CMD; u8 buf[SJA1105_SIZE_PTP_CMD] = {0}; @@ -95,10 +95,10 @@ int sja1105et_ptp_cmd(const void *ctx, const void *data) SJA1105_SIZE_PTP_CMD); } -int sja1105pqrs_ptp_cmd(const void *ctx, const void *data) +int sja1105pqrs_ptp_cmd(const struct dsa_switch *ds, const void *data) { + const struct sja1105_private *priv = ds->priv; const struct sja1105_ptp_cmd *cmd = data; - const struct sja1105_private *priv = ctx; const struct sja1105_regs *regs = priv->info->regs; const int size = SJA1105_SIZE_PTP_CMD; u8 buf[SJA1105_SIZE_PTP_CMD] = {0}; @@ -126,9 +126,10 @@ int sja1105pqrs_ptp_cmd(const void *ctx, const void *data) * Must be called within one wraparound period of the partial timestamp since * it was generated by the MAC. */ -u64 sja1105_tstamp_reconstruct(struct sja1105_private *priv, u64 now, +u64 sja1105_tstamp_reconstruct(struct dsa_switch *ds, u64 now, u64 ts_partial) { + struct sja1105_private *priv = ds->priv; u64 partial_tstamp_mask = CYCLECOUNTER_MASK(priv->info->ptp_ts_bits); u64 ts_reconstructed; @@ -170,8 +171,9 @@ u64 sja1105_tstamp_reconstruct(struct sja1105_private *priv, u64 now, * To have common code for E/T and P/Q/R/S for reading the timestamp, * we need to juggle with the offset and the bit indices. */ -int sja1105_ptpegr_ts_poll(struct sja1105_private *priv, int port, u64 *ts) +int sja1105_ptpegr_ts_poll(struct dsa_switch *ds, int port, u64 *ts) { + struct sja1105_private *priv = ds->priv; const struct sja1105_regs *regs = priv->info->regs; int tstamp_bit_start, tstamp_bit_end; int timeout = 10; @@ -214,9 +216,9 @@ int sja1105_ptpegr_ts_poll(struct sja1105_private *priv, int port, u64 *ts) return 0; } -int sja1105_ptp_reset(struct sja1105_private *priv) +int sja1105_ptp_reset(struct dsa_switch *ds) { - struct dsa_switch *ds = priv->ds; + struct sja1105_private *priv = ds->priv; struct sja1105_ptp_cmd cmd = {0}; int rc; @@ -224,7 +226,7 @@ int sja1105_ptp_reset(struct sja1105_private *priv) cmd.resptp = 1; dev_dbg(ds->dev, "Resetting PTP clock\n"); - rc = priv->info->ptp_cmd(priv, &cmd); + rc = priv->info->ptp_cmd(ds, &cmd); timecounter_init(&priv->tstamp_tc, &priv->tstamp_cc, ktime_to_ns(ktime_get_real())); @@ -344,9 +346,9 @@ static void sja1105_ptp_overflow_check(struct work_struct *work) schedule_delayed_work(&priv->refresh_work, SJA1105_REFRESH_INTERVAL); } -int sja1105_ptp_clock_register(struct sja1105_private *priv) +int sja1105_ptp_clock_register(struct dsa_switch *ds) { - struct dsa_switch *ds = priv->ds; + struct sja1105_private *priv = ds->priv; /* Set up the cycle counter */ priv->tstamp_cc = (struct cyclecounter) { @@ -374,11 +376,13 @@ int sja1105_ptp_clock_register(struct sja1105_private *priv) INIT_DELAYED_WORK(&priv->refresh_work, sja1105_ptp_overflow_check); schedule_delayed_work(&priv->refresh_work, SJA1105_REFRESH_INTERVAL); - return sja1105_ptp_reset(priv); + return sja1105_ptp_reset(ds); } -void sja1105_ptp_clock_unregister(struct sja1105_private *priv) +void sja1105_ptp_clock_unregister(struct dsa_switch *ds) { + struct sja1105_private *priv = ds->priv; + if (IS_ERR_OR_NULL(priv->clock)) return; -- cgit v1.2.3-59-g8ed1b