[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VfUq+DZk_u5Wsyr5nnibbe+WrYDyhvCU22=4Pog06DgHg@mail.gmail.com>
Date: Mon, 1 Nov 2021 12:42:37 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Hans de Goede <hdegoede@...hat.com>
Cc: "Rafael J . Wysocki" <rjw@...ysocki.net>,
Mark Gross <markgross@...nel.org>,
Andy Shevchenko <andy@...radead.org>,
Wolfram Sang <wsa@...-dreams.de>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Daniel Scally <djrscally@...il.com>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>, Len Brown <lenb@...nel.org>,
ACPI Devel Maling List <linux-acpi@...r.kernel.org>,
Platform Driver <platform-driver-x86@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-i2c <linux-i2c@...r.kernel.org>,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
Kate Hsuan <hpa@...hat.com>,
Linux Media Mailing List <linux-media@...r.kernel.org>,
linux-clk <linux-clk@...r.kernel.org>
Subject: Re: [PATCH v4 05/11] clk: Introduce clk-tps68470 driver
On Mon, Nov 1, 2021 at 12:27 PM Hans de Goede <hdegoede@...hat.com> wrote:
> On 10/25/21 13:24, Andy Shevchenko wrote:
> > On Mon, Oct 25, 2021 at 12:42 PM Hans de Goede <hdegoede@...hat.com> wrote:
...
> >> + for (i = 0; i < ARRAY_SIZE(clk_freqs); i++) {
> >> + diff = clk_freqs[i].freq - rate;
> >> + if (diff == 0)
> >> + return i;
> >
> >> + diff = abs(diff);
> >
> > This needs a comment why higher (lower) frequency is okay.
>
> This function is called in 2 places:
>
> 1. From tps68470_clk_round_rate(), where higher/lower clearly is ok,
> (see the function name) so no comment needed.
>
> 2. From tps68470_clk_set_rate() where it is NOT ok and this is
> enforced in the caller:
>
> unsigned int idx = tps68470_clk_cfg_lookup(rate);
>
> if (rate != clk_freqs[idx].freq)
> return -EINVAL;
>
> This is not easy to describe in a comment, while being obvious
> if someone looking at this actually looks at the callers.
Hmm... but try your best. :-)
While at it, recently I have learned about util_macros.h. Any use of it here?
Or amending it there and re-using it here?
> >> + if (diff < best_diff) {
> >> + best_diff = diff;
> >> + best_idx = i;
> >> + }
> >> + }
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists