From patchwork Wed Feb 17 05:42:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Cheng X-Patchwork-Id: 384263 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1937CC433DB for ; Wed, 17 Feb 2021 06:02:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C16596186A for ; Wed, 17 Feb 2021 06:02:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231546AbhBQGCj (ORCPT ); Wed, 17 Feb 2021 01:02:39 -0500 Received: from pbmsgap01.intersil.com ([192.157.179.201]:32790 "EHLO pbmsgap01.intersil.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231516AbhBQGCd (ORCPT ); Wed, 17 Feb 2021 01:02:33 -0500 X-Greylist: delayed 1123 seconds by postgrey-1.27 at vger.kernel.org; Wed, 17 Feb 2021 01:02:06 EST Received: from pps.filterd (pbmsgap01.intersil.com [127.0.0.1]) by pbmsgap01.intersil.com (8.16.0.42/8.16.0.42) with SMTP id 11H5gMDm009524; Wed, 17 Feb 2021 00:42:45 -0500 Received: from pbmxdp01.intersil.corp (pbmxdp01.pb.intersil.com [132.158.200.222]) by pbmsgap01.intersil.com with ESMTP id 36pb661ge1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 00:42:45 -0500 Received: from pbmxdp02.intersil.corp (132.158.200.223) by pbmxdp01.intersil.corp (132.158.200.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1979.3; Wed, 17 Feb 2021 00:42:44 -0500 Received: from localhost (132.158.202.108) by pbmxdp02.intersil.corp (132.158.200.223) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 17 Feb 2021 00:42:44 -0500 From: To: CC: , , Vincent Cheng Subject: [PATCH v3 net-next 1/7] ptp: ptp_clockmatrix: Add wait_for_sys_apll_dpll_lock. Date: Wed, 17 Feb 2021 00:42:12 -0500 Message-ID: <1613540538-23792-2-git-send-email-vincent.cheng.xh@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1613540538-23792-1-git-send-email-vincent.cheng.xh@renesas.com> References: <1613540538-23792-1-git-send-email-vincent.cheng.xh@renesas.com> X-TM-AS-MML: disable MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-02-17_02:2021-02-16,2021-02-17 signatures=0 X-Proofpoint-Spam-Details: rule=junk_notspam policy=junk score=0 bulkscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102170042 X-Proofpoint-Spam-Reason: mlx Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vincent Cheng 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 Acked-by: Richard Cochran --- 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 { From patchwork Wed Feb 17 05:42:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Cheng X-Patchwork-Id: 384262 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28B4BC433DB for ; Wed, 17 Feb 2021 06:07:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA16E64E2B for ; Wed, 17 Feb 2021 06:07:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231616AbhBQGHV (ORCPT ); Wed, 17 Feb 2021 01:07:21 -0500 Received: from pbmsgap02.intersil.com ([192.157.179.202]:54226 "EHLO pbmsgap02.intersil.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231596AbhBQGGu (ORCPT ); Wed, 17 Feb 2021 01:06:50 -0500 Received: from pps.filterd (pbmsgap02.intersil.com [127.0.0.1]) by pbmsgap02.intersil.com (8.16.0.42/8.16.0.42) with SMTP id 11H5ggsD032612; Wed, 17 Feb 2021 00:42:42 -0500 Received: from pbmxdp03.intersil.corp (pbmxdp03.pb.intersil.com [132.158.200.224]) by pbmsgap02.intersil.com with ESMTP id 36p9tmscnc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 00:42:42 -0500 Received: from pbmxdp03.intersil.corp (132.158.200.224) by pbmxdp03.intersil.corp (132.158.200.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1979.3; Wed, 17 Feb 2021 00:42:40 -0500 Received: from localhost (132.158.202.108) by pbmxdp03.intersil.corp (132.158.200.224) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 17 Feb 2021 00:42:40 -0500 From: To: CC: , , Vincent Cheng Subject: [PATCH v3 net-next 4/7] ptp: ptp_clockmatrix: Clean-up dev_*() messages. Date: Wed, 17 Feb 2021 00:42:15 -0500 Message-ID: <1613540538-23792-5-git-send-email-vincent.cheng.xh@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1613540538-23792-1-git-send-email-vincent.cheng.xh@renesas.com> References: <1613540538-23792-1-git-send-email-vincent.cheng.xh@renesas.com> X-TM-AS-MML: disable MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-02-17_02:2021-02-16,2021-02-17 signatures=0 X-Proofpoint-Spam-Details: rule=junk_notspam policy=junk score=0 malwarescore=0 mlxlogscore=999 spamscore=0 phishscore=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102170042 X-Proofpoint-Spam-Reason: mlx Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vincent Cheng 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 --- 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; } From patchwork Wed Feb 17 05:42:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Cheng X-Patchwork-Id: 384261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69128C433E0 for ; Wed, 17 Feb 2021 06:13:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B9A864E28 for ; Wed, 17 Feb 2021 06:13:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231610AbhBQGM4 (ORCPT ); Wed, 17 Feb 2021 01:12:56 -0500 Received: from pbmsgap02.intersil.com ([192.157.179.202]:54498 "EHLO pbmsgap02.intersil.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231577AbhBQGMw (ORCPT ); Wed, 17 Feb 2021 01:12:52 -0500 Received: from pps.filterd (pbmsgap02.intersil.com [127.0.0.1]) by pbmsgap02.intersil.com (8.16.0.42/8.16.0.42) with SMTP id 11H5ggsE032612; Wed, 17 Feb 2021 00:42:44 -0500 Received: from pbmxdp03.intersil.corp (pbmxdp03.pb.intersil.com [132.158.200.224]) by pbmsgap02.intersil.com with ESMTP id 36p9tmscnd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 00:42:44 -0500 Received: from pbmxdp02.intersil.corp (132.158.200.223) by pbmxdp03.intersil.corp (132.158.200.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1979.3; Wed, 17 Feb 2021 00:42:42 -0500 Received: from localhost (132.158.202.108) by pbmxdp02.intersil.corp (132.158.200.223) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 17 Feb 2021 00:42:42 -0500 From: To: CC: , , Vincent Cheng Subject: [PATCH v3 net-next 6/7] ptp: ptp_clockmatrix: Simplify code - remove unnecessary `err` variable. Date: Wed, 17 Feb 2021 00:42:17 -0500 Message-ID: <1613540538-23792-7-git-send-email-vincent.cheng.xh@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1613540538-23792-1-git-send-email-vincent.cheng.xh@renesas.com> References: <1613540538-23792-1-git-send-email-vincent.cheng.xh@renesas.com> X-TM-AS-MML: disable MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-02-17_02:2021-02-16,2021-02-17 signatures=0 X-Proofpoint-Spam-Details: rule=junk_notspam policy=junk score=0 malwarescore=0 mlxlogscore=999 spamscore=0 phishscore=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102170042 X-Proofpoint-Spam-Reason: mlx Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vincent Cheng Code clean-up. Signed-off-by: Vincent Cheng --- 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) From patchwork Wed Feb 17 05:42:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Cheng X-Patchwork-Id: 384264 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0336EC433DB for ; Wed, 17 Feb 2021 06:02:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC9B26186A for ; Wed, 17 Feb 2021 06:02:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231451AbhBQGCL (ORCPT ); Wed, 17 Feb 2021 01:02:11 -0500 Received: from pbmsgap01.intersil.com ([192.157.179.201]:32790 "EHLO pbmsgap01.intersil.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbhBQGCH (ORCPT ); Wed, 17 Feb 2021 01:02:07 -0500 X-Greylist: delayed 1123 seconds by postgrey-1.27 at vger.kernel.org; Wed, 17 Feb 2021 01:02:06 EST Received: from pps.filterd (pbmsgap01.intersil.com [127.0.0.1]) by pbmsgap01.intersil.com (8.16.0.42/8.16.0.42) with SMTP id 11H5gMDl009524; Wed, 17 Feb 2021 00:42:40 -0500 Received: from pbmxdp01.intersil.corp (pbmxdp01.pb.intersil.com [132.158.200.222]) by pbmsgap01.intersil.com with ESMTP id 36pb661ge0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 17 Feb 2021 00:42:40 -0500 Received: from pbmxdp03.intersil.corp (132.158.200.224) by pbmxdp01.intersil.corp (132.158.200.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1979.3; Wed, 17 Feb 2021 00:42:39 -0500 Received: from localhost (132.158.202.108) by pbmxdp03.intersil.corp (132.158.200.224) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 17 Feb 2021 00:42:38 -0500 From: To: CC: , , Vincent Cheng Subject: [PATCH v3 net-next 7/7] ptp: ptp_clockmatrix: clean-up - parenthesis around a == b are unnecessary Date: Wed, 17 Feb 2021 00:42:18 -0500 Message-ID: <1613540538-23792-8-git-send-email-vincent.cheng.xh@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1613540538-23792-1-git-send-email-vincent.cheng.xh@renesas.com> References: <1613540538-23792-1-git-send-email-vincent.cheng.xh@renesas.com> X-TM-AS-MML: disable MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-02-17_02:2021-02-16,2021-02-17 signatures=0 X-Proofpoint-Spam-Details: rule=junk_notspam policy=junk score=0 bulkscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102170042 X-Proofpoint-Spam-Reason: mlx Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vincent Cheng Code clean-up. Signed-off-by: Vincent Cheng --- 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)