linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gregor Boirie <gregor.boirie@parrot.com>
To: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>, <linux-iio@vger.kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Subject: Re: [PATCH v1 1/1] iio:core: fix IIO_VAL_FRACTIONAL sign handling
Date: Wed, 7 Sep 2016 20:11:26 +0200	[thread overview]
Message-ID: <57D0584E.2000709@parrot.com> (raw)
In-Reply-To: <419daee6-1e68-dba4-3e04-3c13d58eea44@kernel.org>

Just to mention that a somewhat similar patch might be needed to handle 
negative
IIO_VAL_FRACTIONAL_LOG2 values.

On 09/05/2016 10:24 PM, Jonathan Cameron wrote:
> On 05/09/16 08:59, Lars-Peter Clausen wrote:
>> On 09/03/2016 05:13 PM, Jonathan Cameron wrote:
>>> On 02/09/16 19:27, Gregor Boirie wrote:
>>>> 7985e7c100 ("iio: Introduce a new fractional value type") introduced a
>>>> new IIO_VAL_FRACTIONAL value type meant to represent rational type numbers
>>>> expressed by a numerator and denominator combination.
>>>>
>>>> Formating of IIO_VAL_FRACTIONAL values relies upon do_div() usage. This
>>>> fails handling negative values properly since parameters are reevaluated
>>>> as unsigned values.
>>>> Fix this by using div_s64_rem() instead. Computed integer part will carry
>>>> properly signed value. Formatted fractional part will always be positive.
>>>>
>>>> Fixes: 7985e7c100 ("iio: Introduce a new fractional value type")
>>>> Signed-off-by: Gregor Boirie <gregor.boirie@parrot.com>
>>> Hi Gregor,
>>>
>>> While this looks sensible to me, I always gain an almighty headache when
>>> I hit the various divide functions.
>>>
>>> Lars, the fractional code was yours in the first place.
>>> If you have time can you sanity check this please.
>> Looks good. While looking into this I noticed that we have a very similar
>> patch[1] in our tree, seems like somebody forgot to send that upstream.
>>
>> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
> Applied to the fixes-togreg branch of iio.git and marked for stable.
> Good to know about the previous patch - if there was anything hiding around
> this I would assume that would have shaken it out by now!
>
> Thanks
>
> Jonathan
>>
>> [1]
>> https://github.com/analogdevicesinc/linux/commit/1dbcdcfd0c8d3f5513572697685d9f30ba49d851
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>

  reply	other threads:[~2016-09-07 18:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-02 18:27 [PATCH v1 1/1] iio:core: fix IIO_VAL_FRACTIONAL sign handling Gregor Boirie
2016-09-03 15:13 ` Jonathan Cameron
2016-09-04 16:11   ` Gregor Boirie
2016-09-04 16:23     ` Jonathan Cameron
2016-09-05  7:59   ` Lars-Peter Clausen
2016-09-05 20:24     ` Jonathan Cameron
2016-09-07 18:11       ` Gregor Boirie [this message]
2016-09-07 18:54         ` Lars-Peter Clausen
2016-09-08  8:21           ` Gregor Boirie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57D0584E.2000709@parrot.com \
    --to=gregor.boirie@parrot.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).