@@ -261,17 +261,13 @@ static int arm_tod_read_trig_sel_refclk(struct idtcm_channel *channel, u8 ref)
if (err)
dev_err(idtcm->dev, "%s: err = %d", __func__, err);
-
return err;
}
static bool is_single_shot(u8 mask)
{
/* Treat single bit ToD masks as continuous trigger */
- if ((mask == 1) || (mask == 2) || (mask == 4) || (mask == 8))
- return false;
- else
- return true;
+ return mask <= 8 && is_power_of_2(mask);
}
static int idtcm_extts_enable(struct idtcm_channel *channel,
@@ -418,13 +414,10 @@ static int _idtcm_gettime_triggered(struct idtcm_channel *channel,
err = idtcm_read(idtcm, channel->tod_read_secondary,
TOD_READ_SECONDARY_BASE, buf, sizeof(buf));
-
if (err)
return err;
- err = char_array_to_timespec(buf, sizeof(buf), ts);
-
- return err;
+ return char_array_to_timespec(buf, sizeof(buf), ts);
}
static int _idtcm_gettime(struct idtcm_channel *channel,
@@ -456,9 +449,7 @@ static int _idtcm_gettime(struct idtcm_channel *channel,
if (err)
return err;
- err = char_array_to_timespec(buf, sizeof(buf), ts);
-
- return err;
+ return char_array_to_timespec(buf, sizeof(buf), ts);
}
static int idtcm_extts_check_channel(struct idtcm *idtcm, u8 todn)
@@ -500,13 +491,10 @@ static int _idtcm_gettime_immediate(struct idtcm_channel *channel,
err = idtcm_write(idtcm, channel->tod_read_primary,
tod_read_cmd, &val, sizeof(val));
-
if (err)
return err;
- err = _idtcm_gettime(channel, ts, 10);
-
- return err;
+ return _idtcm_gettime(channel, ts, 10);
}
static int _sync_pll_output(struct idtcm *idtcm,
@@ -631,9 +619,7 @@ static int _sync_pll_output(struct idtcm *idtcm,
/* Place master sync out of reset */
val &= ~(SYNCTRL1_MASTER_SYNC_RST);
- err = idtcm_write(idtcm, 0, sync_ctrl1, &val, sizeof(val));
-
- return err;
+ return idtcm_write(idtcm, 0, sync_ctrl1, &val, sizeof(val));
}
static int idtcm_sync_pps_output(struct idtcm_channel *channel)
@@ -917,7 +903,6 @@ static int _idtcm_settime(struct idtcm_channel *channel,
static int idtcm_set_phase_pull_in_offset(struct idtcm_channel *channel,
s32 offset_ns)
{
- int err;
int i;
struct idtcm *idtcm = channel->idtcm;
u8 buf[4];
@@ -927,16 +912,13 @@ static int idtcm_set_phase_pull_in_offset(struct idtcm_channel *channel,
offset_ns >>= 8;
}
- err = idtcm_write(idtcm, channel->dpll_phase_pull_in, PULL_IN_OFFSET,
- buf, sizeof(buf));
-
- return err;
+ return idtcm_write(idtcm, channel->dpll_phase_pull_in, PULL_IN_OFFSET,
+ buf, sizeof(buf));
}
static int idtcm_set_phase_pull_in_slope_limit(struct idtcm_channel *channel,
u32 max_ffo_ppb)
{
- int err;
u8 i;
struct idtcm *idtcm = channel->idtcm;
u8 buf[3];
@@ -949,10 +931,8 @@ static int idtcm_set_phase_pull_in_slope_limit(struct idtcm_channel *channel,
max_ffo_ppb >>= 8;
}
- err = idtcm_write(idtcm, channel->dpll_phase_pull_in,
- PULL_IN_SLOPE_LIMIT, buf, sizeof(buf));
-
- return err;
+ return idtcm_write(idtcm, channel->dpll_phase_pull_in,
+ PULL_IN_SLOPE_LIMIT, buf, sizeof(buf));
}
static int idtcm_start_phase_pull_in(struct idtcm_channel *channel)
@@ -991,9 +971,7 @@ static int do_phase_pull_in_fw(struct idtcm_channel *channel,
if (err)
return err;
- err = idtcm_start_phase_pull_in(channel);
-
- return err;
+ return idtcm_start_phase_pull_in(channel);
}
static int set_tod_write_overhead(struct idtcm_channel *channel)
@@ -1417,10 +1395,9 @@ static int idtcm_set_pll_mode(struct idtcm_channel *channel,
dpll_mode |= (mode << PLL_MODE_SHIFT);
- err = idtcm_write(idtcm, channel->dpll_n,
- IDTCM_FW_REG(idtcm->fw_ver, V520, DPLL_MODE),
- &dpll_mode, sizeof(dpll_mode));
- return err;
+ return idtcm_write(idtcm, channel->dpll_n,
+ IDTCM_FW_REG(idtcm->fw_ver, V520, DPLL_MODE),
+ &dpll_mode, sizeof(dpll_mode));
}
static int idtcm_get_manual_reference(struct idtcm_channel *channel,
@@ -1460,11 +1437,9 @@ static int idtcm_set_manual_reference(struct idtcm_channel *channel,
dpll_manu_ref_cfg |= (ref << MANUAL_REFERENCE_SHIFT);
- err = idtcm_write(idtcm, channel->dpll_ctrl_n,
- DPLL_CTRL_DPLL_MANU_REF_CFG,
- &dpll_manu_ref_cfg, sizeof(dpll_manu_ref_cfg));
-
- return err;
+ return idtcm_write(idtcm, channel->dpll_ctrl_n,
+ DPLL_CTRL_DPLL_MANU_REF_CFG,
+ &dpll_manu_ref_cfg, sizeof(dpll_manu_ref_cfg));
}
static int configure_dpll_mode_write_frequency(struct idtcm_channel *channel)
@@ -1746,10 +1721,8 @@ static int _idtcm_adjphase(struct idtcm_channel *channel, s32 delta_ns)
phase_50ps >>= 8;
}
- err = idtcm_write(idtcm, channel->dpll_phase, DPLL_WR_PHASE,
- buf, sizeof(buf));
-
- return err;
+ return idtcm_write(idtcm, channel->dpll_phase, DPLL_WR_PHASE,
+ buf, sizeof(buf));
}
static int _idtcm_adjfine(struct idtcm_channel *channel, long scaled_ppm)
@@ -1790,10 +1763,8 @@ static int _idtcm_adjfine(struct idtcm_channel *channel, long scaled_ppm)
fcw >>= 8;
}
- err = idtcm_write(idtcm, channel->dpll_freq, DPLL_WR_FREQ,
- buf, sizeof(buf));
-
- return err;
+ return idtcm_write(idtcm, channel->dpll_freq, DPLL_WR_FREQ,
+ buf, sizeof(buf));
}
static int idtcm_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
suggested by Jakub Kicinski Signed-off-by: Min Li <min.li.xe@renesas.com> --- drivers/ptp/ptp_clockmatrix.c | 69 +++++++++++++------------------------------ 1 file changed, 20 insertions(+), 49 deletions(-)