[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VdeqiMdm=zS7W9sfu7=hVFMo0NV6kTOZ_q6UNq9jFcNuA@mail.gmail.com>
Date: Thu, 10 Sep 2020 14:46:08 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Gene Chen <gene.chen.richtek@...il.com>
Cc: Jacek Anaszewski <jacek.anaszewski@...il.com>,
Pavel Machek <pavel@....cz>, Rob Herring <robh+dt@...nel.org>,
Matthias Brugger <matthias.bgg@...il.com>,
Dan Murphy <dmurphy@...com>,
Linux LED Subsystem <linux-leds@...r.kernel.org>,
devicetree <devicetree@...r.kernel.org>,
linux-arm Mailing List <linux-arm-kernel@...ts.infradead.org>,
"moderated list:ARM/Mediatek SoC support"
<linux-mediatek@...ts.infradead.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Gene Chen <gene_chen@...htek.com>, Wilma.Wu@...iatek.com,
shufan_lee@...htek.com, cy_huang@...htek.com,
benjamin.chao@...iatek.com
Subject: Re: [PATCH v3 1/2] leds: mt6360: Add LED driver for MT6360
On Thu, Sep 10, 2020 at 11:11 AM Gene Chen <gene.chen.richtek@...il.com> wrote:
> Andy Shevchenko <andy.shevchenko@...il.com> 於 2020年9月9日 週三 下午9:48寫道:
> > On Mon, Sep 7, 2020 at 1:31 PM Gene Chen <gene.chen.richtek@...il.com> wrote:
> > > From: Gene Chen <gene_chen@...htek.com>
...
> > > + if (priv->fled_strobe_used) {
> > > + dev_warn(lcdev->dev, "Please disable strobe first [%d]\n", priv->fled_strobe_used);
> > > + return -EINVAL;
> >
> > Hmm... Shouldn't be guaranteed by some framework?
> >
>
> Because both Flash LED use single logically control.
> It doesn't exist one LED is torch mode, and the other is strobe mode.
You mean you have always an attribute for hardware even if it doesn't
support a feature?
Can you consider hiding attributes?
...
> > > + lcdev->max_brightness = (val - MT6360_ITORCH_MIN) / MT6360_ITORCH_STEP + 1;
> >
> > DIV_ROUND_UP(val - MT6360_ITORCH_MIN, MT6360_ITORCH_STEP) ?
> >
>
> This is mapping 0~val to 1~max_brightness as level.
> I convert val below MT6360_ITORCH_STEP to 1 for ignore max_brightness
> = 0, because 0 means disable.
> There is a little difference from DIV_ROUND_UP.
What div_round_up does is
(x + y - 1) / y
What do you do
x / y + 1 = (x + y)/y = ((x + 1) + y - 1)/y = DIV_ROUND_UP(x+1,y)
So, DIV_ROUND_UP(val - MT6360_ITORCH_MIN + 1, MT6360_ITORCH_STEP) ?
(yes I made classical off-by-one error)
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists