| 173 | | } |
| 174 | | |
| 175 | | /* These constants are a guess, consistent w/ LM75 */ |
| 176 | | #define LM75_TEMP_MIN (-550) |
| 177 | | #define LM75_TEMP_MAX (1250) |
| 178 | | |
| 179 | | /* TEMP: 1/10 degrees C (-55C to 125C) |
| 180 | | REG: (0.5C/bit, two's complement) << 7 */ |
| 181 | | static u16 LM75_TEMP_TO_REG(int temp) |
| 182 | | { |
| 183 | | int ntemp = SENSORS_LIMIT(temp, LM75_TEMP_MIN, LM75_TEMP_MAX); |
| 184 | | ntemp += (ntemp<0 ? -2 : 2); |
| 185 | | return (u16)((ntemp / 5) << 7); |
| 186 | | } |
| 187 | | |
| 188 | | static int LM75_TEMP_FROM_REG(u16 reg) |
| 189 | | { |
| 190 | | /* use integer division instead of equivalent right shift |
| 191 | | in order to guarantee arithmetic shift */ |
| 192 | | return ((s16)reg / 128) * 5; |