From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754814AbcK2QWp (ORCPT ); Tue, 29 Nov 2016 11:22:45 -0500 Received: from lelnx193.ext.ti.com ([198.47.27.77]:14740 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751168AbcK2QWh (ORCPT ); Tue, 29 Nov 2016 11:22:37 -0500 Subject: Re: [PATCH v2 12/13] net: ethernet: ti: cpts: calc mult and shift from refclk freq To: Richard Cochran References: <20161128230337.6731-1-grygorii.strashko@ti.com> <20161128230337.6731-13-grygorii.strashko@ti.com> <20161129103453.GJ3110@localhost.localdomain> CC: "David S. Miller" , , Mugunthan V N , Sekhar Nori , , , Rob Herring , , Murali Karicheri , Wingman Kwok , John Stultz , Thomas Gleixner From: Grygorii Strashko Message-ID: Date: Tue, 29 Nov 2016 10:22:21 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161129103453.GJ3110@localhost.localdomain> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [128.247.83.173] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/29/2016 04:34 AM, Richard Cochran wrote: > On Mon, Nov 28, 2016 at 05:03:36PM -0600, Grygorii Strashko wrote: >> +static void cpts_calc_mult_shift(struct cpts *cpts) >> +{ >> + u64 frac, maxsec, ns; >> + u32 freq, mult, shift; >> + >> + freq = clk_get_rate(cpts->refclk); >> + >> + /* Calc the maximum number of seconds which we can run before >> + * wrapping around. >> + */ >> + maxsec = cpts->cc.mask; >> + do_div(maxsec, freq); >> + if (maxsec > 600 && cpts->cc.mask > UINT_MAX) >> + maxsec = 600; > > The reason for this test is not obvious. Why check cc.mask against > UINT_MAX? Please use the comment to explain it. > Yeah. This is copy paste from __clocksource_update_freq_scale(), but I'm going to limit it to 10 sec for now, because otherwise it will result in too small mult in case of 64bit counter. if (maxsec > 10) maxsec = 10; -- regards, -grygorii