lkml.org 
[lkml]   [2022]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 17/19] hwmon: (mr75203) parse temperature coefficients from device-tree
On Tue, Aug 30, 2022 at 07:22:10PM +0000, Eliav Farber wrote:
> Use thermal coefficients from the device tree if they exist.
> Otherwise, use default values according to the series (5 or 6).
> All coefficients can be used or only part of them.
>
> The coefficients shall be used for fine tuning the default values since
> coefficients can vary between product and product.

...

> + ret = of_property_read_u32(np, "moortec,ts-coeff-h", &coeff_h);

of_ ?! Ditto for the rest.

> + if (!ret)
> + ts_coeff->h = coeff_h;

...

> + ret = of_property_read_s32(np, "moortec,ts-coeff-j", &coeff_j);
> + if (!ret)
> + ts_coeff->j = coeff_j;

You may avoid conditional:

_property_read_s32(..., "moortec,ts-coeff-j", &ts_coeff->j);


...

> + ret = of_property_read_u32(np, "moortec,ts-coeff-cal5", &coeff_cal5);
> + if (!ret) {

> + if (coeff_cal5 == 0) {
> + dev_err(dev, "moortec,ts-coeff-cal5 can't be 0\n");
> + return -EINVAL;
> + }

Code shouldn't be a YAML validator. Drop this and make sure you have correct
DT schema.

> + ts_coeff->cal5 = coeff_cal5;
> + }

Also see above.

--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2022-08-31 14:12    [W:0.395 / U:0.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site