[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-iio
Subject:    Re: [PATCH v4] workaround regression in ina2xx introduced by cb47755725da("time: Prevent undefined b
From:       Arnd Bergmann <arnd () arndb ! de>
Date:       2021-09-30 11:04:10
Message-ID: CAK8P3a3LPLbJRDEsYgSL9x=rrk1=AmBWxFBNd0H591NKrLnMZA () mail ! gmail ! com
[Download RAW message or body]

On Thu, Sep 30, 2021 at 10:10 AM Iain Hunter <drhunter95@gmail.com> wrote:
>
> From: Iain Hunter <iain@hunterembedded.co.uk>
>
> That change adds an error check to avoid saturation during multiplication
> to calculate nano seconds in timespec64_to_ns().
> In ina2xx_capture_thread() a timespec64 structure is used to calculate
> the delta time until the next sample time. This delta can be negative if
> the next sample time was in the past. In the -1 case timespec64_to_ns()
> now clamps the -1 second value to KTIME_MAX. This essentially puts ina2xx
> thread to sleep forever.
> Proposed patch is to:
> 1 change from timespec64_XXX() to standard raw ktime_XXX() APIs to remove
> non-standard timespec64 calls.
> 2 split the functionality in the loop into two parts:
> - do while loop only does the test to see if the next sample time is in the
> future or in the past and so will be skipped and the sample time
> incremented until it is in the future. This test is done with a simple
> signed comparison as we are only interested in the sign being positive or
> negative.
> - after do while loop we know that next is later than now and so delay is
> positive and ksub_sub() can be used to get the delay which is positive.
>
> Signed-off-by: Iain Hunter <iain@hunterembedded.co.uk>
>
> Fixes: cb47755725da("time: Prevent undef$

The changelog text could be improved to more closely follow the
style described in Documentation/process/submitting-patches.rst,
but the important information is here and the changes look good
to me.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic