From: Jacek Anaszewski <j.anaszewski@samsung.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: linux-leds@vger.kernel.org, linux-media@vger.kernel.org,
sakari.ailus@linux.intel.com, kyungmin.park@samsung.com,
b.zolnierkie@samsung.com, Bryan Wu <cooloney@gmail.com>,
Richard Purdie <rpurdie@rpsys.net>
Subject: Re: [PATCH/RFC v7 2/3] leds: Add LED Flash Class wrapper to LED subsystem
Date: Fri, 28 Nov 2014 10:34:43 +0100 [thread overview]
Message-ID: <547841B3.2020902@samsung.com> (raw)
In-Reply-To: <20141127084354.GN8907@valkosipuli.retiisi.org.uk>
Hi Sakari,
Thanks for the review.
[...]
>> +static void led_clamp_align(struct led_flash_setting *s)
>> +{
>> + u32 v, offset;
>> +
>> + v = s->val + s->step / 2;
>> + v = clamp(v, s->min, s->max);
>> + offset = v - s->min;
>> + offset = s->step * (offset / s->step);
>
> You could use the rounddown() macro. I.e.
>
> rounddown(v - s->min, s->step) + s->min;
I took this code snippet from v4l2-ctrls.c.
It allows for aligning the control value to the nearest
step - top or bottom, whereas rounddown only to the
bottom one.
Best Regards,
Jacek Anaszewski
next prev parent reply other threads:[~2014-11-28 9:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-12 16:09 [PATCH/RFC v7 0/3] LED / flash API integration - LED Flash Class Jacek Anaszewski
2014-11-12 16:09 ` [PATCH/RFC v7 1/3] leds: Add support for setting brightness in a synchronous way Jacek Anaszewski
2014-11-13 18:43 ` Bryan Wu
2014-11-12 16:09 ` [PATCH/RFC v7 2/3] leds: Add LED Flash Class wrapper to LED subsystem Jacek Anaszewski
2014-11-27 8:43 ` Sakari Ailus
2014-11-28 9:34 ` Jacek Anaszewski [this message]
2014-11-12 16:09 ` [PATCH/RFC v7 3/3] Documentation: leds: Add description of LED Flash Class extension Jacek Anaszewski
2014-11-13 18:58 ` Bryan Wu
2014-11-14 10:21 ` Jacek Anaszewski
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=547841B3.2020902@samsung.com \
--to=j.anaszewski@samsung.com \
--cc=b.zolnierkie@samsung.com \
--cc=cooloney@gmail.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-leds@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=rpurdie@rpsys.net \
--cc=sakari.ailus@iki.fi \
--cc=sakari.ailus@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.