adt7475.c (976e3645923bdd2fe7893aae33fd7a21098bfb28) | adt7475.c (cf3ca1877574a306c0207cbf7fdf25419d9229df) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * adt7475 - Thermal sensor driver for the ADT7475 chip and derivatives 4 * Copyright (C) 2007-2008, Advanced Micro Devices, Inc. 5 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net> 6 * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com> 7 * Copyright (C) 2009 Jean Delvare <jdelvare@suse.de> 8 * --- 280 unchanged lines hidden (view full) --- 289} 290 291static inline u16 volt2reg(int channel, long volt, u8 bypass_attn) 292{ 293 const int *r = adt7473_in_scaling[channel]; 294 long reg; 295 296 if (bypass_attn & (1 << channel)) | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * adt7475 - Thermal sensor driver for the ADT7475 chip and derivatives 4 * Copyright (C) 2007-2008, Advanced Micro Devices, Inc. 5 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net> 6 * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com> 7 * Copyright (C) 2009 Jean Delvare <jdelvare@suse.de> 8 * --- 280 unchanged lines hidden (view full) --- 289} 290 291static inline u16 volt2reg(int channel, long volt, u8 bypass_attn) 292{ 293 const int *r = adt7473_in_scaling[channel]; 294 long reg; 295 296 if (bypass_attn & (1 << channel)) |
297 reg = (volt * 1024) / 2250; | 297 reg = DIV_ROUND_CLOSEST(volt * 1024, 2250); |
298 else | 298 else |
299 reg = (volt * r[1] * 1024) / ((r[0] + r[1]) * 2250); | 299 reg = DIV_ROUND_CLOSEST(volt * r[1] * 1024, 300 (r[0] + r[1]) * 2250); |
300 return clamp_val(reg, 0, 1023) & (0xff << 2); 301} 302 303static int adt7475_read_word(struct i2c_client *client, int reg) 304{ 305 int val1, val2; 306 307 val1 = i2c_smbus_read_byte_data(client, reg); --- 1532 unchanged lines hidden --- | 301 return clamp_val(reg, 0, 1023) & (0xff << 2); 302} 303 304static int adt7475_read_word(struct i2c_client *client, int reg) 305{ 306 int val1, val2; 307 308 val1 = i2c_smbus_read_byte_data(client, reg); --- 1532 unchanged lines hidden --- |