lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VeP6Ui-Sw65T-cwGh9ADMEcEGOzf8C3aYCTK_seZjgqeg@mail.gmail.com>
Date:   Thu, 17 May 2018 01:19:47 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Dan Murphy <dmurphy@...com>
Cc:     Rob Herring <robh+dt@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Jacek Anaszewski <jacek.anaszewski@...il.com>,
        Pavel Machek <pavel@....cz>,
        devicetree <devicetree@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Linux LED Subsystem <linux-leds@...r.kernel.org>
Subject: Re: [PATCH v6 2/2] leds: lm3601x: Introduce the lm3601x LED driver

On Thu, May 17, 2018 at 1:11 AM, Andy Shevchenko
<andy.shevchenko@...il.com> wrote:
> On Wed, May 16, 2018 at 11:43 PM, Dan Murphy <dmurphy@...com> wrote:
>> On 05/15/2018 05:24 PM, Andy Shevchenko wrote:
>>> On Wed, May 16, 2018 at 1:08 AM, Dan Murphy <dmurphy@...com> wrote:
>>>> On 05/15/2018 04:56 PM, Andy Shevchenko wrote:

>>>>>> +static const struct lm3601x_max_timeouts strobe_timeouts[] = {
>>>>>> +       { 40000, 0x00 },
>>>>>> +       { 80000, 0x01 },
>>>>>> +       { 120000, 0x02 },
>>>>>> +       { 160000, 0x03 },
>>>>>> +       { 200000, 0x04 },
>>>>>> +       { 240000, 0x05 },
>>>>>> +       { 280000, 0x06 },
>>>>>> +       { 320000, 0x07 },
>>>>>> +       { 360000, 0x08 },
>>>>>> +       { 400000, 0x09 },
>>>>>> +       { 600000, 0x0a },
>>>>>> +       { 800000, 0x0b },
>>>>>> +       { 1000000, 0x0c },
>>>>>> +       { 1200000, 0x0d },
>>>>>> +       { 1400000, 0x0e },
>>>>>> +       { 1600000, 0x0f },

>>> if (x < 9)
>>>  strobe_timeout = (x + 1) * 40 * MSECS_IN_SEC;
>>> else
>>>  strobe_timeout = (x - 7) * 200 * MSECS_IN_SEC;

>>
>> Not sure if this will produce the register value I am looking for.  I have to run through the
>> algorithim.  The idea is to take in the timeout and get the reg value to program.
>>
>> If it yields the expected output, or with a modified equation, then I can pull it in.
>
> So, you need a reversed calculus in this case.
>
> u8 regval;
>
> /* To make it in range... */
> timeout = clamp_val(timeout, 40000, 1600000);
> /* ...other possibility to issue an error */
>
> if (timeout >= 400000)
>  regval = timeout / 200000 + 0x07;
> else
>  regval = timeout / 40000 - 0x01;

Forgot to mention that there are also three approaches (considering
division here):
- round up
- round down
- round to closest

>
> In any case, please double check it gives a correct values.


-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ