···125125 * (These conversions were contributed by Jonathan Teh Soon Yew126126 * <j.teh@iname.com>)127127 */128128-static inline u8 IN_TO_REG(long val, int inNum)128128+static inline u8 IN_TO_REG(long val, int in_num)129129{130130 /*131131 * To avoid floating point, we multiply constants by 10 (100 for +12V).···134134 * by an additional 10000 (100000 for +12V): 1000 for val and 10 (100)135135 * for the constants.136136 */137137- if (inNum <= 1)137137+ if (in_num <= 1)138138 return (u8) clamp_val((val * 21024 - 1205000) / 250000, 0, 255);139139- else if (inNum == 2)139139+ else if (in_num == 2)140140 return (u8) clamp_val((val * 15737 - 1205000) / 250000, 0, 255);141141- else if (inNum == 3)141141+ else if (in_num == 3)142142 return (u8) clamp_val((val * 10108 - 1205000) / 250000, 0, 255);143143 else144144 return (u8) clamp_val((val * 41714 - 12050000) / 2500000, 0,145145 255);146146}147147148148-static inline long IN_FROM_REG(u8 val, int inNum)148148+static inline long IN_FROM_REG(u8 val, int in_num)149149{150150 /*151151 * To avoid floating point, we multiply constants by 10 (100 for +12V).152152 * We also multiply them by 1000 because we want 0.001V/bit for the153153 * output value. Rounding is done.154154 */155155- if (inNum <= 1)155155+ if (in_num <= 1)156156 return (long) ((250000 * val + 1330000 + 21024 / 2) / 21024);157157- else if (inNum == 2)157157+ else if (in_num == 2)158158 return (long) ((250000 * val + 1330000 + 15737 / 2) / 15737);159159- else if (inNum == 3)159159+ else if (in_num == 3)160160 return (long) ((250000 * val + 1330000 + 10108 / 2) / 10108);161161 else162162 return (long) ((2500000 * val + 13300000 + 41714 / 2) / 41714);···210210 * VIA register values 0-255. I *10 before rounding, so we get tenth-degree211211 * precision. (I could have done all 1024 values for our 10-bit readings,212212 * but the function is very linear in the useful range (0-80 deg C), so213213- * we'll just use linear interpolation for 10-bit readings.) So, tempLUT213213+ * we'll just use linear interpolation for 10-bit readings.) So, temp_lut214214 * is the temp at via register values 0-255:215215 */216216-static const s16 tempLUT[] = {216216+static const s16 temp_lut[] = {217217 -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519,218218 -503, -487, -471, -456, -442, -428, -414, -400, -387, -375,219219 -362, -350, -339, -327, -316, -305, -295, -285, -275, -265,···261261 * - 2.525453e-04*val^3 + 1.424593e-02*val^2 + 2.148941e+00*val +7.275808e+01)262262 * Note that n=161:263263 */264264-static const u8 viaLUT[] = {264264+static const u8 via_lut[] = {265265 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 23,266266 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40,267267 41, 43, 45, 46, 48, 49, 51, 53, 55, 57, 59, 60, 62, 64, 66,···284284 */285285static inline u8 TEMP_TO_REG(long val)286286{287287- return viaLUT[val <= -50000 ? 0 : val >= 110000 ? 160 :287287+ return via_lut[val <= -50000 ? 0 : val >= 110000 ? 160 :288288 (val < 0 ? val - 500 : val + 500) / 1000 + 50];289289}290290291291/* for 8-bit temperature hyst and over registers */292292-#define TEMP_FROM_REG(val) ((long)tempLUT[val] * 100)292292+#define TEMP_FROM_REG(val) ((long)temp_lut[val] * 100)293293294294/* for 10-bit temperature readings */295295static inline long TEMP_FROM_REG10(u16 val)296296{297297- u16 eightBits = val >> 2;298298- u16 twoBits = val & 3;297297+ u16 eight_bits = val >> 2;298298+ u16 two_bits = val & 3;299299300300 /* no interpolation for these */301301- if (twoBits == 0 || eightBits == 255)302302- return TEMP_FROM_REG(eightBits);301301+ if (two_bits == 0 || eight_bits == 255)302302+ return TEMP_FROM_REG(eight_bits);303303304304 /* do some linear interpolation */305305- return (tempLUT[eightBits] * (4 - twoBits) +306306- tempLUT[eightBits + 1] * twoBits) * 25;305305+ return (temp_lut[eight_bits] * (4 - two_bits) +306306+ temp_lut[eight_bits + 1] * two_bits) * 25;307307}308308309309#define DIV_FROM_REG(val) (1 << (val))
+2-2
include/linux/platform_data/ntc_thermistor.h
···4545 * chan: iio_channel pointer to communicate with the ADC which the4646 * thermistor is using for conversion of the analog values.4747 */4848- int (*read_uV)(struct ntc_thermistor_platform_data *);4949- unsigned int pullup_uV;4848+ int (*read_uv)(struct ntc_thermistor_platform_data *);4949+ unsigned int pullup_uv;50505151 unsigned int pullup_ohm;5252 unsigned int pulldown_ohm;