devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Martin Kurbanov <mmkurbanov@sberdevices.ru>
Cc: Pavel Machek <pavel@ucw.cz>, Lee Jones <lee@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel@sberdevices.ru, devicetree@vger.kernel.org
Subject: Re: [PATCH v3 2/2] leds: add aw20xx driver
Date: Tue, 14 Mar 2023 18:49:58 +0200	[thread overview]
Message-ID: <CAHp75Vd5goCgubOyaR2FFPi05eCfguh7XqP7MnHd6qP_o7wEmw@mail.gmail.com> (raw)
In-Reply-To: <CAHp75VcWuOEWZn2E8dG=Pb_KuEv06jYt_+nZSL-ceAQRPmgeGw@mail.gmail.com>

On Tue, Mar 14, 2023 at 6:22 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Tue, Mar 14, 2023 at 2:12 PM Martin Kurbanov
> <mmkurbanov@sberdevices.ru> wrote:
> > On 2023-03-01 00:51, Andy Shevchenko wrote:

...

> > >> +static int aw200xx_set_imax(const struct aw200xx *const chip,
> > >> +                           u32 led_imax_microamp)
> > >> +{
> > >> +       struct imax_global {
> > >> +               u32 regval;
> > >> +               u32 microamp;
> > >> +       } imaxs[] = {
> > >> +               { 8,  3300 },
> > >> +               { 9,  6700 },
> > >> +               { 0,  10000 },
> > >> +               { 11, 13300 },
> > >> +               { 1,  20000 },
> > >> +               { 13, 26700 },
> > >> +               { 2,  30000 },
> > >> +               { 3,  40000 },
> > >> +               { 15, 53300 },
> > >> +               { 4,  60000 },
> > >> +               { 5,  80000 },
> > >> +               { 6,  120000 },
> > >> +               { 7,  160000 },
> > >
> > > This looks a bit random. Is there any pattern on how value is
> > > connected to the register value?
> >
> > There is no ability to create any pattern here, because this table data
> > doesn’t have any regularity.
>
> There is a clear pattern.
>
> You have two tables, i.e. with multiplier 10000 and second one with
> multiplier 3333 (table in the datasheet seems bad from a math
> perspective). And it's even shown correctly in the datasheet.
>
> With this mix you missed 10.
>
> The coefficient table is 1,2,3,4,6,8,12,16 for both tables.
>
> Hence you need one table and two multipliers.
>
> Please, rewrite accordingly.

JFYI: You may see how I killed a table in one driver due to missing
understanding that there is a pattern.
9df461eca18f ("spi: pxa2xx: replace ugly table by approximation")

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2023-03-14 16:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14 12:02 [PATCH v3 0/2] leds: add aw20xx driver Martin Kurbanov
2023-03-14 12:02 ` [PATCH v3 1/2] dt-bindings: leds: add binding for aw200xx Martin Kurbanov
2023-03-16  7:11   ` Krzysztof Kozlowski
2023-03-16 16:40   ` Lee Jones
2023-03-16 19:54     ` Martin Kurbanov
2023-03-17  8:09       ` Lee Jones
2023-03-14 12:02 ` [PATCH v3 2/2] leds: add aw20xx driver Martin Kurbanov
2023-03-14 12:12   ` Martin Kurbanov
2023-03-14 16:22     ` Andy Shevchenko
2023-03-14 16:49       ` Andy Shevchenko [this message]
2023-03-14 16:44   ` Andy Shevchenko
2023-03-15  9:59   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHp75Vd5goCgubOyaR2FFPi05eCfguh7XqP7MnHd6qP_o7wEmw@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@sberdevices.ru \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=mmkurbanov@sberdevices.ru \
    --cc=pavel@ucw.cz \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).