Linux IIO development
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Subhajit Ghosh <subhajit.ghosh@tweaklogic.com>,
	Jonathan Cameron <jic23@kernel.org>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: gts-helper: Fix division loop
Date: Mon, 5 Feb 2024 11:19:59 +0200	[thread overview]
Message-ID: <ec54fd85-f326-4162-aa28-1dcf54be0e4f@gmail.com> (raw)
In-Reply-To: <9f94a3de-7f04-4ad8-9b98-9e6312cce589@tweaklogic.com>

On 2/4/24 15:49, Subhajit Ghosh wrote:
> Hi Matti,
>>>>>>   drivers/iio/industrialio-gts-helper.c | 5 ++---
>>>>>>   1 file changed, 2 insertions(+), 3 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/iio/industrialio-gts-helper.c 
>>>>>> b/drivers/iio/industrialio-gts-helper.c
>>>>>> index 7653261d2dc2..abcab2d38589 100644
>>>>>> --- a/drivers/iio/industrialio-gts-helper.c
>>>>>> +++ b/drivers/iio/industrialio-gts-helper.c
>>>>>> @@ -34,7 +34,7 @@
>>>>>>   static int iio_gts_get_gain(const u64 max, const u64 scale)
>>>>>>   {
>>>>>>       u64 full = max;
>>>>>> -    int tmp = 1;
>>>>>> +    int tmp = 0;
>>>>>>       if (scale > full || !scale)
>>>>>>           return -EINVAL;
>>>>>> @@ -48,8 +48,7 @@ static int iio_gts_get_gain(const u64 max, const 
>>>>>> u64 scale)
>>>>>>           tmp++;
>>>>>>       }
>>>>>> -    while (full > scale * (u64)tmp)
>>>>>> -        tmp++;
>>>>>> +    tmp += div64_u64(full, scale);
>>>>>>       return tmp;
>>>>>>   }
>>>>>>
>>>>>> base-commit: 2cc14f52aeb78ce3f29677c2de1f06c0e91471ab
>>>>>
>>>>>
>>>> Hi Matti,
>>>>
>>>> Your fix works beautifully with the latest version of apds9306 
>>>> driver which I am working on.
>>>> All available scale values can be set without any errors. Thank you.
>>>
>>> Thanks for testing Subhajit! Just to ensure we have no 
>>> miscommunication - did you test just this division fix, or the 
>>> rounding fix here:
>>> https://lore.kernel.org/lkml/37d3aa193e69577353d314e94463a08d488ddd8d.1701780964.git.mazziesaccount@gmail.com/
>> You are most welcome. I did not check the above rounding fix pointed 
>> out by the link. I will be happy to check it and let you know by the 
>> end of this month.
>> I checked this division fix.
> I tested the patch in the above link with adps9306 driver which I am 
> working on and it seems to work well without any issues.

Great! Thanks a lot Subhajit! Your testing is very much appreciated :)

I think you sent another version of your APDS9306 driver. AFAIR, this 
driver could have benefited from the above rounding fix. I will see if I 
find the time and energy to see if I can dive into this again and 
re-spin this rounding fix. No promises but I'll try :)

Yours,
	-- Matti

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


  reply	other threads:[~2024-02-05  9:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-04  9:34 [PATCH] iio: gts-helper: Fix division loop Matti Vaittinen
2024-01-07 16:22 ` Jonathan Cameron
2024-01-08  6:35   ` Matti Vaittinen
2024-01-19 11:56   ` Subhajit Ghosh
2024-01-22  6:50     ` Matti Vaittinen
2024-01-22  9:58       ` Subhajit Ghosh
2024-02-04 13:49         ` Subhajit Ghosh
2024-02-05  9:19           ` Matti Vaittinen [this message]
2024-01-22 16:27       ` David Laight
2024-01-22 19:24         ` Jonathan Cameron
2024-01-23 10:30         ` Matti Vaittinen

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=ec54fd85-f326-4162-aa28-1dcf54be0e4f@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matti.vaittinen@fi.rohmeurope.com \
    --cc=subhajit.ghosh@tweaklogic.com \
    /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