lkml.org 
[lkml]   [2023]   [Oct]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2 2/2] iio: light: Add support for APDS9306 Light Sensor
From
On 10/31/23 12:38, Andy Shevchenko wrote:
> On Tue, Oct 31, 2023 at 09:11:37AM +0200, Matti Vaittinen wrote:
>> On 10/30/23 12:21, Matti Vaittinen wrote:
>>> On 10/29/23 17:51, Matti Vaittinen wrote:
>>>> On 10/28/23 18:20, Jonathan Cameron wrote:
>
> ...
>
>> tmp = gts->max_scale;
>>
>> rem = do_div(tmp, total_gain);
>> if (total_gain > 1 && rem >= total_gain / 2)
>> tmp += 1ULL;
>
> ...which is NIH DIV_ROUND_CLOSEST_ULL()

Thanks for the hint Andy. I do very much prefer using stuff like the
DIV_ROUND_CLOSEST_ULL().

I will use this - do you have other suggestions for me, especially
regarding the division u64 / u64?

I would appreciate if you found the time and energy to look at:
https://lore.kernel.org/all/ZUDN9n8iXoNwzifQ@dc78bmyyyyyyyyyyyyyyt-3.rev.dnainternet.fi/

as well. I feel like I am doing something someone else has already done.
(Yes, DIV_ROUND_CLOSEST_ULL() can be used there too).

Anyways, Thanks for this!

Yours,
-- Matti

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

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

\
 
 \ /
  Last update: 2023-10-31 12:40    [W:0.106 / U:2.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site