From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932318AbcFUBmU (ORCPT ); Mon, 20 Jun 2016 21:42:20 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:54505 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751663AbcFUBmS (ORCPT ); Mon, 20 Jun 2016 21:42:18 -0400 Date: Mon, 20 Jun 2016 18:42:16 -0700 From: Stephen Boyd To: Maxime Ripard Cc: Mike Turquette , Chen-Yu Tsai , linux-clk@vger.kernel.org, Hans de Goede , Andre Przywara , Rob Herring , Vishnu Patekar , linux-arm-kernel@lists.infradead.org, Boris Brezillon , Jean-Francois Moine , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v2 13/15] clk: sunxi-ng: Add N-K-M-P factor clock Message-ID: <20160621014216.GS1521@codeaurora.org> References: <20160607204154.31967-1-maxime.ripard@free-electrons.com> <20160607204154.31967-14-maxime.ripard@free-electrons.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160607204154.31967-14-maxime.ripard@free-electrons.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/07, Maxime Ripard wrote: > diff --git a/drivers/clk/sunxi-ng/ccu_nkmp.c b/drivers/clk/sunxi-ng/ccu_nkmp.c > new file mode 100644 > index 000000000000..9f2b98e19dc9 > --- /dev/null > +++ b/drivers/clk/sunxi-ng/ccu_nkmp.c > @@ -0,0 +1,167 @@ > +/* > + * Copyright (C) 2016 Maxime Ripard > + * Maxime Ripard > + * > + * This program is free software; you can redistribute it and/or > + * modify it under the terms of the GNU General Public License as > + * published by the Free Software Foundation; either version 2 of > + * the License, or (at your option) any later version. > + */ > + > +#include > +#include > + > +#include "ccu_gate.h" > +#include "ccu_nkmp.h" > + > +struct _ccu_nkmp { > + unsigned long n, max_n; > + unsigned long k, max_k; > + unsigned long m, max_m; > + unsigned long p, max_p; > +}; > + > +static void ccu_nkmp_find_best(unsigned long parent, unsigned long rate, > + struct _ccu_nkmp *nkmp) > +{ > + unsigned long best_rate = 0; > + unsigned long best_n = 0, best_k = 0, best_m = 0, best_p = 0; > + unsigned long _n, _k, _m, _p; > + > + for (_k = 1; _k <= nkmp->max_k; _k++) { > + for (_p = 0; _p <= nkmp->max_p; _p++) { > + unsigned long tmp_rate; > + > + rational_best_approximation(rate / _k, parent >> _p, > + nkmp->max_n, nkmp->max_m, > + &_n, &_m); Is there a select for RATIONAL somewhere? If not please add it to the Kconfig. I know that COMMON_CLK has it, but I think we should try to reduce bloat by not forcing all the basic types on drivers that aren't using them. Instead we should have drivers start selecting that code. So it's best to not rely on the common clk select. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project