Re: [lm-sensors 1/2] hwmon: (ds1621) Add ds1721 chip support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm once again late, but I could not find the time to test your ds1621
patches before today.

On Wed, 8 May 2013 22:45:53 -0700, Robert Coulson wrote:
> --- a/drivers/hwmon/ds1621.c
> +++ b/drivers/hwmon/ds1621.c
> (...)
> +/*
> + * TEMP: 0.001C/bit (-55C to +125C)
> + * REG:
> + *  - 1621, 1625: x = 0.5C
> + *  - 1721:       x = 0.0625C
> + * Assume highest resolution and let the bits fall where they may..
> + */
> +static inline u16 DS1621_TEMP_TO_REG(long temp)
> +{
> +	int ntemp = clamp_val(temp, DS1621_TEMP_MIN, DS1621_TEMP_MAX);
> +	ntemp += (ntemp < 0 ? -31 : 31);
> +	ntemp = DIV_ROUND_CLOSEST(ntemp * 10, 625) << 4;
> +	return (u16)ntemp;
> +}

This breaks limit rounding on the DS1621. Limits have a resolution of
0.5°C on that chip, so limit values should rounded to the closest
half-degree. It used to work but no longer: if I write 20300 to
temp1_min, it is rounded down to 20000, while it should be rounded up
to 20500.

-- 
Jean Delvare

_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors





[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux