From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423427AbcB0IAz (ORCPT ); Sat, 27 Feb 2016 03:00:55 -0500 Received: from torg.zytor.com ([198.137.202.12]:37652 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755553AbcB0IAx (ORCPT ); Sat, 27 Feb 2016 03:00:53 -0500 Date: Sat, 27 Feb 2016 00:00:37 -0800 From: tip-bot for Alexander Kuleshov Message-ID: Cc: richardcochran@gmail.com, kuleshovmail@gmail.com, tglx@linutronix.de, john.stultz@linaro.org, prarit@redhat.com, hpa@zytor.com, linux-kernel@vger.kernel.org, mingo@kernel.org Reply-To: kuleshovmail@gmail.com, richardcochran@gmail.com, hpa@zytor.com, linux-kernel@vger.kernel.org, mingo@kernel.org, prarit@redhat.com, john.stultz@linaro.org, tglx@linutronix.de In-Reply-To: <1456542854-22104-2-git-send-email-john.stultz@linaro.org> References: <1456542854-22104-2-git-send-email-john.stultz@linaro.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:timers/core] clocksource: Introduce clocksource_freq2mult() Git-Commit-ID: 7aca0c07207385cca76025cc85231519935722b9 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 7aca0c07207385cca76025cc85231519935722b9 Gitweb: http://git.kernel.org/tip/7aca0c07207385cca76025cc85231519935722b9 Author: Alexander Kuleshov AuthorDate: Fri, 26 Feb 2016 19:14:13 -0800 Committer: Thomas Gleixner CommitDate: Sat, 27 Feb 2016 08:55:30 +0100 clocksource: Introduce clocksource_freq2mult() The clocksource_khz2mult() and clocksource_hz2mult() share similar code wihch calculates a mult from the given frequency. Both implementations in differ only in value of a frequency. This patch introduces the clocksource_freq2mult() helper with generic implementation of mult calculation to prevent code duplication. Signed-off-by: Alexander Kuleshov Signed-off-by: John Stultz Cc: Prarit Bhargava Cc: Richard Cochran Link: http://lkml.kernel.org/r/1456542854-22104-2-git-send-email-john.stultz@linaro.org Signed-off-by: Thomas Gleixner --- include/linux/clocksource.h | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h index 6013021..a307bf6 100644 --- a/include/linux/clocksource.h +++ b/include/linux/clocksource.h @@ -118,6 +118,23 @@ struct clocksource { /* simplify initialization of mask field */ #define CLOCKSOURCE_MASK(bits) (cycle_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1) +static inline u32 clocksource_freq2mult(u32 freq, u32 shift_constant, u64 from) +{ + /* freq = cyc/from + * mult/2^shift = ns/cyc + * mult = ns/cyc * 2^shift + * mult = from/freq * 2^shift + * mult = from * 2^shift / freq + * mult = (from<