[PATCH RFC v1 1/3] clk: divider: Add re-usable determine_rate implementations

Martin Blumenstingl martin.blumenstingl at googlemail.com
Tue May 18 13:33:50 PDT 2021


Hi Jerome,

On Tue, May 18, 2021 at 9:44 AM Jerome Brunet <jbrunet at baylibre.com> wrote:
[...]
> > +int divider_ro_determine_rate(struct clk_hw *hw, struct clk_rate_request *req,
> > +                           const struct clk_div_table *table, u8 width,
> > +                           unsigned long flags, unsigned int val)
> > +{
> > +     int div;
> > +
> > +     div = _get_div(table, val, flags, width);
> > +
> > +     /* Even a read-only clock can propagate a rate change */
> > +     if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) {
> > +             if (!req->best_parent_hw)
> > +                     return -EINVAL;
> > +
> > +             req->best_parent_rate = clk_hw_round_rate(req->best_parent_hw,
> > +                                                       req->rate * div);
> > +     }
> > +
> > +     req->rate = DIV_ROUND_UP_ULL((u64)req->best_parent_rate, div);
> > +
> > +     return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(divider_ro_determine_rate);
>
> For a final version, could you factorize the code with the .round_rate()
> variant ? It would remove a bit of duplication.
my first idea was to basically let the new _determine_rate code just
forward all relevant parameters to _round_rate
however, I discarded that as it turned out to be less understandable
for me as parameters need to be mapped in both ways

while writing this mail I noticed that the opposite direction
(meaning: _round_rate forwards to _determine_rate) will probably work.
I'll give it a try in the next days
if you had anything else in mind then please let me know

> Maybe determine_rate() can also replace round_rate() in the generic
> divider ops ?
sure, I'll add that as a separate patch in this series
note to myself: testing can be done with the MMC drivers as we're
using the generic clk_divider_ops there


Best regards,
Martin



More information about the linux-arm-kernel mailing list