Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752173AbdFMIT4 (ORCPT ); Tue, 13 Jun 2017 04:19:56 -0400 Received: from webbox1416.server-home.net ([77.236.96.61]:55748 "EHLO webbox1416.server-home.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751834AbdFMITy (ORCPT ); Tue, 13 Jun 2017 04:19:54 -0400 From: Alexander Stein To: linux-kernel@vger.kernel.org Cc: Dong Aisheng , linux-arm-kernel@lists.infradead.org, daniel.lezcano@linaro.org, tglx@linutronix.de, shawnguo@kernel.org, ping.bai@nxp.com, anson.huang@nxp.com, dongas86@gmail.com, kernel@pengutronix.de, arnd@arndb.de, Anson Huang Subject: Re: [PATCH V2 2/2] timer: imx-tpm: add imx tpm timer support Date: Tue, 13 Jun 2017 10:19:47 +0200 Message-ID: <2318694.E4xdUbedMD@ws-stein> User-Agent: KMail/4.14.10 (Linux/4.11.3-gentoo; KDE/4.14.32; x86_64; ; ) In-Reply-To: <1497340725-26594-3-git-send-email-aisheng.dong@nxp.com> References: <1497340725-26594-1-git-send-email-aisheng.dong@nxp.com> <1497340725-26594-3-git-send-email-aisheng.dong@nxp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 800 Lines: 29 On Tuesday 13 June 2017 15:58:45, Dong Aisheng wrote: > diff --git a/drivers/clocksource/timer-imx-tpm.c > b/drivers/clocksource/timer-imx-tpm.c new file mode 100644 > index 0000000..940a4f75 > --- /dev/null > +++ b/drivers/clocksource/timer-imx-tpm.c > @@ -0,0 +1,227 @@ > [...] > +static int tpm_set_next_event(unsigned long delta, > + struct clock_event_device *evt) > +{ > + unsigned long next, now; > + > + next = readl(timer_base + TPM_CNT) + delta; > + writel(next, timer_base + TPM_C0V); > + now = readl(timer_base + TPM_CNT); What about: > now = readl(timer_base + TPM_CNT); > next = now + delta; > writel(next, timer_base + TPM_C0V); > return 0; > + return (int)((next - now) <= 0) ? -ETIME : 0; Can this error actually happen, even with your implementation? Best regards, Alexander