From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753934AbbCXSDg (ORCPT ); Tue, 24 Mar 2015 14:03:36 -0400 Received: from mail-ig0-f178.google.com ([209.85.213.178]:35427 "EHLO mail-ig0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752618AbbCXSDe (ORCPT ); Tue, 24 Mar 2015 14:03:34 -0400 Message-ID: <5511A6EF.8010103@ieee.org> Date: Tue, 24 Mar 2015 13:03:27 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Javi Merino , akpm@linux-foundation.org CC: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, emil.l.velikov@gmail.com, jepler@unpythonic.net, daniel@ffwll.ch, Mike Turquette , Stephen Boyd , Alex Elder Subject: Re: [PATCH v2 2/4] clk: bcm/kona: use DIV_ROUND_CLOSEST_ULL() References: <1427205825-5444-1-git-send-email-javi.merino@arm.com> <1427205825-5444-3-git-send-email-javi.merino@arm.com> In-Reply-To: <1427205825-5444-3-git-send-email-javi.merino@arm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/24/2015 09:03 AM, Javi Merino wrote: > Now that the kernel provides DIV_ROUND_CLOSEST_ULL(), drop the internal > implementation and use the kernel one. > > Cc: Mike Turquette > Cc: Stephen Boyd > Cc: Alex Elder Acked-by: Alex Elder > Signed-off-by: Javi Merino > --- > drivers/clk/bcm/clk-kona.c | 28 +++++++--------------------- > drivers/clk/bcm/clk-kona.h | 1 - > 2 files changed, 7 insertions(+), 22 deletions(-) > > diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c > index 05abae89262e..a0ef4f75d457 100644 > --- a/drivers/clk/bcm/clk-kona.c > +++ b/drivers/clk/bcm/clk-kona.c > @@ -15,6 +15,7 @@ > #include "clk-kona.h" > > #include > +#include > > /* > * "Policies" affect the frequencies of bus clocks provided by a > @@ -51,21 +52,6 @@ static inline u32 bitfield_replace(u32 reg_val, u32 shift, u32 width, u32 val) > > /* Divider and scaling helpers */ > > -/* > - * Implement DIV_ROUND_CLOSEST() for 64-bit dividend and both values > - * unsigned. Note that unlike do_div(), the remainder is discarded > - * and the return value is the quotient (not the remainder). > - */ > -u64 do_div_round_closest(u64 dividend, unsigned long divisor) > -{ > - u64 result; > - > - result = dividend + ((u64)divisor >> 1); > - (void)do_div(result, divisor); > - > - return result; > -} > - > /* Convert a divider into the scaled divisor value it represents. */ > static inline u64 scaled_div_value(struct bcm_clk_div *div, u32 reg_div) > { > @@ -87,7 +73,7 @@ u64 scaled_div_build(struct bcm_clk_div *div, u32 div_value, u32 billionths) > combined = (u64)div_value * BILLION + billionths; > combined <<= div->u.s.frac_width; > > - return do_div_round_closest(combined, BILLION); > + return DIV_ROUND_CLOSEST_ULL(combined, BILLION); > } > > /* The scaled minimum divisor representable by a divider */ > @@ -731,7 +717,7 @@ static unsigned long clk_recalc_rate(struct ccu_data *ccu, > scaled_rate = scale_rate(pre_div, parent_rate); > scaled_rate = scale_rate(div, scaled_rate); > scaled_div = divider_read_scaled(ccu, pre_div); > - scaled_parent_rate = do_div_round_closest(scaled_rate, > + scaled_parent_rate = DIV_ROUND_CLOSEST_ULL(scaled_rate, > scaled_div); > } else { > scaled_parent_rate = scale_rate(div, parent_rate); > @@ -743,7 +729,7 @@ static unsigned long clk_recalc_rate(struct ccu_data *ccu, > * rate. > */ > scaled_div = divider_read_scaled(ccu, div); > - result = do_div_round_closest(scaled_parent_rate, scaled_div); > + result = DIV_ROUND_CLOSEST_ULL(scaled_parent_rate, scaled_div); > > return (unsigned long)result; > } > @@ -790,7 +776,7 @@ static long round_rate(struct ccu_data *ccu, struct bcm_clk_div *div, > scaled_rate = scale_rate(pre_div, parent_rate); > scaled_rate = scale_rate(div, scaled_rate); > scaled_pre_div = divider_read_scaled(ccu, pre_div); > - scaled_parent_rate = do_div_round_closest(scaled_rate, > + scaled_parent_rate = DIV_ROUND_CLOSEST_ULL(scaled_rate, > scaled_pre_div); > } else { > scaled_parent_rate = scale_rate(div, parent_rate); > @@ -802,7 +788,7 @@ static long round_rate(struct ccu_data *ccu, struct bcm_clk_div *div, > * the best we can do. > */ > if (!divider_is_fixed(div)) { > - best_scaled_div = do_div_round_closest(scaled_parent_rate, > + best_scaled_div = DIV_ROUND_CLOSEST_ULL(scaled_parent_rate, > rate); > min_scaled_div = scaled_div_min(div); > max_scaled_div = scaled_div_max(div); > @@ -815,7 +801,7 @@ static long round_rate(struct ccu_data *ccu, struct bcm_clk_div *div, > } > > /* OK, figure out the resulting rate */ > - result = do_div_round_closest(scaled_parent_rate, best_scaled_div); > + result = DIV_ROUND_CLOSEST_ULL(scaled_parent_rate, best_scaled_div); > > if (scaled_div) > *scaled_div = best_scaled_div; > diff --git a/drivers/clk/bcm/clk-kona.h b/drivers/clk/bcm/clk-kona.h > index 2537b3072910..6849a64baf6d 100644 > --- a/drivers/clk/bcm/clk-kona.h > +++ b/drivers/clk/bcm/clk-kona.h > @@ -503,7 +503,6 @@ extern struct clk_ops kona_peri_clk_ops; > > /* Externally visible functions */ > > -extern u64 do_div_round_closest(u64 dividend, unsigned long divisor); > extern u64 scaled_div_max(struct bcm_clk_div *div); > extern u64 scaled_div_build(struct bcm_clk_div *div, u32 div_value, > u32 billionths); >