* [PATCH v3 net-next 0/7] ptp: ptp_clockmatrix: Fix output 1 PPS alignment.
@ 2021-02-17 5:42 vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 1/7] ptp: ptp_clockmatrix: Add wait_for_sys_apll_dpll_lock vincent.cheng.xh
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: vincent.cheng.xh @ 2021-02-17 5:42 UTC (permalink / raw)
To: richardcochran; +Cc: netdev, linux-kernel, Vincent Cheng
From: Vincent Cheng <vincent.cheng.xh@renesas.com>
This series fixes a race condition that may result in the output clock
not aligned to internal 1 PPS clock.
Part of device initialization is to align the rising edge of output
clocks to the internal rising edge of the 1 PPS clock. If the system
APLL and DPLL are not locked when this alignment occurs, the alignment
fails and a fixed offset between the internal 1 PPS clock and the
output clock occurs.
If a clock is dynamically enabled after power-up, the output clock
also needs to be aligned to the internal 1 PPS clock.
v3:
Suggested by: Jakub Kicinski <kuba@kernel.org>
- Remove unnecessary 'err' variable
- Increase msleep()/loop accuracy by using jiffies in while()
- No empty lines between variables
- No empty lines between call and the if
- parenthesis around a == b are unnecessary
- Inconsistent \n usage in dev_()
- Remove unnecessary empty line
- Leave string format in place so static code checkers can
validate arguments
v2:
Suggested by: Richard Cochran <richardcochran@gmail.com>
- Added const to "char * fmt"
- Break unrelated header change into separate patch
Vincent Cheng (7):
ptp: ptp_clockmatrix: Add wait_for_sys_apll_dpll_lock.
ptp: ptp_clockmatrix: Add alignment of 1 PPS to idtcm_perout_enable.
ptp: ptp_clockmatrix: Remove unused header declarations.
ptp: ptp_clockmatrix: Clean-up dev_*() messages.
ptp: ptp_clockmatrix: Coding style - tighten vertical spacing.
ptp: ptp_clockmatrix: Simplify code - remove unnecessary `err`
variable.
ptp: ptp_clockmatrix: clean-up - parenthesis around a == b are
unnecessary
drivers/ptp/idt8a340_reg.h | 10 ++
drivers/ptp/ptp_clockmatrix.c | 313 ++++++++++++++++++------------------------
drivers/ptp/ptp_clockmatrix.h | 17 ++-
3 files changed, 162 insertions(+), 178 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3 net-next 1/7] ptp: ptp_clockmatrix: Add wait_for_sys_apll_dpll_lock.
2021-02-17 5:42 [PATCH v3 net-next 0/7] ptp: ptp_clockmatrix: Fix output 1 PPS alignment vincent.cheng.xh
@ 2021-02-17 5:42 ` vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 2/7] ptp: ptp_clockmatrix: Add alignment of 1 PPS to idtcm_perout_enable vincent.cheng.xh
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: vincent.cheng.xh @ 2021-02-17 5:42 UTC (permalink / raw)
To: richardcochran; +Cc: netdev, linux-kernel, Vincent Cheng
From: Vincent Cheng <vincent.cheng.xh@renesas.com>
Part of the device initialization aligns the rising edge of the output
clock to the internal 1 PPS clock. If the system APLL and DPLL is not
locked, then the alignment will fail and there will be a fixed offset
between the internal 1 PPS clock and the output clock.
After loading the device firmware, poll the system APLL and DPLL for
locked state prior to initialization, timing out after 2 seconds.
Signed-off-by: Vincent Cheng <vincent.cheng.xh@renesas.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
---
drivers/ptp/idt8a340_reg.h | 10 +++++++
drivers/ptp/ptp_clockmatrix.c | 64 +++++++++++++++++++++++++++++++++++++++++--
drivers/ptp/ptp_clockmatrix.h | 15 ++++++++++
3 files changed, 87 insertions(+), 2 deletions(-)
diff --git a/drivers/ptp/idt8a340_reg.h b/drivers/ptp/idt8a340_reg.h
index a664dfe..ac524cf 100644
--- a/drivers/ptp/idt8a340_reg.h
+++ b/drivers/ptp/idt8a340_reg.h
@@ -122,6 +122,8 @@
#define OTP_SCSR_CONFIG_SELECT 0x0022
#define STATUS 0xc03c
+#define DPLL_SYS_STATUS 0x0020
+#define DPLL_SYS_APLL_STATUS 0x0021
#define USER_GPIO0_TO_7_STATUS 0x008a
#define USER_GPIO8_TO_15_STATUS 0x008b
@@ -707,4 +709,12 @@
/* Bit definitions for the DPLL_CTRL_COMBO_MASTER_CFG register */
#define COMBO_MASTER_HOLD BIT(0)
+/* Bit definitions for DPLL_SYS_STATUS register */
+#define DPLL_SYS_STATE_MASK (0xf)
+
+/* Bit definitions for SYS_APLL_STATUS register */
+#define SYS_APLL_LOSS_LOCK_LIVE_MASK BIT(0)
+#define SYS_APLL_LOSS_LOCK_LIVE_LOCKED 0
+#define SYS_APLL_LOSS_LOCK_LIVE_UNLOCKED 1
+
#endif
diff --git a/drivers/ptp/ptp_clockmatrix.c b/drivers/ptp/ptp_clockmatrix.c
index 051511f..9bfd32b 100644
--- a/drivers/ptp/ptp_clockmatrix.c
+++ b/drivers/ptp/ptp_clockmatrix.c
@@ -335,6 +335,67 @@ static int wait_for_boot_status_ready(struct idtcm *idtcm)
return -EBUSY;
}
+static int read_sys_apll_status(struct idtcm *idtcm, u8 *status)
+{
+ return idtcm_read(idtcm, STATUS, DPLL_SYS_APLL_STATUS, status,
+ sizeof(u8));
+}
+
+static int read_sys_dpll_status(struct idtcm *idtcm, u8 *status)
+{
+ return idtcm_read(idtcm, STATUS, DPLL_SYS_STATUS, status, sizeof(u8));
+}
+
+static int wait_for_sys_apll_dpll_lock(struct idtcm *idtcm)
+{
+ unsigned long timeout = jiffies + msecs_to_jiffies(LOCK_TIMEOUT_MS);
+ u8 apll = 0;
+ u8 dpll = 0;
+ int err;
+
+ do {
+ err = read_sys_apll_status(idtcm, &apll);
+ if (err)
+ return err;
+
+ err = read_sys_dpll_status(idtcm, &dpll);
+ if (err)
+ return err;
+
+ apll &= SYS_APLL_LOSS_LOCK_LIVE_MASK;
+ dpll &= DPLL_SYS_STATE_MASK;
+
+ if (apll == SYS_APLL_LOSS_LOCK_LIVE_LOCKED &&
+ dpll == DPLL_STATE_LOCKED) {
+ return 0;
+ } else if (dpll == DPLL_STATE_FREERUN ||
+ dpll == DPLL_STATE_HOLDOVER ||
+ dpll == DPLL_STATE_OPEN_LOOP) {
+ dev_warn(&idtcm->client->dev,
+ "No wait state: DPLL_SYS_STATE %d", dpll);
+ return -EPERM;
+ }
+
+ msleep(LOCK_POLL_INTERVAL_MS);
+ } while (time_is_after_jiffies(timeout));
+
+ dev_warn(&idtcm->client->dev,
+ "%d ms lock timeout: SYS APLL Loss Lock %d SYS DPLL state %d",
+ LOCK_TIMEOUT_MS, apll, dpll);
+
+ return -ETIME;
+}
+
+static void wait_for_chip_ready(struct idtcm *idtcm)
+{
+ if (wait_for_boot_status_ready(idtcm))
+ dev_warn(&idtcm->client->dev, "BOOT_STATUS != 0xA0");
+
+ if (wait_for_sys_apll_dpll_lock(idtcm))
+ dev_warn(&idtcm->client->dev,
+ "Continuing while SYS APLL/DPLL is not locked");
+}
+
static int _idtcm_gettime(struct idtcm_channel *channel,
struct timespec64 *ts)
{
@@ -2235,8 +2296,7 @@ static int idtcm_probe(struct i2c_client *client,
dev_warn(&idtcm->client->dev,
"loading firmware failed with %d\n", err);
- if (wait_for_boot_status_ready(idtcm))
- dev_warn(&idtcm->client->dev, "BOOT_STATUS != 0xA0\n");
+ wait_for_chip_ready(idtcm);
if (idtcm->tod_mask) {
for (i = 0; i < MAX_TOD; i++) {
diff --git a/drivers/ptp/ptp_clockmatrix.h b/drivers/ptp/ptp_clockmatrix.h
index 645de2c..0233236 100644
--- a/drivers/ptp/ptp_clockmatrix.h
+++ b/drivers/ptp/ptp_clockmatrix.h
@@ -51,6 +51,9 @@
#define TOD_WRITE_OVERHEAD_COUNT_MAX (2)
#define TOD_BYTE_COUNT (11)
+#define LOCK_TIMEOUT_MS (2000)
+#define LOCK_POLL_INTERVAL_MS (10)
+
#define PEROUT_ENABLE_OUTPUT_MASK (0xdeadbeef)
#define IDTCM_MAX_WRITE_COUNT (512)
@@ -105,6 +108,18 @@ enum scsr_tod_write_type_sel {
SCSR_TOD_WR_TYPE_SEL_MAX = SCSR_TOD_WR_TYPE_SEL_DELTA_MINUS,
};
+/* Values STATUS.DPLL_SYS_STATUS.DPLL_SYS_STATE */
+enum dpll_state {
+ DPLL_STATE_MIN = 0,
+ DPLL_STATE_FREERUN = DPLL_STATE_MIN,
+ DPLL_STATE_LOCKACQ = 1,
+ DPLL_STATE_LOCKREC = 2,
+ DPLL_STATE_LOCKED = 3,
+ DPLL_STATE_HOLDOVER = 4,
+ DPLL_STATE_OPEN_LOOP = 5,
+ DPLL_STATE_MAX = DPLL_STATE_OPEN_LOOP,
+};
+
struct idtcm;
struct idtcm_channel {
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 net-next 2/7] ptp: ptp_clockmatrix: Add alignment of 1 PPS to idtcm_perout_enable.
2021-02-17 5:42 [PATCH v3 net-next 0/7] ptp: ptp_clockmatrix: Fix output 1 PPS alignment vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 1/7] ptp: ptp_clockmatrix: Add wait_for_sys_apll_dpll_lock vincent.cheng.xh
@ 2021-02-17 5:42 ` vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 3/7] ptp: ptp_clockmatrix: Remove unused header declarations vincent.cheng.xh
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: vincent.cheng.xh @ 2021-02-17 5:42 UTC (permalink / raw)
To: richardcochran; +Cc: netdev, linux-kernel, Vincent Cheng
From: Vincent Cheng <vincent.cheng.xh@renesas.com>
When enabling output using PTP_CLK_REQ_PEROUT, need to align the output
clock to the internal 1 PPS clock.
Signed-off-by: Vincent Cheng <vincent.cheng.xh@renesas.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
---
drivers/ptp/ptp_clockmatrix.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/ptp/ptp_clockmatrix.c b/drivers/ptp/ptp_clockmatrix.c
index 9bfd32b..f597e4f 100644
--- a/drivers/ptp/ptp_clockmatrix.c
+++ b/drivers/ptp/ptp_clockmatrix.c
@@ -1389,13 +1389,23 @@ static int idtcm_perout_enable(struct idtcm_channel *channel,
bool enable,
struct ptp_perout_request *perout)
{
+ struct idtcm *idtcm = channel->idtcm;
unsigned int flags = perout->flags;
+ struct timespec64 ts = {0, 0};
+ int err;
if (flags == PEROUT_ENABLE_OUTPUT_MASK)
- return idtcm_output_mask_enable(channel, enable);
+ err = idtcm_output_mask_enable(channel, enable);
+ else
+ err = idtcm_output_enable(channel, enable, perout->index);
+
+ if (err) {
+ dev_err(&idtcm->client->dev, "Unable to set output enable");
+ return err;
+ }
- /* Enable/disable individual output instead */
- return idtcm_output_enable(channel, enable, perout->index);
+ /* Align output to internal 1 PPS */
+ return _idtcm_settime(channel, &ts, SCSR_TOD_WR_TYPE_SEL_DELTA_PLUS);
}
static int idtcm_get_pll_mode(struct idtcm_channel *channel,
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 net-next 3/7] ptp: ptp_clockmatrix: Remove unused header declarations.
2021-02-17 5:42 [PATCH v3 net-next 0/7] ptp: ptp_clockmatrix: Fix output 1 PPS alignment vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 1/7] ptp: ptp_clockmatrix: Add wait_for_sys_apll_dpll_lock vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 2/7] ptp: ptp_clockmatrix: Add alignment of 1 PPS to idtcm_perout_enable vincent.cheng.xh
@ 2021-02-17 5:42 ` vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 4/7] ptp: ptp_clockmatrix: Clean-up dev_*() messages vincent.cheng.xh
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: vincent.cheng.xh @ 2021-02-17 5:42 UTC (permalink / raw)
To: richardcochran; +Cc: netdev, linux-kernel, Vincent Cheng
From: Vincent Cheng <vincent.cheng.xh@renesas.com>
Removed unused header declarations.
Signed-off-by: Vincent Cheng <vincent.cheng.xh@renesas.com>
---
drivers/ptp/ptp_clockmatrix.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/ptp/ptp_clockmatrix.h b/drivers/ptp/ptp_clockmatrix.h
index 0233236..fb32327 100644
--- a/drivers/ptp/ptp_clockmatrix.h
+++ b/drivers/ptp/ptp_clockmatrix.h
@@ -15,7 +15,6 @@
#define FW_FILENAME "idtcm.bin"
#define MAX_TOD (4)
#define MAX_PLL (8)
-#define MAX_OUTPUT (12)
#define MAX_ABS_WRITE_PHASE_PICOSECONDS (107374182350LL)
@@ -138,7 +137,6 @@ struct idtcm_channel {
enum pll_mode pll_mode;
u8 pll;
u16 output_mask;
- u8 output_phase_adj[MAX_OUTPUT][4];
};
struct idtcm {
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 net-next 4/7] ptp: ptp_clockmatrix: Clean-up dev_*() messages.
2021-02-17 5:42 [PATCH v3 net-next 0/7] ptp: ptp_clockmatrix: Fix output 1 PPS alignment vincent.cheng.xh
` (2 preceding siblings ...)
2021-02-17 5:42 ` [PATCH v3 net-next 3/7] ptp: ptp_clockmatrix: Remove unused header declarations vincent.cheng.xh
@ 2021-02-17 5:42 ` vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 5/7] ptp: ptp_clockmatrix: Coding style - tighten vertical spacing vincent.cheng.xh
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: vincent.cheng.xh @ 2021-02-17 5:42 UTC (permalink / raw)
To: richardcochran; +Cc: netdev, linux-kernel, Vincent Cheng
From: Vincent Cheng <vincent.cheng.xh@renesas.com>
Code clean-up.
* Remove unnecessary \n termination from dev_*() messages.
* Remove 'char *fmt' to define strings to stay within 80 column
limit. Not needed since coding guidelines increased to
100 columns limit.
Keeping format in place allows static code checkers to
validate the arguments.
* Tighten up vertical spacing.
Signed-off-by: Vincent Cheng <vincent.cheng.xh@renesas.com>
---
drivers/ptp/ptp_clockmatrix.c | 122 +++++++++++++++---------------------------
1 file changed, 43 insertions(+), 79 deletions(-)
diff --git a/drivers/ptp/ptp_clockmatrix.c b/drivers/ptp/ptp_clockmatrix.c
index f597e4f..eec0a74 100644
--- a/drivers/ptp/ptp_clockmatrix.c
+++ b/drivers/ptp/ptp_clockmatrix.c
@@ -160,7 +160,6 @@ static int idtcm_xfer_read(struct idtcm *idtcm,
struct i2c_client *client = idtcm->client;
struct i2c_msg msg[2];
int cnt;
- char *fmt = "i2c_transfer failed at %d in %s, at addr: %04X!\n";
msg[0].addr = client->addr;
msg[0].flags = 0;
@@ -176,14 +175,12 @@ static int idtcm_xfer_read(struct idtcm *idtcm,
if (cnt < 0) {
dev_err(&client->dev,
- fmt,
- __LINE__,
- __func__,
- regaddr);
+ "i2c_transfer failed at %d in %s, at addr: %04x!",
+ __LINE__, __func__, regaddr);
return cnt;
} else if (cnt != 2) {
dev_err(&client->dev,
- "i2c_transfer sent only %d of %d messages\n", cnt, 2);
+ "i2c_transfer sent only %d of %d messages", cnt, 2);
return -EIO;
}
@@ -199,7 +196,6 @@ static int idtcm_xfer_write(struct idtcm *idtcm,
/* we add 1 byte for device register */
u8 msg[IDTCM_MAX_WRITE_COUNT + 1];
int cnt;
- char *fmt = "i2c_master_send failed at %d in %s, at addr: %04X!\n";
if (count > IDTCM_MAX_WRITE_COUNT)
return -EINVAL;
@@ -211,10 +207,8 @@ static int idtcm_xfer_write(struct idtcm *idtcm,
if (cnt < 0) {
dev_err(&client->dev,
- fmt,
- __LINE__,
- __func__,
- regaddr);
+ "i2c_master_send failed at %d in %s, at addr: %04x!",
+ __LINE__, __func__, regaddr);
return cnt;
}
@@ -238,7 +232,7 @@ static int idtcm_page_offset(struct idtcm *idtcm, u8 val)
if (err) {
idtcm->page_offset = 0xff;
- dev_err(&idtcm->client->dev, "failed to set page offset\n");
+ dev_err(&idtcm->client->dev, "failed to set page offset");
} else {
idtcm->page_offset = val;
}
@@ -330,7 +324,7 @@ static int wait_for_boot_status_ready(struct idtcm *idtcm)
} while (i);
- dev_warn(&idtcm->client->dev, "%s timed out\n", __func__);
+ dev_warn(&idtcm->client->dev, "%s timed out", __func__);
return -EBUSY;
}
@@ -811,7 +805,7 @@ static int _idtcm_set_dpll_scsr_tod(struct idtcm_channel *channel,
if (++count > 20) {
dev_err(&idtcm->client->dev,
- "Timed out waiting for the write counter\n");
+ "Timed out waiting for the write counter");
return -EIO;
}
}
@@ -877,7 +871,7 @@ static int _idtcm_settime_deprecated(struct idtcm_channel *channel,
if (err) {
dev_err(&idtcm->client->dev,
- "%s: Set HW ToD failed\n", __func__);
+ "%s: Set HW ToD failed", __func__);
return err;
}
@@ -1079,14 +1073,14 @@ static int idtcm_state_machine_reset(struct idtcm *idtcm)
if (status == 0xA0) {
dev_dbg(&idtcm->client->dev,
- "SM_RESET completed in %d ms\n",
- i * 100);
+ "SM_RESET completed in %d ms", i * 100);
break;
}
}
if (!status)
- dev_err(&idtcm->client->dev, "Timed out waiting for CM_RESET to complete\n");
+ dev_err(&idtcm->client->dev,
+ "Timed out waiting for CM_RESET to complete");
}
return err;
@@ -1182,12 +1176,12 @@ static int set_pll_output_mask(struct idtcm *idtcm, u16 addr, u8 val)
static int set_tod_ptp_pll(struct idtcm *idtcm, u8 index, u8 pll)
{
if (index >= MAX_TOD) {
- dev_err(&idtcm->client->dev, "ToD%d not supported\n", index);
+ dev_err(&idtcm->client->dev, "ToD%d not supported", index);
return -EINVAL;
}
if (pll >= MAX_PLL) {
- dev_err(&idtcm->client->dev, "Pll%d not supported\n", pll);
+ dev_err(&idtcm->client->dev, "Pll%d not supported", pll);
return -EINVAL;
}
@@ -1205,8 +1199,7 @@ static int check_and_set_masks(struct idtcm *idtcm,
switch (regaddr) {
case TOD_MASK_ADDR:
if ((val & 0xf0) || !(val & 0x0f)) {
- dev_err(&idtcm->client->dev,
- "Invalid TOD mask 0x%hhx\n", val);
+ dev_err(&idtcm->client->dev, "Invalid TOD mask 0x%02x", val);
err = -EINVAL;
} else {
idtcm->tod_mask = val;
@@ -1237,14 +1230,14 @@ static void display_pll_and_masks(struct idtcm *idtcm)
u8 i;
u8 mask;
- dev_dbg(&idtcm->client->dev, "tod_mask = 0x%02x\n", idtcm->tod_mask);
+ dev_dbg(&idtcm->client->dev, "tod_mask = 0x%02x", idtcm->tod_mask);
for (i = 0; i < MAX_TOD; i++) {
mask = 1 << i;
if (mask & idtcm->tod_mask)
dev_dbg(&idtcm->client->dev,
- "TOD%d pll = %d output_mask = 0x%04x\n",
+ "TOD%d pll = %d output_mask = 0x%04x",
i, idtcm->channel[i].pll,
idtcm->channel[i].output_mask);
}
@@ -1265,19 +1258,16 @@ static int idtcm_load_firmware(struct idtcm *idtcm,
if (firmware) /* module parameter */
snprintf(fname, sizeof(fname), "%s", firmware);
- dev_dbg(&idtcm->client->dev, "requesting firmware '%s'\n", fname);
+ dev_dbg(&idtcm->client->dev, "requesting firmware '%s'", fname);
err = request_firmware(&fw, fname, dev);
-
if (err) {
dev_err(&idtcm->client->dev,
- "Failed at line %d in func %s!\n",
- __LINE__,
- __func__);
+ "Failed at line %d in %s!", __LINE__, __func__);
return err;
}
- dev_dbg(&idtcm->client->dev, "firmware size %zu bytes\n", fw->size);
+ dev_dbg(&idtcm->client->dev, "firmware size %zu bytes", fw->size);
rec = (struct idtcm_fwrc *) fw->data;
@@ -1288,7 +1278,7 @@ static int idtcm_load_firmware(struct idtcm *idtcm,
if (rec->reserved) {
dev_err(&idtcm->client->dev,
- "bad firmware, reserved field non-zero\n");
+ "bad firmware, reserved field non-zero");
err = -EINVAL;
} else {
regaddr = rec->hiaddr << 8;
@@ -1559,10 +1549,8 @@ static int idtcm_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
err = _idtcm_gettime(channel, ts);
if (err)
- dev_err(&idtcm->client->dev,
- "Failed at line %d in func %s!\n",
- __LINE__,
- __func__);
+ dev_err(&idtcm->client->dev, "Failed at line %d in %s!",
+ __LINE__, __func__);
mutex_unlock(&idtcm->reg_lock);
@@ -1583,9 +1571,7 @@ static int idtcm_settime_deprecated(struct ptp_clock_info *ptp,
if (err)
dev_err(&idtcm->client->dev,
- "Failed at line %d in func %s!\n",
- __LINE__,
- __func__);
+ "Failed at line %d in %s!", __LINE__, __func__);
mutex_unlock(&idtcm->reg_lock);
@@ -1606,9 +1592,7 @@ static int idtcm_settime(struct ptp_clock_info *ptp,
if (err)
dev_err(&idtcm->client->dev,
- "Failed at line %d in func %s!\n",
- __LINE__,
- __func__);
+ "Failed at line %d in %s!", __LINE__, __func__);
mutex_unlock(&idtcm->reg_lock);
@@ -1628,9 +1612,7 @@ static int idtcm_adjtime_deprecated(struct ptp_clock_info *ptp, s64 delta)
if (err)
dev_err(&idtcm->client->dev,
- "Failed at line %d in func %s!\n",
- __LINE__,
- __func__);
+ "Failed at line %d in %s!", __LINE__, __func__);
mutex_unlock(&idtcm->reg_lock);
@@ -1650,9 +1632,7 @@ static int idtcm_adjtime(struct ptp_clock_info *ptp, s64 delta)
err = idtcm_do_phase_pull_in(channel, delta, 0);
if (err)
dev_err(&idtcm->client->dev,
- "Failed at line %d in func %s!\n",
- __LINE__,
- __func__);
+ "Failed at line %d in %s!", __LINE__, __func__);
return err;
}
@@ -1670,9 +1650,7 @@ static int idtcm_adjtime(struct ptp_clock_info *ptp, s64 delta)
if (err)
dev_err(&idtcm->client->dev,
- "Failed at line %d in func %s!\n",
- __LINE__,
- __func__);
+ "Failed at line %d in %s!", __LINE__, __func__);
mutex_unlock(&idtcm->reg_lock);
@@ -1694,9 +1672,7 @@ static int idtcm_adjphase(struct ptp_clock_info *ptp, s32 delta)
if (err)
dev_err(&idtcm->client->dev,
- "Failed at line %d in func %s!\n",
- __LINE__,
- __func__);
+ "Failed at line %d in %s!", __LINE__, __func__);
mutex_unlock(&idtcm->reg_lock);
@@ -1718,9 +1694,7 @@ static int idtcm_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
if (err)
dev_err(&idtcm->client->dev,
- "Failed at line %d in func %s!\n",
- __LINE__,
- __func__);
+ "Failed at line %d in %s!", __LINE__, __func__);
mutex_unlock(&idtcm->reg_lock);
@@ -1741,9 +1715,8 @@ static int idtcm_enable(struct ptp_clock_info *ptp,
err = idtcm_perout_enable(channel, false, &rq->perout);
if (err)
dev_err(&channel->idtcm->client->dev,
- "Failed at line %d in func %s!\n",
- __LINE__,
- __func__);
+ "Failed at line %d in %s!",
+ __LINE__, __func__);
return err;
}
@@ -1755,9 +1728,7 @@ static int idtcm_enable(struct ptp_clock_info *ptp,
err = idtcm_perout_enable(channel, true, &rq->perout);
if (err)
dev_err(&channel->idtcm->client->dev,
- "Failed at line %d in func %s!\n",
- __LINE__,
- __func__);
+ "Failed at line %d in %s!", __LINE__, __func__);
return err;
default:
break;
@@ -2025,7 +1996,6 @@ static void idtcm_set_version_info(struct idtcm *idtcm)
u16 product_id;
u8 hw_rev_id;
u8 config_select;
- char *fmt = "%d.%d.%d, Id: 0x%04x HW Rev: %d OTP Config Select: %d\n";
idtcm_read_major_release(idtcm, &major);
idtcm_read_minor_release(idtcm, &minor);
@@ -2044,7 +2014,9 @@ static void idtcm_set_version_info(struct idtcm *idtcm)
else
idtcm->deprecated = 1;
- dev_info(&idtcm->client->dev, fmt, major, minor, hotfix,
+ dev_info(&idtcm->client->dev,
+ "%d.%d.%d, Id: 0x%04x HW Rev: %d OTP Config Select: %d",
+ major, minor, hotfix,
product_id, hw_rev_id, config_select);
}
@@ -2203,9 +2175,7 @@ static int idtcm_enable_channel(struct idtcm *idtcm, u32 index)
err = idtcm_enable_tod_sync(channel);
if (err) {
dev_err(&idtcm->client->dev,
- "Failed at line %d in func %s!\n",
- __LINE__,
- __func__);
+ "Failed at line %d in %s!", __LINE__, __func__);
return err;
}
}
@@ -2214,16 +2184,14 @@ static int idtcm_enable_channel(struct idtcm *idtcm, u32 index)
err = idtcm_get_pll_mode(channel, &channel->pll_mode);
if (err) {
dev_err(&idtcm->client->dev,
- "Error: %s - Unable to read pll mode\n", __func__);
+ "Error: %s - Unable to read pll mode", __func__);
return err;
}
err = idtcm_enable_tod(channel);
if (err) {
dev_err(&idtcm->client->dev,
- "Failed at line %d in func %s!\n",
- __LINE__,
- __func__);
+ "Failed at line %d in %s!", __LINE__, __func__);
return err;
}
@@ -2238,7 +2206,7 @@ static int idtcm_enable_channel(struct idtcm *idtcm, u32 index)
if (!channel->ptp_clock)
return -ENOTSUPP;
- dev_info(&idtcm->client->dev, "PLL%d registered as ptp%d\n",
+ dev_info(&idtcm->client->dev, "PLL%d registered as ptp%d",
index, channel->ptp_clock->index);
return 0;
@@ -2279,7 +2247,6 @@ static int idtcm_probe(struct i2c_client *client,
struct idtcm *idtcm;
int err;
u8 i;
- char *fmt = "Failed at %d in line %s with channel output %d!\n";
/* Unused for now */
(void)id;
@@ -2304,7 +2271,7 @@ static int idtcm_probe(struct i2c_client *client,
if (err)
dev_warn(&idtcm->client->dev,
- "loading firmware failed with %d\n", err);
+ "loading firmware failed with %d", err);
wait_for_chip_ready(idtcm);
@@ -2314,17 +2281,14 @@ static int idtcm_probe(struct i2c_client *client,
err = idtcm_enable_channel(idtcm, i);
if (err) {
dev_err(&idtcm->client->dev,
- fmt,
- __LINE__,
- __func__,
- i);
+ "idtcm_enable_channel %d failed!", i);
break;
}
}
}
} else {
dev_err(&idtcm->client->dev,
- "no PLLs flagged as PHCs, nothing to do\n");
+ "no PLLs flagged as PHCs, nothing to do");
err = -ENODEV;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 net-next 5/7] ptp: ptp_clockmatrix: Coding style - tighten vertical spacing.
2021-02-17 5:42 [PATCH v3 net-next 0/7] ptp: ptp_clockmatrix: Fix output 1 PPS alignment vincent.cheng.xh
` (3 preceding siblings ...)
2021-02-17 5:42 ` [PATCH v3 net-next 4/7] ptp: ptp_clockmatrix: Clean-up dev_*() messages vincent.cheng.xh
@ 2021-02-17 5:42 ` vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 6/7] ptp: ptp_clockmatrix: Simplify code - remove unnecessary `err` variable vincent.cheng.xh
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: vincent.cheng.xh @ 2021-02-17 5:42 UTC (permalink / raw)
To: richardcochran; +Cc: netdev, linux-kernel, Vincent Cheng
From: Vincent Cheng <vincent.cheng.xh@renesas.com>
Code clean-up.
* Remove blank line between variable declarations.
* Remove blank line between:
err = blah(...)
if (err)
...
* Remove unnecessary blank line before/after loop constructs.
Signed-off-by: Vincent Cheng <vincent.cheng.xh@renesas.com>
---
drivers/ptp/ptp_clockmatrix.c | 90 ++++++-------------------------------------
1 file changed, 11 insertions(+), 79 deletions(-)
diff --git a/drivers/ptp/ptp_clockmatrix.c b/drivers/ptp/ptp_clockmatrix.c
index eec0a74..241bff0 100644
--- a/drivers/ptp/ptp_clockmatrix.c
+++ b/drivers/ptp/ptp_clockmatrix.c
@@ -229,7 +229,6 @@ static int idtcm_page_offset(struct idtcm *idtcm, u8 val)
buf[3] = 0x20;
err = idtcm_xfer_write(idtcm, PAGE_ADDR, buf, sizeof(buf));
-
if (err) {
idtcm->page_offset = 0xff;
dev_err(&idtcm->client->dev, "failed to set page offset");
@@ -254,7 +253,6 @@ static int _idtcm_rdwr(struct idtcm *idtcm,
lo = regaddr & 0xff;
err = idtcm_page_offset(idtcm, hi);
-
if (err)
return err;
@@ -312,7 +310,6 @@ static int wait_for_boot_status_ready(struct idtcm *idtcm)
do {
err = read_boot_status(idtcm, &status);
-
if (err)
return err;
@@ -415,14 +412,12 @@ static int _idtcm_gettime(struct idtcm_channel *channel,
/* wait trigger to be 0 */
while (trigger & TOD_READ_TRIGGER_MASK) {
-
if (idtcm->calculate_overhead_flag)
idtcm->start_time = ktime_get_raw();
err = idtcm_read(idtcm, channel->tod_read_primary,
TOD_READ_PRIMARY_CMD, &trigger,
sizeof(trigger));
-
if (err)
return err;
@@ -432,7 +427,6 @@ static int _idtcm_gettime(struct idtcm_channel *channel,
err = idtcm_read(idtcm, channel->tod_read_primary,
TOD_READ_PRIMARY, buf, sizeof(buf));
-
if (err)
return err;
@@ -595,7 +589,6 @@ static int sync_source_dpll_tod_pps(u16 tod_addr, u8 *sync_src)
static int idtcm_sync_pps_output(struct idtcm_channel *channel)
{
struct idtcm *idtcm = channel->idtcm;
-
u8 pll;
u8 sync_src;
u8 qn;
@@ -604,7 +597,6 @@ static int idtcm_sync_pps_output(struct idtcm_channel *channel)
u8 out8_mux = 0;
u8 out11_mux = 0;
u8 temp;
-
u16 output_mask = channel->output_mask;
err = sync_source_dpll_tod_pps(channel->tod_n, &sync_src);
@@ -681,7 +673,6 @@ static int _idtcm_set_dpll_hw_tod(struct idtcm_channel *channel,
enum hw_tod_write_trig_sel wr_trig)
{
struct idtcm *idtcm = channel->idtcm;
-
u8 buf[TOD_BYTE_COUNT];
u8 cmd;
int err;
@@ -691,7 +682,6 @@ static int _idtcm_set_dpll_hw_tod(struct idtcm_channel *channel,
/* Configure HW TOD write trigger. */
err = idtcm_read(idtcm, channel->hw_dpll_n, HW_DPLL_TOD_CTRL_1,
&cmd, sizeof(cmd));
-
if (err)
return err;
@@ -700,20 +690,16 @@ static int _idtcm_set_dpll_hw_tod(struct idtcm_channel *channel,
err = idtcm_write(idtcm, channel->hw_dpll_n, HW_DPLL_TOD_CTRL_1,
&cmd, sizeof(cmd));
-
if (err)
return err;
if (wr_trig != HW_TOD_WR_TRIG_SEL_MSB) {
-
err = timespec_to_char_array(&local_ts, buf, sizeof(buf));
-
if (err)
return err;
err = idtcm_write(idtcm, channel->hw_dpll_n,
HW_DPLL_TOD_OVR__0, buf, sizeof(buf));
-
if (err)
return err;
}
@@ -725,7 +711,6 @@ static int _idtcm_set_dpll_hw_tod(struct idtcm_channel *channel,
&cmd, sizeof(cmd));
if (wr_trig == HW_TOD_WR_TRIG_SEL_MSB) {
-
if (idtcm->calculate_overhead_flag) {
/* Assumption: I2C @ 400KHz */
ktime_t diff = ktime_sub(ktime_get_raw(),
@@ -740,7 +725,6 @@ static int _idtcm_set_dpll_hw_tod(struct idtcm_channel *channel,
}
err = timespec_to_char_array(&local_ts, buf, sizeof(buf));
-
if (err)
return err;
@@ -764,7 +748,6 @@ static int _idtcm_set_dpll_scsr_tod(struct idtcm_channel *channel,
timespec64_add_ns(&local_ts, SETTIME_CORRECTION);
err = timespec_to_char_array(&local_ts, buf, sizeof(buf));
-
if (err)
return err;
@@ -868,7 +851,6 @@ static int _idtcm_settime_deprecated(struct idtcm_channel *channel,
int err;
err = _idtcm_set_dpll_hw_tod(channel, ts, HW_TOD_WR_TRIG_SEL_MSB);
-
if (err) {
dev_err(&idtcm->client->dev,
"%s: Set HW ToD failed", __func__);
@@ -893,7 +875,6 @@ static int idtcm_set_phase_pull_in_offset(struct idtcm_channel *channel,
int err;
int i;
struct idtcm *idtcm = channel->idtcm;
-
u8 buf[4];
for (i = 0; i < 4; i++) {
@@ -913,7 +894,6 @@ static int idtcm_set_phase_pull_in_slope_limit(struct idtcm_channel *channel,
int err;
u8 i;
struct idtcm *idtcm = channel->idtcm;
-
u8 buf[3];
if (max_ffo_ppb & 0xff000000)
@@ -934,12 +914,10 @@ static int idtcm_start_phase_pull_in(struct idtcm_channel *channel)
{
int err;
struct idtcm *idtcm = channel->idtcm;
-
u8 buf;
err = idtcm_read(idtcm, channel->dpll_phase_pull_in, PULL_IN_CTRL,
&buf, sizeof(buf));
-
if (err)
return err;
@@ -961,12 +939,10 @@ static int idtcm_do_phase_pull_in(struct idtcm_channel *channel,
int err;
err = idtcm_set_phase_pull_in_offset(channel, -offset_ns);
-
if (err)
return err;
err = idtcm_set_phase_pull_in_slope_limit(channel, max_ffo_ppb);
-
if (err)
return err;
@@ -982,7 +958,6 @@ static int set_tod_write_overhead(struct idtcm_channel *channel)
s64 lowest_ns = 0;
int err;
u8 i;
-
ktime_t start;
ktime_t stop;
ktime_t diff;
@@ -994,12 +969,10 @@ static int set_tod_write_overhead(struct idtcm_channel *channel)
buf, sizeof(buf));
for (i = 0; i < TOD_WRITE_OVERHEAD_COUNT_MAX; i++) {
-
start = ktime_get_raw();
err = idtcm_write(idtcm, channel->hw_dpll_n,
HW_DPLL_TOD_OVR__0, buf, sizeof(buf));
-
if (err)
return err;
@@ -1035,12 +1008,10 @@ static int _idtcm_adjtime_deprecated(struct idtcm_channel *channel, s64 delta)
idtcm->calculate_overhead_flag = 1;
err = set_tod_write_overhead(channel);
-
if (err)
return err;
err = _idtcm_gettime(channel, &ts);
-
if (err)
return err;
@@ -1275,7 +1246,6 @@ static int idtcm_load_firmware(struct idtcm *idtcm,
idtcm_state_machine_reset(idtcm);
for (len = fw->size; len > 0; len -= sizeof(*rec)) {
-
if (rec->reserved) {
dev_err(&idtcm->client->dev,
"bad firmware, reserved field non-zero");
@@ -1336,7 +1306,6 @@ static int idtcm_output_enable(struct idtcm_channel *channel,
}
err = idtcm_read(idtcm, (u16)base, OUT_CTRL_1, &val, sizeof(val));
-
if (err)
return err;
@@ -1359,11 +1328,8 @@ static int idtcm_output_mask_enable(struct idtcm_channel *channel,
outn = 0;
while (mask) {
-
if (mask & 0x1) {
-
err = idtcm_output_enable(channel, enable, outn);
-
if (err)
return err;
}
@@ -1453,7 +1419,6 @@ static int idtcm_set_pll_mode(struct idtcm_channel *channel,
static int _idtcm_adjphase(struct idtcm_channel *channel, s32 delta_ns)
{
struct idtcm *idtcm = channel->idtcm;
-
int err;
u8 i;
u8 buf[4] = {0};
@@ -1461,9 +1426,7 @@ static int _idtcm_adjphase(struct idtcm_channel *channel, s32 delta_ns)
s64 offset_ps;
if (channel->pll_mode != PLL_MODE_WRITE_PHASE) {
-
err = idtcm_set_pll_mode(channel, PLL_MODE_WRITE_PHASE);
-
if (err)
return err;
}
@@ -1539,15 +1502,13 @@ static int _idtcm_adjfine(struct idtcm_channel *channel, long scaled_ppm)
static int idtcm_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
{
- struct idtcm_channel *channel =
- container_of(ptp, struct idtcm_channel, caps);
+ struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps);
struct idtcm *idtcm = channel->idtcm;
int err;
mutex_lock(&idtcm->reg_lock);
err = _idtcm_gettime(channel, ts);
-
if (err)
dev_err(&idtcm->client->dev, "Failed at line %d in %s!",
__LINE__, __func__);
@@ -1560,15 +1521,13 @@ static int idtcm_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
static int idtcm_settime_deprecated(struct ptp_clock_info *ptp,
const struct timespec64 *ts)
{
- struct idtcm_channel *channel =
- container_of(ptp, struct idtcm_channel, caps);
+ struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps);
struct idtcm *idtcm = channel->idtcm;
int err;
mutex_lock(&idtcm->reg_lock);
err = _idtcm_settime_deprecated(channel, ts);
-
if (err)
dev_err(&idtcm->client->dev,
"Failed at line %d in %s!", __LINE__, __func__);
@@ -1581,15 +1540,13 @@ static int idtcm_settime_deprecated(struct ptp_clock_info *ptp,
static int idtcm_settime(struct ptp_clock_info *ptp,
const struct timespec64 *ts)
{
- struct idtcm_channel *channel =
- container_of(ptp, struct idtcm_channel, caps);
+ struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps);
struct idtcm *idtcm = channel->idtcm;
int err;
mutex_lock(&idtcm->reg_lock);
err = _idtcm_settime(channel, ts, SCSR_TOD_WR_TYPE_SEL_ABSOLUTE);
-
if (err)
dev_err(&idtcm->client->dev,
"Failed at line %d in %s!", __LINE__, __func__);
@@ -1601,15 +1558,13 @@ static int idtcm_settime(struct ptp_clock_info *ptp,
static int idtcm_adjtime_deprecated(struct ptp_clock_info *ptp, s64 delta)
{
- struct idtcm_channel *channel =
- container_of(ptp, struct idtcm_channel, caps);
+ struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps);
struct idtcm *idtcm = channel->idtcm;
int err;
mutex_lock(&idtcm->reg_lock);
err = _idtcm_adjtime_deprecated(channel, delta);
-
if (err)
dev_err(&idtcm->client->dev,
"Failed at line %d in %s!", __LINE__, __func__);
@@ -1621,8 +1576,7 @@ static int idtcm_adjtime_deprecated(struct ptp_clock_info *ptp, s64 delta)
static int idtcm_adjtime(struct ptp_clock_info *ptp, s64 delta)
{
- struct idtcm_channel *channel =
- container_of(ptp, struct idtcm_channel, caps);
+ struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps);
struct idtcm *idtcm = channel->idtcm;
struct timespec64 ts;
enum scsr_tod_write_type_sel type;
@@ -1647,7 +1601,6 @@ static int idtcm_adjtime(struct ptp_clock_info *ptp, s64 delta)
mutex_lock(&idtcm->reg_lock);
err = _idtcm_settime(channel, &ts, type);
-
if (err)
dev_err(&idtcm->client->dev,
"Failed at line %d in %s!", __LINE__, __func__);
@@ -1659,17 +1612,13 @@ static int idtcm_adjtime(struct ptp_clock_info *ptp, s64 delta)
static int idtcm_adjphase(struct ptp_clock_info *ptp, s32 delta)
{
- struct idtcm_channel *channel =
- container_of(ptp, struct idtcm_channel, caps);
-
+ struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps);
struct idtcm *idtcm = channel->idtcm;
-
int err;
mutex_lock(&idtcm->reg_lock);
err = _idtcm_adjphase(channel, delta);
-
if (err)
dev_err(&idtcm->client->dev,
"Failed at line %d in %s!", __LINE__, __func__);
@@ -1681,17 +1630,13 @@ static int idtcm_adjphase(struct ptp_clock_info *ptp, s32 delta)
static int idtcm_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
{
- struct idtcm_channel *channel =
- container_of(ptp, struct idtcm_channel, caps);
-
+ struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps);
struct idtcm *idtcm = channel->idtcm;
-
int err;
mutex_lock(&idtcm->reg_lock);
err = _idtcm_adjfine(channel, scaled_ppm);
-
if (err)
dev_err(&idtcm->client->dev,
"Failed at line %d in %s!", __LINE__, __func__);
@@ -1705,9 +1650,7 @@ static int idtcm_enable(struct ptp_clock_info *ptp,
struct ptp_clock_request *rq, int on)
{
int err;
-
- struct idtcm_channel *channel =
- container_of(ptp, struct idtcm_channel, caps);
+ struct idtcm_channel *channel = container_of(ptp, struct idtcm_channel, caps);
switch (rq->type) {
case PTP_CLK_REQ_PEROUT:
@@ -1813,28 +1756,24 @@ static int _enable_pll_tod_sync(struct idtcm *idtcm,
*/
if (out0) {
err = idtcm_read(idtcm, out0, OUT_CTRL_1, &val, sizeof(val));
-
if (err)
return err;
val &= ~OUT_SYNC_DISABLE;
err = idtcm_write(idtcm, out0, OUT_CTRL_1, &val, sizeof(val));
-
if (err)
return err;
}
if (out1) {
err = idtcm_read(idtcm, out1, OUT_CTRL_1, &val, sizeof(val));
-
if (err)
return err;
val &= ~OUT_SYNC_DISABLE;
err = idtcm_write(idtcm, out1, OUT_CTRL_1, &val, sizeof(val));
-
if (err)
return err;
}
@@ -1854,7 +1793,6 @@ static int _enable_pll_tod_sync(struct idtcm *idtcm,
static int idtcm_enable_tod_sync(struct idtcm_channel *channel)
{
struct idtcm *idtcm = channel->idtcm;
-
u8 pll;
u8 sync_src;
u8 qn;
@@ -1896,8 +1834,7 @@ static int idtcm_enable_tod_sync(struct idtcm_channel *channel)
return -EINVAL;
}
- err = idtcm_read(idtcm, 0, HW_Q8_CTRL_SPARE,
- &temp, sizeof(temp));
+ err = idtcm_read(idtcm, 0, HW_Q8_CTRL_SPARE, &temp, sizeof(temp));
if (err)
return err;
@@ -1905,8 +1842,7 @@ static int idtcm_enable_tod_sync(struct idtcm_channel *channel)
Q9_TO_Q8_FANOUT_AND_CLOCK_SYNC_ENABLE_MASK)
out8_mux = 1;
- err = idtcm_read(idtcm, 0, HW_Q11_CTRL_SPARE,
- &temp, sizeof(temp));
+ err = idtcm_read(idtcm, 0, HW_Q11_CTRL_SPARE, &temp, sizeof(temp));
if (err)
return err;
@@ -1953,7 +1889,6 @@ static int idtcm_enable_tod_sync(struct idtcm_channel *channel)
if ((qn != 0) || (qn_plus_1 != 0))
err = _enable_pll_tod_sync(idtcm, pll, sync_src, qn,
qn_plus_1);
-
if (err)
return err;
}
@@ -2218,7 +2153,6 @@ static void ptp_clock_unregister_all(struct idtcm *idtcm)
struct idtcm_channel *channel;
for (i = 0; i < MAX_TOD; i++) {
-
channel = &idtcm->channel[i];
if (channel->ptp_clock)
@@ -2268,10 +2202,8 @@ static int idtcm_probe(struct i2c_client *client,
idtcm_set_version_info(idtcm);
err = idtcm_load_firmware(idtcm, &client->dev);
-
if (err)
- dev_warn(&idtcm->client->dev,
- "loading firmware failed with %d", err);
+ dev_warn(&idtcm->client->dev, "loading firmware failed with %d", err);
wait_for_chip_ready(idtcm);
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 net-next 6/7] ptp: ptp_clockmatrix: Simplify code - remove unnecessary `err` variable.
2021-02-17 5:42 [PATCH v3 net-next 0/7] ptp: ptp_clockmatrix: Fix output 1 PPS alignment vincent.cheng.xh
` (4 preceding siblings ...)
2021-02-17 5:42 ` [PATCH v3 net-next 5/7] ptp: ptp_clockmatrix: Coding style - tighten vertical spacing vincent.cheng.xh
@ 2021-02-17 5:42 ` vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 7/7] ptp: ptp_clockmatrix: clean-up - parenthesis around a == b are unnecessary vincent.cheng.xh
2021-02-17 22:00 ` [PATCH v3 net-next 0/7] ptp: ptp_clockmatrix: Fix output 1 PPS alignment patchwork-bot+netdevbpf
7 siblings, 0 replies; 9+ messages in thread
From: vincent.cheng.xh @ 2021-02-17 5:42 UTC (permalink / raw)
To: richardcochran; +Cc: netdev, linux-kernel, Vincent Cheng
From: Vincent Cheng <vincent.cheng.xh@renesas.com>
Code clean-up.
Signed-off-by: Vincent Cheng <vincent.cheng.xh@renesas.com>
---
drivers/ptp/ptp_clockmatrix.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/ptp/ptp_clockmatrix.c b/drivers/ptp/ptp_clockmatrix.c
index 241bff0..dc42c36 100644
--- a/drivers/ptp/ptp_clockmatrix.c
+++ b/drivers/ptp/ptp_clockmatrix.c
@@ -282,12 +282,9 @@ static int idtcm_write(struct idtcm *idtcm,
static int clear_boot_status(struct idtcm *idtcm)
{
- int err;
u8 buf[4] = {0};
- err = idtcm_write(idtcm, GENERAL_STATUS, BOOT_STATUS, buf, sizeof(buf));
-
- return err;
+ return idtcm_write(idtcm, GENERAL_STATUS, BOOT_STATUS, buf, sizeof(buf));
}
static int read_boot_status(struct idtcm *idtcm, u32 *status)
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 net-next 7/7] ptp: ptp_clockmatrix: clean-up - parenthesis around a == b are unnecessary
2021-02-17 5:42 [PATCH v3 net-next 0/7] ptp: ptp_clockmatrix: Fix output 1 PPS alignment vincent.cheng.xh
` (5 preceding siblings ...)
2021-02-17 5:42 ` [PATCH v3 net-next 6/7] ptp: ptp_clockmatrix: Simplify code - remove unnecessary `err` variable vincent.cheng.xh
@ 2021-02-17 5:42 ` vincent.cheng.xh
2021-02-17 22:00 ` [PATCH v3 net-next 0/7] ptp: ptp_clockmatrix: Fix output 1 PPS alignment patchwork-bot+netdevbpf
7 siblings, 0 replies; 9+ messages in thread
From: vincent.cheng.xh @ 2021-02-17 5:42 UTC (permalink / raw)
To: richardcochran; +Cc: netdev, linux-kernel, Vincent Cheng
From: Vincent Cheng <vincent.cheng.xh@renesas.com>
Code clean-up.
Signed-off-by: Vincent Cheng <vincent.cheng.xh@renesas.com>
---
drivers/ptp/ptp_clockmatrix.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/ptp/ptp_clockmatrix.c b/drivers/ptp/ptp_clockmatrix.c
index dc42c36..75463c2 100644
--- a/drivers/ptp/ptp_clockmatrix.c
+++ b/drivers/ptp/ptp_clockmatrix.c
@@ -444,7 +444,7 @@ static int _sync_pll_output(struct idtcm *idtcm,
u16 sync_ctrl1;
u8 temp;
- if ((qn == 0) && (qn_plus_1 == 0))
+ if (qn == 0 && qn_plus_1 == 0)
return 0;
switch (pll) {
@@ -509,7 +509,7 @@ static int _sync_pll_output(struct idtcm *idtcm,
return err;
/* PLL5 can have OUT8 as second additional output. */
- if ((pll == 5) && (qn_plus_1 != 0)) {
+ if (pll == 5 && qn_plus_1 != 0) {
err = idtcm_read(idtcm, 0, HW_Q8_CTRL_SPARE,
&temp, sizeof(temp));
if (err)
@@ -531,7 +531,7 @@ static int _sync_pll_output(struct idtcm *idtcm,
}
/* PLL6 can have OUT11 as second additional output. */
- if ((pll == 6) && (qn_plus_1 != 0)) {
+ if (pll == 6 && qn_plus_1 != 0) {
err = idtcm_read(idtcm, 0, HW_Q11_CTRL_SPARE,
&temp, sizeof(temp));
if (err)
@@ -654,7 +654,7 @@ static int idtcm_sync_pps_output(struct idtcm_channel *channel)
}
}
- if ((qn != 0) || (qn_plus_1 != 0))
+ if (qn != 0 || qn_plus_1 != 0)
err = _sync_pll_output(idtcm, pll, sync_src, qn,
qn_plus_1);
@@ -1263,13 +1263,11 @@ static int idtcm_load_firmware(struct idtcm *idtcm,
err = 0;
/* Top (status registers) and bottom are read-only */
- if ((regaddr < GPIO_USER_CONTROL)
- || (regaddr >= SCRATCH))
+ if (regaddr < GPIO_USER_CONTROL || regaddr >= SCRATCH)
continue;
/* Page size 128, last 4 bytes of page skipped */
- if (((loaddr > 0x7b) && (loaddr <= 0x7f))
- || loaddr > 0xfb)
+ if ((loaddr > 0x7b && loaddr <= 0x7f) || loaddr > 0xfb)
continue;
err = idtcm_write(idtcm, regaddr, 0, &val, sizeof(val));
@@ -1688,7 +1686,7 @@ static int _enable_pll_tod_sync(struct idtcm *idtcm,
u16 dpll;
u16 out0 = 0, out1 = 0;
- if ((qn == 0) && (qn_plus_1 == 0))
+ if (qn == 0 && qn_plus_1 == 0)
return 0;
switch (pll) {
@@ -1883,7 +1881,7 @@ static int idtcm_enable_tod_sync(struct idtcm_channel *channel)
}
}
- if ((qn != 0) || (qn_plus_1 != 0))
+ if (qn != 0 || qn_plus_1 != 0)
err = _enable_pll_tod_sync(idtcm, pll, sync_src, qn,
qn_plus_1);
if (err)
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 net-next 0/7] ptp: ptp_clockmatrix: Fix output 1 PPS alignment.
2021-02-17 5:42 [PATCH v3 net-next 0/7] ptp: ptp_clockmatrix: Fix output 1 PPS alignment vincent.cheng.xh
` (6 preceding siblings ...)
2021-02-17 5:42 ` [PATCH v3 net-next 7/7] ptp: ptp_clockmatrix: clean-up - parenthesis around a == b are unnecessary vincent.cheng.xh
@ 2021-02-17 22:00 ` patchwork-bot+netdevbpf
7 siblings, 0 replies; 9+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-02-17 22:00 UTC (permalink / raw)
To: Vincent Cheng; +Cc: richardcochran, netdev, linux-kernel
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
On Wed, 17 Feb 2021 00:42:11 -0500 you wrote:
> From: Vincent Cheng <vincent.cheng.xh@renesas.com>
>
> This series fixes a race condition that may result in the output clock
> not aligned to internal 1 PPS clock.
>
> Part of device initialization is to align the rising edge of output
> clocks to the internal rising edge of the 1 PPS clock. If the system
> APLL and DPLL are not locked when this alignment occurs, the alignment
> fails and a fixed offset between the internal 1 PPS clock and the
> output clock occurs.
>
> [...]
Here is the summary with links:
- [v3,net-next,1/7] ptp: ptp_clockmatrix: Add wait_for_sys_apll_dpll_lock.
https://git.kernel.org/netdev/net-next/c/797d3186544f
- [v3,net-next,2/7] ptp: ptp_clockmatrix: Add alignment of 1 PPS to idtcm_perout_enable.
https://git.kernel.org/netdev/net-next/c/e8b4d8b542b1
- [v3,net-next,3/7] ptp: ptp_clockmatrix: Remove unused header declarations.
https://git.kernel.org/netdev/net-next/c/10c270cf25bd
- [v3,net-next,4/7] ptp: ptp_clockmatrix: Clean-up dev_*() messages.
https://git.kernel.org/netdev/net-next/c/1c49d3e94778
- [v3,net-next,5/7] ptp: ptp_clockmatrix: Coding style - tighten vertical spacing.
https://git.kernel.org/netdev/net-next/c/fcfd37573a09
- [v3,net-next,6/7] ptp: ptp_clockmatrix: Simplify code - remove unnecessary `err` variable.
https://git.kernel.org/netdev/net-next/c/fde3b3a7069e
- [v3,net-next,7/7] ptp: ptp_clockmatrix: clean-up - parenthesis around a == b are unnecessary
https://git.kernel.org/netdev/net-next/c/77fdb168a3e2
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-02-17 22:01 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-17 5:42 [PATCH v3 net-next 0/7] ptp: ptp_clockmatrix: Fix output 1 PPS alignment vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 1/7] ptp: ptp_clockmatrix: Add wait_for_sys_apll_dpll_lock vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 2/7] ptp: ptp_clockmatrix: Add alignment of 1 PPS to idtcm_perout_enable vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 3/7] ptp: ptp_clockmatrix: Remove unused header declarations vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 4/7] ptp: ptp_clockmatrix: Clean-up dev_*() messages vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 5/7] ptp: ptp_clockmatrix: Coding style - tighten vertical spacing vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 6/7] ptp: ptp_clockmatrix: Simplify code - remove unnecessary `err` variable vincent.cheng.xh
2021-02-17 5:42 ` [PATCH v3 net-next 7/7] ptp: ptp_clockmatrix: clean-up - parenthesis around a == b are unnecessary vincent.cheng.xh
2021-02-17 22:00 ` [PATCH v3 net-next 0/7] ptp: ptp_clockmatrix: Fix output 1 PPS alignment patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).