[PATCH v3 1/2] leds: mt6360: Add LED driver for MT6360
Andy Shevchenko
andy.shevchenko at gmail.com
Thu Sep 10 07:46:08 EDT 2020
On Thu, Sep 10, 2020 at 11:11 AM Gene Chen <gene.chen.richtek at gmail.com> wrote:
> Andy Shevchenko <andy.shevchenko at gmail.com> 於 2020年9月9日 週三 下午9:48寫道:
> > On Mon, Sep 7, 2020 at 1:31 PM Gene Chen <gene.chen.richtek at gmail.com> wrote:
> > > From: Gene Chen <gene_chen at richtek.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
More information about the Linux-mediatek
mailing list