Messages in this thread | | | From | Andy Shevchenko <> | Date | Thu, 10 Sep 2020 14:46:08 +0300 | 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@gmail.com> wrote: > Andy Shevchenko <andy.shevchenko@gmail.com> 於 2020年9月9日 週三 下午9:48寫道: > > On Mon, Sep 7, 2020 at 1:31 PM Gene Chen <gene.chen.richtek@gmail.com> wrote: > > > From: Gene Chen <gene_chen@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
| |