lkml.org 
[lkml]   [2014]   [Oct]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 7/8] eeepc-laptop: document fan_pwm conversions
From
On Tue, Oct 28, 2014 at 6:31 AM, Darren Hart <dvhart@infradead.org> wrote:
> On Wed, Oct 22, 2014 at 09:12:42PM +0200, Frans Klaver wrote:
>> eeepc_get_fan_pwm and eeepc_set_fan_pwm convert the PWM value read from
>> the fan to a range lmsensors understands. Unfortunately this is only
>> clear if you are familiar with how lmsensors handles duty cycles.
>>
>> Introduce two conversion functions that document the goal of these
>> conversions.
>>
>> Signed-off-by: Frans Klaver <fransklaver@gmail.com>
>> ---
>> drivers/platform/x86/eeepc-laptop.c | 16 +++++++++++++---
>> 1 file changed, 13 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
>> index f820bb3..275a239 100644
>> --- a/drivers/platform/x86/eeepc-laptop.c
>> +++ b/drivers/platform/x86/eeepc-laptop.c
>> @@ -974,18 +974,28 @@ static struct platform_driver platform_driver = {
>> #define EEEPC_EC_SFB0 0xD0
>> #define EEEPC_EC_FAN_CTRL (EEEPC_EC_SFB0 + 3) /* Byte containing SF25 */
>>
>> +static inline int eeepc_pwm_to_lmsensors(int value)
>> +{
>> + return value * 255 / 100;
>> +}
>> +
>> +static inline int eeepc_lmsensors_to_pwm(int value)
>> +{
>> + value = clamp_val(value, 0, 255);
>> + return value * 100 / 255;
>
> Says the guy cleaning up all the magic numbers.... ;-)
>
> But yeah, this is fine IMO. Applied.

Heh, I don't think this is any more or less magic than

#define CONVERT_TO_LMSENSORS (255 / 100)

value = value * CONVERT_TO_LMSENSORS;

or

#define lmify(v) v * 255 / 100

value = lmify(v);

But since you've just applied it, I would say you have pretty much the
same opinion.

Thanks,
Frans


\
 
 \ /
  Last update: 2014-10-28 10:01    [W:0.077 / U:2.720 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site