Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
088ce2ac
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
088ce2ac
编写于
3月 13, 2013
作者:
G
Guenter Roeck
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hwmon: Fix CamelCase checkpatch warnings
Signed-off-by:
N
Guenter Roeck
<
linux@roeck-us.net
>
上级
236d9039
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
218 addition
and
218 deletion
+218
-218
drivers/hwmon/ads7871.c
drivers/hwmon/ads7871.c
+21
-21
drivers/hwmon/asc7621.c
drivers/hwmon/asc7621.c
+28
-28
drivers/hwmon/da9052-hwmon.c
drivers/hwmon/da9052-hwmon.c
+7
-7
drivers/hwmon/da9055-hwmon.c
drivers/hwmon/da9055-hwmon.c
+2
-2
drivers/hwmon/it87.c
drivers/hwmon/it87.c
+12
-12
drivers/hwmon/lm93.c
drivers/hwmon/lm93.c
+19
-19
drivers/hwmon/ntc_thermistor.c
drivers/hwmon/ntc_thermistor.c
+108
-108
drivers/hwmon/via686a.c
drivers/hwmon/via686a.c
+19
-19
include/linux/platform_data/ntc_thermistor.h
include/linux/platform_data/ntc_thermistor.h
+2
-2
未找到文件。
drivers/hwmon/ads7871.c
浏览文件 @
088ce2ac
...
...
@@ -40,25 +40,25 @@
* the instruction byte
*/
/*Instruction Bit masks*/
#define INST_MODE_
bm (1<<
7)
#define INST_READ_
bm (1<<
6)
#define INST_16BIT_
bm (1<<
5)
#define INST_MODE_
BM (1 <<
7)
#define INST_READ_
BM (1 <<
6)
#define INST_16BIT_
BM (1 <<
5)
/*From figure 18 in the datasheet*/
/*bit masks for Rev/Oscillator Control Register*/
#define MUX_CNV_
bv
7
#define MUX_CNV_
bm (1<<MUX_CNV_bv
)
#define MUX_M3_
bm (1<<
3)
/*M3 selects single ended*/
#define MUX_G_
bv 4
/*allows for reg = (gain << MUX_G_bv
) | ...*/
#define MUX_CNV_
BV
7
#define MUX_CNV_
BM (1 << MUX_CNV_BV
)
#define MUX_M3_
BM (1 <<
3)
/*M3 selects single ended*/
#define MUX_G_
BV 4
/*allows for reg = (gain << MUX_G_BV
) | ...*/
/*From figure 18 in the datasheet*/
/*bit masks for Rev/Oscillator Control Register*/
#define OSC_OSCR_
bm (1<<
5)
#define OSC_OSCE_
bm (1<<
4)
#define OSC_REFE_
bm (1<<
3)
#define OSC_BUFE_
bm (1<<
2)
#define OSC_R2V_
bm (1<<
1)
#define OSC_RBG_
bm (1<<
0)
#define OSC_OSCR_
BM (1 <<
5)
#define OSC_OSCE_
BM (1 <<
4)
#define OSC_REFE_
BM (1 <<
3)
#define OSC_BUFE_
BM (1 <<
2)
#define OSC_R2V_
BM (1 <<
1)
#define OSC_RBG_
BM (1 <<
0)
#include <linux/module.h>
#include <linux/init.h>
...
...
@@ -79,7 +79,7 @@ struct ads7871_data {
static
int
ads7871_read_reg8
(
struct
spi_device
*
spi
,
int
reg
)
{
int
ret
;
reg
=
reg
|
INST_READ_
bm
;
reg
=
reg
|
INST_READ_
BM
;
ret
=
spi_w8r8
(
spi
,
reg
);
return
ret
;
}
...
...
@@ -87,7 +87,7 @@ static int ads7871_read_reg8(struct spi_device *spi, int reg)
static
int
ads7871_read_reg16
(
struct
spi_device
*
spi
,
int
reg
)
{
int
ret
;
reg
=
reg
|
INST_READ_
bm
|
INST_16BIT_bm
;
reg
=
reg
|
INST_READ_
BM
|
INST_16BIT_BM
;
ret
=
spi_w8r16
(
spi
,
reg
);
return
ret
;
}
...
...
@@ -111,13 +111,13 @@ static ssize_t show_voltage(struct device *dev,
* TODO: add support for conversions
* other than single ended with a gain of 1
*/
/*MUX_M3_
bm
forces single ended*/
/*MUX_M3_
BM
forces single ended*/
/*This is also where the gain of the PGA would be set*/
ads7871_write_reg8
(
spi
,
REG_GAIN_MUX
,
(
MUX_CNV_
bm
|
MUX_M3_bm
|
channel
));
(
MUX_CNV_
BM
|
MUX_M3_BM
|
channel
));
ret
=
ads7871_read_reg8
(
spi
,
REG_GAIN_MUX
);
mux_cnv
=
((
ret
&
MUX_CNV_
bm
)
>>
MUX_CNV_bv
);
mux_cnv
=
((
ret
&
MUX_CNV_
BM
)
>>
MUX_CNV_BV
);
/*
* on 400MHz arm9 platform the conversion
* is already done when we do this test
...
...
@@ -125,14 +125,14 @@ static ssize_t show_voltage(struct device *dev,
while
((
i
<
2
)
&&
mux_cnv
)
{
i
++
;
ret
=
ads7871_read_reg8
(
spi
,
REG_GAIN_MUX
);
mux_cnv
=
((
ret
&
MUX_CNV_
bm
)
>>
MUX_CNV_bv
);
mux_cnv
=
((
ret
&
MUX_CNV_
BM
)
>>
MUX_CNV_BV
);
msleep_interruptible
(
1
);
}
if
(
mux_cnv
==
0
)
{
val
=
ads7871_read_reg16
(
spi
,
REG_LS_BYTE
);
/*result in volts*10000 = (val/8192)*2.5*10000*/
val
=
((
val
>>
2
)
*
25000
)
/
8192
;
val
=
((
val
>>
2
)
*
25000
)
/
8192
;
return
sprintf
(
buf
,
"%d
\n
"
,
val
);
}
else
{
return
-
1
;
...
...
@@ -189,7 +189,7 @@ static int ads7871_probe(struct spi_device *spi)
ads7871_write_reg8
(
spi
,
REG_SER_CONTROL
,
0
);
ads7871_write_reg8
(
spi
,
REG_AD_CONTROL
,
0
);
val
=
(
OSC_OSCR_
bm
|
OSC_OSCE_bm
|
OSC_REFE_bm
|
OSC_BUFE_bm
);
val
=
(
OSC_OSCR_
BM
|
OSC_OSCE_BM
|
OSC_REFE_BM
|
OSC_BUFE_BM
);
ads7871_write_reg8
(
spi
,
REG_OSC_CONTROL
,
val
);
ret
=
ads7871_read_reg8
(
spi
,
REG_OSC_CONTROL
);
...
...
drivers/hwmon/asc7621.c
浏览文件 @
088ce2ac
...
...
@@ -159,12 +159,12 @@ static inline int write_byte(struct i2c_client *client, u8 reg, u8 data)
* and retrieval of like parameters.
*/
#define SETUP_SHOW_
data_param
(d, a) \
#define SETUP_SHOW_
DATA_PARAM
(d, a) \
struct sensor_device_attribute *sda = to_sensor_dev_attr(a); \
struct asc7621_data *data = asc7621_update_device(d); \
struct asc7621_param *param = to_asc7621_param(sda)
#define SETUP_STORE_
data_param
(d, a) \
#define SETUP_STORE_
DATA_PARAM
(d, a) \
struct sensor_device_attribute *sda = to_sensor_dev_attr(a); \
struct i2c_client *client = to_i2c_client(d); \
struct asc7621_data *data = i2c_get_clientdata(client); \
...
...
@@ -177,7 +177,7 @@ static inline int write_byte(struct i2c_client *client, u8 reg, u8 data)
static
ssize_t
show_u8
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
SETUP_SHOW_
data_param
(
dev
,
attr
);
SETUP_SHOW_
DATA_PARAM
(
dev
,
attr
);
return
sprintf
(
buf
,
"%u
\n
"
,
data
->
reg
[
param
->
msb
[
0
]]);
}
...
...
@@ -185,7 +185,7 @@ static ssize_t show_u8(struct device *dev, struct device_attribute *attr,
static
ssize_t
store_u8
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
SETUP_STORE_
data_param
(
dev
,
attr
);
SETUP_STORE_
DATA_PARAM
(
dev
,
attr
);
long
reqval
;
if
(
kstrtol
(
buf
,
10
,
&
reqval
))
...
...
@@ -206,7 +206,7 @@ static ssize_t store_u8(struct device *dev, struct device_attribute *attr,
static
ssize_t
show_bitmask
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
SETUP_SHOW_
data_param
(
dev
,
attr
);
SETUP_SHOW_
DATA_PARAM
(
dev
,
attr
);
return
sprintf
(
buf
,
"%u
\n
"
,
(
data
->
reg
[
param
->
msb
[
0
]]
>>
param
->
...
...
@@ -217,7 +217,7 @@ static ssize_t store_bitmask(struct device *dev,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
SETUP_STORE_
data_param
(
dev
,
attr
);
SETUP_STORE_
DATA_PARAM
(
dev
,
attr
);
long
reqval
;
u8
currval
;
...
...
@@ -246,7 +246,7 @@ static ssize_t store_bitmask(struct device *dev,
static
ssize_t
show_fan16
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
SETUP_SHOW_
data_param
(
dev
,
attr
);
SETUP_SHOW_
DATA_PARAM
(
dev
,
attr
);
u16
regval
;
mutex_lock
(
&
data
->
update_lock
);
...
...
@@ -262,7 +262,7 @@ static ssize_t store_fan16(struct device *dev,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
SETUP_STORE_
data_param
(
dev
,
attr
);
SETUP_STORE_
DATA_PARAM
(
dev
,
attr
);
long
reqval
;
if
(
kstrtol
(
buf
,
10
,
&
reqval
))
...
...
@@ -307,7 +307,7 @@ static int asc7621_in_scaling[] = {
static
ssize_t
show_in10
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
SETUP_SHOW_
data_param
(
dev
,
attr
);
SETUP_SHOW_
DATA_PARAM
(
dev
,
attr
);
u16
regval
;
u8
nr
=
sda
->
index
;
...
...
@@ -325,7 +325,7 @@ static ssize_t show_in10(struct device *dev, struct device_attribute *attr,
static
ssize_t
show_in8
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
SETUP_SHOW_
data_param
(
dev
,
attr
);
SETUP_SHOW_
DATA_PARAM
(
dev
,
attr
);
u8
nr
=
sda
->
index
;
return
sprintf
(
buf
,
"%u
\n
"
,
...
...
@@ -336,7 +336,7 @@ static ssize_t show_in8(struct device *dev, struct device_attribute *attr,
static
ssize_t
store_in8
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
SETUP_STORE_
data_param
(
dev
,
attr
);
SETUP_STORE_
DATA_PARAM
(
dev
,
attr
);
long
reqval
;
u8
nr
=
sda
->
index
;
...
...
@@ -360,7 +360,7 @@ static ssize_t store_in8(struct device *dev, struct device_attribute *attr,
static
ssize_t
show_temp8
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
SETUP_SHOW_
data_param
(
dev
,
attr
);
SETUP_SHOW_
DATA_PARAM
(
dev
,
attr
);
return
sprintf
(
buf
,
"%d
\n
"
,
((
s8
)
data
->
reg
[
param
->
msb
[
0
]])
*
1000
);
}
...
...
@@ -369,7 +369,7 @@ static ssize_t store_temp8(struct device *dev,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
SETUP_STORE_
data_param
(
dev
,
attr
);
SETUP_STORE_
DATA_PARAM
(
dev
,
attr
);
long
reqval
;
s8
temp
;
...
...
@@ -397,7 +397,7 @@ static ssize_t store_temp8(struct device *dev,
static
ssize_t
show_temp10
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
SETUP_SHOW_
data_param
(
dev
,
attr
);
SETUP_SHOW_
DATA_PARAM
(
dev
,
attr
);
u8
msb
,
lsb
;
int
temp
;
...
...
@@ -414,7 +414,7 @@ static ssize_t show_temp10(struct device *dev,
static
ssize_t
show_temp62
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
SETUP_SHOW_
data_param
(
dev
,
attr
);
SETUP_SHOW_
DATA_PARAM
(
dev
,
attr
);
u8
regval
=
data
->
reg
[
param
->
msb
[
0
]];
int
temp
=
((
s8
)
(
regval
&
0xfc
)
*
1000
)
+
((
regval
&
0x03
)
*
250
);
...
...
@@ -425,7 +425,7 @@ static ssize_t store_temp62(struct device *dev,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
SETUP_STORE_
data_param
(
dev
,
attr
);
SETUP_STORE_
DATA_PARAM
(
dev
,
attr
);
long
reqval
,
i
,
f
;
s8
temp
;
...
...
@@ -459,7 +459,7 @@ static u32 asc7621_range_map[] = {
static
ssize_t
show_ap2_temp
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
SETUP_SHOW_
data_param
(
dev
,
attr
);
SETUP_SHOW_
DATA_PARAM
(
dev
,
attr
);
long
auto_point1
;
u8
regval
;
int
temp
;
...
...
@@ -479,7 +479,7 @@ static ssize_t store_ap2_temp(struct device *dev,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
SETUP_STORE_
data_param
(
dev
,
attr
);
SETUP_STORE_
DATA_PARAM
(
dev
,
attr
);
long
reqval
,
auto_point1
;
int
i
;
u8
currval
,
newval
=
0
;
...
...
@@ -510,7 +510,7 @@ static ssize_t store_ap2_temp(struct device *dev,
static
ssize_t
show_pwm_ac
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
SETUP_SHOW_
data_param
(
dev
,
attr
);
SETUP_SHOW_
DATA_PARAM
(
dev
,
attr
);
u8
config
,
altbit
,
regval
;
u8
map
[]
=
{
0x01
,
0x02
,
0x04
,
0x1f
,
0x00
,
0x06
,
0x07
,
0x10
,
...
...
@@ -530,7 +530,7 @@ static ssize_t store_pwm_ac(struct device *dev,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
SETUP_STORE_
data_param
(
dev
,
attr
);
SETUP_STORE_
DATA_PARAM
(
dev
,
attr
);
unsigned
long
reqval
;
u8
currval
,
config
,
altbit
,
newval
;
u16
map
[]
=
{
...
...
@@ -569,7 +569,7 @@ static ssize_t store_pwm_ac(struct device *dev,
static
ssize_t
show_pwm_enable
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
SETUP_SHOW_
data_param
(
dev
,
attr
);
SETUP_SHOW_
DATA_PARAM
(
dev
,
attr
);
u8
config
,
altbit
,
minoff
,
val
,
newval
;
mutex_lock
(
&
data
->
update_lock
);
...
...
@@ -599,7 +599,7 @@ static ssize_t store_pwm_enable(struct device *dev,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
SETUP_STORE_
data_param
(
dev
,
attr
);
SETUP_STORE_
DATA_PARAM
(
dev
,
attr
);
long
reqval
;
u8
currval
,
config
,
altbit
,
newval
,
minoff
=
255
;
...
...
@@ -659,7 +659,7 @@ static u32 asc7621_pwm_freq_map[] = {
static
ssize_t
show_pwm_freq
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
SETUP_SHOW_
data_param
(
dev
,
attr
);
SETUP_SHOW_
DATA_PARAM
(
dev
,
attr
);
u8
regval
=
(
data
->
reg
[
param
->
msb
[
0
]]
>>
param
->
shift
[
0
])
&
param
->
mask
[
0
];
...
...
@@ -672,7 +672,7 @@ static ssize_t store_pwm_freq(struct device *dev,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
SETUP_STORE_
data_param
(
dev
,
attr
);
SETUP_STORE_
DATA_PARAM
(
dev
,
attr
);
unsigned
long
reqval
;
u8
currval
,
newval
=
255
;
int
i
;
...
...
@@ -707,7 +707,7 @@ static u32 asc7621_pwm_auto_spinup_map[] = {
static
ssize_t
show_pwm_ast
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
SETUP_SHOW_
data_param
(
dev
,
attr
);
SETUP_SHOW_
DATA_PARAM
(
dev
,
attr
);
u8
regval
=
(
data
->
reg
[
param
->
msb
[
0
]]
>>
param
->
shift
[
0
])
&
param
->
mask
[
0
];
...
...
@@ -721,7 +721,7 @@ static ssize_t store_pwm_ast(struct device *dev,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
SETUP_STORE_
data_param
(
dev
,
attr
);
SETUP_STORE_
DATA_PARAM
(
dev
,
attr
);
long
reqval
;
u8
currval
,
newval
=
255
;
u32
i
;
...
...
@@ -756,7 +756,7 @@ static u32 asc7621_temp_smoothing_time_map[] = {
static
ssize_t
show_temp_st
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
SETUP_SHOW_
data_param
(
dev
,
attr
);
SETUP_SHOW_
DATA_PARAM
(
dev
,
attr
);
u8
regval
=
(
data
->
reg
[
param
->
msb
[
0
]]
>>
param
->
shift
[
0
])
&
param
->
mask
[
0
];
regval
=
clamp_val
(
regval
,
0
,
7
);
...
...
@@ -768,7 +768,7 @@ static ssize_t store_temp_st(struct device *dev,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
SETUP_STORE_
data_param
(
dev
,
attr
);
SETUP_STORE_
DATA_PARAM
(
dev
,
attr
);
long
reqval
;
u8
currval
,
newval
=
255
;
u32
i
;
...
...
drivers/hwmon/da9052-hwmon.c
浏览文件 @
088ce2ac
...
...
@@ -43,19 +43,19 @@ static const char * const input_names[] = {
};
/* Conversion function for VDDOUT and VBAT */
static
inline
int
volt_reg_to_m
V
(
int
value
)
static
inline
int
volt_reg_to_m
v
(
int
value
)
{
return
DIV_ROUND_CLOSEST
(
value
*
1000
,
512
)
+
2500
;
}
/* Conversion function for ADC channels 4, 5 and 6 */
static
inline
int
input_reg_to_m
V
(
int
value
)
static
inline
int
input_reg_to_m
v
(
int
value
)
{
return
DIV_ROUND_CLOSEST
(
value
*
2500
,
1023
);
}
/* Conversion function for VBBAT */
static
inline
int
vbbat_reg_to_m
V
(
int
value
)
static
inline
int
vbbat_reg_to_m
v
(
int
value
)
{
return
DIV_ROUND_CLOSEST
(
value
*
2500
,
512
);
}
...
...
@@ -96,7 +96,7 @@ static ssize_t da9052_read_vddout(struct device *dev,
goto
hwmon_err
;
mutex_unlock
(
&
hwmon
->
hwmon_lock
);
return
sprintf
(
buf
,
"%d
\n
"
,
volt_reg_to_m
V
(
vdd
));
return
sprintf
(
buf
,
"%d
\n
"
,
volt_reg_to_m
v
(
vdd
));
hwmon_err_release:
da9052_disable_vddout_channel
(
hwmon
->
da9052
);
...
...
@@ -137,7 +137,7 @@ static ssize_t da9052_read_vbat(struct device *dev,
if
(
ret
<
0
)
return
ret
;
return
sprintf
(
buf
,
"%d
\n
"
,
volt_reg_to_m
V
(
ret
));
return
sprintf
(
buf
,
"%d
\n
"
,
volt_reg_to_m
v
(
ret
));
}
static
ssize_t
da9052_read_misc_channel
(
struct
device
*
dev
,
...
...
@@ -152,7 +152,7 @@ static ssize_t da9052_read_misc_channel(struct device *dev,
if
(
ret
<
0
)
return
ret
;
return
sprintf
(
buf
,
"%d
\n
"
,
input_reg_to_m
V
(
ret
));
return
sprintf
(
buf
,
"%d
\n
"
,
input_reg_to_m
v
(
ret
));
}
static
ssize_t
da9052_read_tjunc
(
struct
device
*
dev
,
...
...
@@ -187,7 +187,7 @@ static ssize_t da9052_read_vbbat(struct device *dev,
if
(
ret
<
0
)
return
ret
;
return
sprintf
(
buf
,
"%d
\n
"
,
vbbat_reg_to_m
V
(
ret
));
return
sprintf
(
buf
,
"%d
\n
"
,
vbbat_reg_to_m
v
(
ret
));
}
static
ssize_t
da9052_hwmon_show_name
(
struct
device
*
dev
,
...
...
drivers/hwmon/da9055-hwmon.c
浏览文件 @
088ce2ac
...
...
@@ -119,7 +119,7 @@ static irqreturn_t da9055_auxadc_irq(int irq, void *irq_data)
}
/* Conversion function for VSYS and ADCINx */
static
inline
int
volt_reg_to_m
V
(
int
value
,
int
channel
)
static
inline
int
volt_reg_to_m
v
(
int
value
,
int
channel
)
{
if
(
channel
==
DA9055_ADC_VSYS
)
return
DIV_ROUND_CLOSEST
(
value
*
1000
,
DA9055_VSYS_DIV
)
+
2500
;
...
...
@@ -168,7 +168,7 @@ static ssize_t da9055_read_auto_ch(struct device *dev,
mutex_unlock
(
&
hwmon
->
hwmon_lock
);
return
sprintf
(
buf
,
"%d
\n
"
,
volt_reg_to_m
V
(
adc
,
channel
));
return
sprintf
(
buf
,
"%d
\n
"
,
volt_reg_to_m
v
(
adc
,
channel
));
hwmon_err_release:
da9055_disable_auto_mode
(
hwmon
->
da9055
,
channel
);
...
...
drivers/hwmon/it87.c
浏览文件 @
088ce2ac
...
...
@@ -1778,7 +1778,7 @@ static int __init it87_find(unsigned short *address,
superio_select
(
5
);
sio_data
->
beep_pin
=
superio_inb
(
IT87_SIO_BEEP_PIN_REG
)
&
0x3f
;
}
else
if
(
sio_data
->
type
==
it8783
)
{
int
reg25
,
reg27
,
reg2
A
,
reg2C
,
regEF
;
int
reg25
,
reg27
,
reg2
a
,
reg2c
,
regef
;
sio_data
->
skip_vid
=
1
;
/* No VID */
...
...
@@ -1786,15 +1786,15 @@ static int __init it87_find(unsigned short *address,
reg25
=
superio_inb
(
IT87_SIO_GPIO1_REG
);
reg27
=
superio_inb
(
IT87_SIO_GPIO3_REG
);
reg2
A
=
superio_inb
(
IT87_SIO_PINX1_REG
);
reg2
C
=
superio_inb
(
IT87_SIO_PINX2_REG
);
reg
EF
=
superio_inb
(
IT87_SIO_SPI_REG
);
reg2
a
=
superio_inb
(
IT87_SIO_PINX1_REG
);
reg2
c
=
superio_inb
(
IT87_SIO_PINX2_REG
);
reg
ef
=
superio_inb
(
IT87_SIO_SPI_REG
);
/* Check if fan3 is there or not */
if
((
reg27
&
(
1
<<
0
))
||
!
(
reg2
C
&
(
1
<<
2
)))
if
((
reg27
&
(
1
<<
0
))
||
!
(
reg2
c
&
(
1
<<
2
)))
sio_data
->
skip_fan
|=
(
1
<<
2
);
if
((
reg25
&
(
1
<<
4
))
||
(
!
(
reg2
A
&
(
1
<<
1
))
&&
(
regEF
&
(
1
<<
0
))))
||
(
!
(
reg2
a
&
(
1
<<
1
))
&&
(
regef
&
(
1
<<
0
))))
sio_data
->
skip_pwm
|=
(
1
<<
2
);
/* Check if fan2 is there or not */
...
...
@@ -1804,7 +1804,7 @@ static int __init it87_find(unsigned short *address,
sio_data
->
skip_pwm
|=
(
1
<<
1
);
/* VIN5 */
if
((
reg27
&
(
1
<<
0
))
||
(
reg2
C
&
(
1
<<
2
)))
if
((
reg27
&
(
1
<<
0
))
||
(
reg2
c
&
(
1
<<
2
)))
sio_data
->
skip_in
|=
(
1
<<
5
);
/* No VIN5 */
/* VIN6 */
...
...
@@ -1829,18 +1829,18 @@ static int __init it87_find(unsigned short *address,
* not the case, and ask the user to report if the
* resulting voltage is sane.
*/
if
(
!
(
reg2
C
&
(
1
<<
1
)))
{
reg2
C
|=
(
1
<<
1
);
superio_outb
(
IT87_SIO_PINX2_REG
,
reg2
C
);
if
(
!
(
reg2
c
&
(
1
<<
1
)))
{
reg2
c
|=
(
1
<<
1
);
superio_outb
(
IT87_SIO_PINX2_REG
,
reg2
c
);
pr_notice
(
"Routing internal VCCH5V to in7.
\n
"
);
}
pr_notice
(
"in7 routed to internal voltage divider, with external pin disabled.
\n
"
);
pr_notice
(
"Please report if it displays a reasonable voltage.
\n
"
);
}
if
(
reg2
C
&
(
1
<<
0
))
if
(
reg2
c
&
(
1
<<
0
))
sio_data
->
internal
|=
(
1
<<
0
);
if
(
reg2
C
&
(
1
<<
1
))
if
(
reg2
c
&
(
1
<<
1
))
sio_data
->
internal
|=
(
1
<<
1
);
sio_data
->
beep_pin
=
superio_inb
(
IT87_SIO_BEEP_PIN_REG
)
&
0x3f
;
...
...
drivers/hwmon/lm93.c
浏览文件 @
088ce2ac
...
...
@@ -354,12 +354,12 @@ static const unsigned long lm93_vin_val_max[16] = {
static
unsigned
LM93_IN_FROM_REG
(
int
nr
,
u8
reg
)
{
const
long
u
V
_max
=
lm93_vin_val_max
[
nr
]
*
1000
;
const
long
u
V
_min
=
lm93_vin_val_min
[
nr
]
*
1000
;
const
long
u
v
_max
=
lm93_vin_val_max
[
nr
]
*
1000
;
const
long
u
v
_min
=
lm93_vin_val_min
[
nr
]
*
1000
;
const
long
slope
=
(
u
V_max
-
uV
_min
)
/
const
long
slope
=
(
u
v_max
-
uv
_min
)
/
(
lm93_vin_reg_max
[
nr
]
-
lm93_vin_reg_min
[
nr
]);
const
long
intercept
=
u
V
_min
-
slope
*
lm93_vin_reg_min
[
nr
];
const
long
intercept
=
u
v
_min
-
slope
*
lm93_vin_reg_min
[
nr
];
return
(
slope
*
reg
+
intercept
+
500
)
/
1000
;
}
...
...
@@ -371,20 +371,20 @@ static unsigned LM93_IN_FROM_REG(int nr, u8 reg)
static
u8
LM93_IN_TO_REG
(
int
nr
,
unsigned
val
)
{
/* range limit */
const
long
m
V
=
clamp_val
(
val
,
const
long
m
v
=
clamp_val
(
val
,
lm93_vin_val_min
[
nr
],
lm93_vin_val_max
[
nr
]);
/* try not to lose too much precision here */
const
long
u
V
=
mV
*
1000
;
const
long
u
V
_max
=
lm93_vin_val_max
[
nr
]
*
1000
;
const
long
u
V
_min
=
lm93_vin_val_min
[
nr
]
*
1000
;
const
long
u
v
=
mv
*
1000
;
const
long
u
v
_max
=
lm93_vin_val_max
[
nr
]
*
1000
;
const
long
u
v
_min
=
lm93_vin_val_min
[
nr
]
*
1000
;
/* convert */
const
long
slope
=
(
u
V_max
-
uV
_min
)
/
const
long
slope
=
(
u
v_max
-
uv
_min
)
/
(
lm93_vin_reg_max
[
nr
]
-
lm93_vin_reg_min
[
nr
]);
const
long
intercept
=
u
V
_min
-
slope
*
lm93_vin_reg_min
[
nr
];
const
long
intercept
=
u
v
_min
-
slope
*
lm93_vin_reg_min
[
nr
];
u8
result
=
((
u
V
-
intercept
+
(
slope
/
2
))
/
slope
);
u8
result
=
((
u
v
-
intercept
+
(
slope
/
2
))
/
slope
);
result
=
clamp_val
(
result
,
lm93_vin_reg_min
[
nr
],
lm93_vin_reg_max
[
nr
]);
return
result
;
...
...
@@ -393,10 +393,10 @@ static u8 LM93_IN_TO_REG(int nr, unsigned val)
/* vid in mV, upper == 0 indicates low limit, otherwise upper limit */
static
unsigned
LM93_IN_REL_FROM_REG
(
u8
reg
,
int
upper
,
int
vid
)
{
const
long
u
V
_offset
=
upper
?
(((
reg
>>
4
&
0x0f
)
+
1
)
*
12500
)
:
const
long
u
v
_offset
=
upper
?
(((
reg
>>
4
&
0x0f
)
+
1
)
*
12500
)
:
(((
reg
>>
0
&
0x0f
)
+
1
)
*
-
25000
);
const
long
u
V
_vid
=
vid
*
1000
;
return
(
u
V_vid
+
uV
_offset
+
5000
)
/
10000
;
const
long
u
v
_vid
=
vid
*
1000
;
return
(
u
v_vid
+
uv
_offset
+
5000
)
/
10000
;
}
#define LM93_IN_MIN_FROM_REG(reg, vid) LM93_IN_REL_FROM_REG((reg), 0, (vid))
...
...
@@ -409,13 +409,13 @@ static unsigned LM93_IN_REL_FROM_REG(u8 reg, int upper, int vid)
*/
static
u8
LM93_IN_REL_TO_REG
(
unsigned
val
,
int
upper
,
int
vid
)
{
long
u
V
_offset
=
vid
*
1000
-
val
*
10000
;
long
u
v
_offset
=
vid
*
1000
-
val
*
10000
;
if
(
upper
)
{
u
V_offset
=
clamp_val
(
uV
_offset
,
12500
,
200000
);
return
(
u8
)((
u
V
_offset
/
12500
-
1
)
<<
4
);
u
v_offset
=
clamp_val
(
uv
_offset
,
12500
,
200000
);
return
(
u8
)((
u
v
_offset
/
12500
-
1
)
<<
4
);
}
else
{
u
V_offset
=
clamp_val
(
uV
_offset
,
-
400000
,
-
25000
);
return
(
u8
)((
u
V
_offset
/
-
25000
-
1
)
<<
0
);
u
v_offset
=
clamp_val
(
uv
_offset
,
-
400000
,
-
25000
);
return
(
u8
)((
u
v
_offset
/
-
25000
-
1
)
<<
0
);
}
}
...
...
drivers/hwmon/ntc_thermistor.c
浏览文件 @
088ce2ac
...
...
@@ -40,7 +40,7 @@
#include <linux/hwmon-sysfs.h>
struct
ntc_compensation
{
int
temp_
C
;
int
temp_
c
;
unsigned
int
ohm
;
};
...
...
@@ -60,76 +60,76 @@ static const struct platform_device_id ntc_thermistor_id[] = {
* Thermistors Datasheet
*/
static
const
struct
ntc_compensation
ncpXXwb473
[]
=
{
{
.
temp_
C
=
-
40
,
.
ohm
=
1747920
},
{
.
temp_
C
=
-
35
,
.
ohm
=
1245428
},
{
.
temp_
C
=
-
30
,
.
ohm
=
898485
},
{
.
temp_
C
=
-
25
,
.
ohm
=
655802
},
{
.
temp_
C
=
-
20
,
.
ohm
=
483954
},
{
.
temp_
C
=
-
15
,
.
ohm
=
360850
},
{
.
temp_
C
=
-
10
,
.
ohm
=
271697
},
{
.
temp_
C
=
-
5
,
.
ohm
=
206463
},
{
.
temp_
C
=
0
,
.
ohm
=
158214
},
{
.
temp_
C
=
5
,
.
ohm
=
122259
},
{
.
temp_
C
=
10
,
.
ohm
=
95227
},
{
.
temp_
C
=
15
,
.
ohm
=
74730
},
{
.
temp_
C
=
20
,
.
ohm
=
59065
},
{
.
temp_
C
=
25
,
.
ohm
=
47000
},
{
.
temp_
C
=
30
,
.
ohm
=
37643
},
{
.
temp_
C
=
35
,
.
ohm
=
30334
},
{
.
temp_
C
=
40
,
.
ohm
=
24591
},
{
.
temp_
C
=
45
,
.
ohm
=
20048
},
{
.
temp_
C
=
50
,
.
ohm
=
16433
},
{
.
temp_
C
=
55
,
.
ohm
=
13539
},
{
.
temp_
C
=
60
,
.
ohm
=
11209
},
{
.
temp_
C
=
65
,
.
ohm
=
9328
},
{
.
temp_
C
=
70
,
.
ohm
=
7798
},
{
.
temp_
C
=
75
,
.
ohm
=
6544
},
{
.
temp_
C
=
80
,
.
ohm
=
5518
},
{
.
temp_
C
=
85
,
.
ohm
=
4674
},
{
.
temp_
C
=
90
,
.
ohm
=
3972
},
{
.
temp_
C
=
95
,
.
ohm
=
3388
},
{
.
temp_
C
=
100
,
.
ohm
=
2902
},
{
.
temp_
C
=
105
,
.
ohm
=
2494
},
{
.
temp_
C
=
110
,
.
ohm
=
2150
},
{
.
temp_
C
=
115
,
.
ohm
=
1860
},
{
.
temp_
C
=
120
,
.
ohm
=
1615
},
{
.
temp_
C
=
125
,
.
ohm
=
1406
},
{
.
temp_
c
=
-
40
,
.
ohm
=
1747920
},
{
.
temp_
c
=
-
35
,
.
ohm
=
1245428
},
{
.
temp_
c
=
-
30
,
.
ohm
=
898485
},
{
.
temp_
c
=
-
25
,
.
ohm
=
655802
},
{
.
temp_
c
=
-
20
,
.
ohm
=
483954
},
{
.
temp_
c
=
-
15
,
.
ohm
=
360850
},
{
.
temp_
c
=
-
10
,
.
ohm
=
271697
},
{
.
temp_
c
=
-
5
,
.
ohm
=
206463
},
{
.
temp_
c
=
0
,
.
ohm
=
158214
},
{
.
temp_
c
=
5
,
.
ohm
=
122259
},
{
.
temp_
c
=
10
,
.
ohm
=
95227
},
{
.
temp_
c
=
15
,
.
ohm
=
74730
},
{
.
temp_
c
=
20
,
.
ohm
=
59065
},
{
.
temp_
c
=
25
,
.
ohm
=
47000
},
{
.
temp_
c
=
30
,
.
ohm
=
37643
},
{
.
temp_
c
=
35
,
.
ohm
=
30334
},
{
.
temp_
c
=
40
,
.
ohm
=
24591
},
{
.
temp_
c
=
45
,
.
ohm
=
20048
},
{
.
temp_
c
=
50
,
.
ohm
=
16433
},
{
.
temp_
c
=
55
,
.
ohm
=
13539
},
{
.
temp_
c
=
60
,
.
ohm
=
11209
},
{
.
temp_
c
=
65
,
.
ohm
=
9328
},
{
.
temp_
c
=
70
,
.
ohm
=
7798
},
{
.
temp_
c
=
75
,
.
ohm
=
6544
},
{
.
temp_
c
=
80
,
.
ohm
=
5518
},
{
.
temp_
c
=
85
,
.
ohm
=
4674
},
{
.
temp_
c
=
90
,
.
ohm
=
3972
},
{
.
temp_
c
=
95
,
.
ohm
=
3388
},
{
.
temp_
c
=
100
,
.
ohm
=
2902
},
{
.
temp_
c
=
105
,
.
ohm
=
2494
},
{
.
temp_
c
=
110
,
.
ohm
=
2150
},
{
.
temp_
c
=
115
,
.
ohm
=
1860
},
{
.
temp_
c
=
120
,
.
ohm
=
1615
},
{
.
temp_
c
=
125
,
.
ohm
=
1406
},
};
static
const
struct
ntc_compensation
ncpXXwl333
[]
=
{
{
.
temp_
C
=
-
40
,
.
ohm
=
1610154
},
{
.
temp_
C
=
-
35
,
.
ohm
=
1130850
},
{
.
temp_
C
=
-
30
,
.
ohm
=
802609
},
{
.
temp_
C
=
-
25
,
.
ohm
=
575385
},
{
.
temp_
C
=
-
20
,
.
ohm
=
416464
},
{
.
temp_
C
=
-
15
,
.
ohm
=
304219
},
{
.
temp_
C
=
-
10
,
.
ohm
=
224193
},
{
.
temp_
C
=
-
5
,
.
ohm
=
166623
},
{
.
temp_
C
=
0
,
.
ohm
=
124850
},
{
.
temp_
C
=
5
,
.
ohm
=
94287
},
{
.
temp_
C
=
10
,
.
ohm
=
71747
},
{
.
temp_
C
=
15
,
.
ohm
=
54996
},
{
.
temp_
C
=
20
,
.
ohm
=
42455
},
{
.
temp_
C
=
25
,
.
ohm
=
33000
},
{
.
temp_
C
=
30
,
.
ohm
=
25822
},
{
.
temp_
C
=
35
,
.
ohm
=
20335
},
{
.
temp_
C
=
40
,
.
ohm
=
16115
},
{
.
temp_
C
=
45
,
.
ohm
=
12849
},
{
.
temp_
C
=
50
,
.
ohm
=
10306
},
{
.
temp_
C
=
55
,
.
ohm
=
8314
},
{
.
temp_
C
=
60
,
.
ohm
=
6746
},
{
.
temp_
C
=
65
,
.
ohm
=
5503
},
{
.
temp_
C
=
70
,
.
ohm
=
4513
},
{
.
temp_
C
=
75
,
.
ohm
=
3721
},
{
.
temp_
C
=
80
,
.
ohm
=
3084
},
{
.
temp_
C
=
85
,
.
ohm
=
2569
},
{
.
temp_
C
=
90
,
.
ohm
=
2151
},
{
.
temp_
C
=
95
,
.
ohm
=
1809
},
{
.
temp_
C
=
100
,
.
ohm
=
1529
},
{
.
temp_
C
=
105
,
.
ohm
=
1299
},
{
.
temp_
C
=
110
,
.
ohm
=
1108
},
{
.
temp_
C
=
115
,
.
ohm
=
949
},
{
.
temp_
C
=
120
,
.
ohm
=
817
},
{
.
temp_
C
=
125
,
.
ohm
=
707
},
{
.
temp_
c
=
-
40
,
.
ohm
=
1610154
},
{
.
temp_
c
=
-
35
,
.
ohm
=
1130850
},
{
.
temp_
c
=
-
30
,
.
ohm
=
802609
},
{
.
temp_
c
=
-
25
,
.
ohm
=
575385
},
{
.
temp_
c
=
-
20
,
.
ohm
=
416464
},
{
.
temp_
c
=
-
15
,
.
ohm
=
304219
},
{
.
temp_
c
=
-
10
,
.
ohm
=
224193
},
{
.
temp_
c
=
-
5
,
.
ohm
=
166623
},
{
.
temp_
c
=
0
,
.
ohm
=
124850
},
{
.
temp_
c
=
5
,
.
ohm
=
94287
},
{
.
temp_
c
=
10
,
.
ohm
=
71747
},
{
.
temp_
c
=
15
,
.
ohm
=
54996
},
{
.
temp_
c
=
20
,
.
ohm
=
42455
},
{
.
temp_
c
=
25
,
.
ohm
=
33000
},
{
.
temp_
c
=
30
,
.
ohm
=
25822
},
{
.
temp_
c
=
35
,
.
ohm
=
20335
},
{
.
temp_
c
=
40
,
.
ohm
=
16115
},
{
.
temp_
c
=
45
,
.
ohm
=
12849
},
{
.
temp_
c
=
50
,
.
ohm
=
10306
},
{
.
temp_
c
=
55
,
.
ohm
=
8314
},
{
.
temp_
c
=
60
,
.
ohm
=
6746
},
{
.
temp_
c
=
65
,
.
ohm
=
5503
},
{
.
temp_
c
=
70
,
.
ohm
=
4513
},
{
.
temp_
c
=
75
,
.
ohm
=
3721
},
{
.
temp_
c
=
80
,
.
ohm
=
3084
},
{
.
temp_
c
=
85
,
.
ohm
=
2569
},
{
.
temp_
c
=
90
,
.
ohm
=
2151
},
{
.
temp_
c
=
95
,
.
ohm
=
1809
},
{
.
temp_
c
=
100
,
.
ohm
=
1529
},
{
.
temp_
c
=
105
,
.
ohm
=
1299
},
{
.
temp_
c
=
110
,
.
ohm
=
1108
},
{
.
temp_
c
=
115
,
.
ohm
=
949
},
{
.
temp_
c
=
120
,
.
ohm
=
817
},
{
.
temp_
c
=
125
,
.
ohm
=
707
},
};
struct
ntc_data
{
...
...
@@ -155,7 +155,7 @@ static int ntc_adc_iio_read(struct ntc_thermistor_platform_data *pdata)
}
/* unit: mV */
result
=
pdata
->
pullup_u
V
*
val
;
result
=
pdata
->
pullup_u
v
*
val
;
result
>>=
12
;
return
result
;
...
...
@@ -194,7 +194,7 @@ ntc_thermistor_parse_dt(struct platform_device *pdev)
if
(
IS_ERR
(
chan
))
return
ERR_CAST
(
chan
);
if
(
of_property_read_u32
(
np
,
"pullup-uv"
,
&
pdata
->
pullup_u
V
))
if
(
of_property_read_u32
(
np
,
"pullup-uv"
,
&
pdata
->
pullup_u
v
))
return
ERR_PTR
(
-
ENODEV
);
if
(
of_property_read_u32
(
np
,
"pullup-ohm"
,
&
pdata
->
pullup_ohm
))
return
ERR_PTR
(
-
ENODEV
);
...
...
@@ -207,7 +207,7 @@ ntc_thermistor_parse_dt(struct platform_device *pdev)
pdata
->
connect
=
NTC_CONNECTED_GROUND
;
pdata
->
chan
=
chan
;
pdata
->
read_u
V
=
ntc_adc_iio_read
;
pdata
->
read_u
v
=
ntc_adc_iio_read
;
return
pdata
;
}
...
...
@@ -236,37 +236,37 @@ static inline u64 div64_u64_safe(u64 dividend, u64 divisor)
return
div64_u64
(
dividend
,
divisor
);
}
static
int
get_ohm_of_thermistor
(
struct
ntc_data
*
data
,
unsigned
int
u
V
)
static
int
get_ohm_of_thermistor
(
struct
ntc_data
*
data
,
unsigned
int
u
v
)
{
struct
ntc_thermistor_platform_data
*
pdata
=
data
->
pdata
;
u64
m
V
=
uV
/
1000
;
u64
pm
V
=
pdata
->
pullup_uV
/
1000
;
u64
N
,
puO
,
pdO
;
pu
O
=
pdata
->
pullup_ohm
;
pd
O
=
pdata
->
pulldown_ohm
;
u64
m
v
=
uv
/
1000
;
u64
pm
v
=
pdata
->
pullup_uv
/
1000
;
u64
n
,
puo
,
pdo
;
pu
o
=
pdata
->
pullup_ohm
;
pd
o
=
pdata
->
pulldown_ohm
;
if
(
m
V
==
0
)
{
if
(
m
v
==
0
)
{
if
(
pdata
->
connect
==
NTC_CONNECTED_POSITIVE
)
return
INT_MAX
;
return
0
;
}
if
(
m
V
>=
pmV
)
if
(
m
v
>=
pmv
)
return
(
pdata
->
connect
==
NTC_CONNECTED_POSITIVE
)
?
0
:
INT_MAX
;
if
(
pdata
->
connect
==
NTC_CONNECTED_POSITIVE
&&
pu
O
==
0
)
N
=
div64_u64_safe
(
pdO
*
(
pmV
-
mV
),
mV
);
else
if
(
pdata
->
connect
==
NTC_CONNECTED_GROUND
&&
pd
O
==
0
)
N
=
div64_u64_safe
(
puO
*
mV
,
pmV
-
mV
);
if
(
pdata
->
connect
==
NTC_CONNECTED_POSITIVE
&&
pu
o
==
0
)
n
=
div64_u64_safe
(
pdo
*
(
pmv
-
mv
),
mv
);
else
if
(
pdata
->
connect
==
NTC_CONNECTED_GROUND
&&
pd
o
==
0
)
n
=
div64_u64_safe
(
puo
*
mv
,
pmv
-
mv
);
else
if
(
pdata
->
connect
==
NTC_CONNECTED_POSITIVE
)
N
=
div64_u64_safe
(
pdO
*
puO
*
(
pmV
-
mV
),
pu
O
*
mV
-
pdO
*
(
pmV
-
mV
));
n
=
div64_u64_safe
(
pdo
*
puo
*
(
pmv
-
mv
),
pu
o
*
mv
-
pdo
*
(
pmv
-
mv
));
else
N
=
div64_u64_safe
(
pdO
*
puO
*
mV
,
pdO
*
(
pmV
-
mV
)
-
puO
*
mV
);
n
=
div64_u64_safe
(
pdo
*
puo
*
mv
,
pdo
*
(
pmv
-
mv
)
-
puo
*
mv
);
if
(
N
>
INT_MAX
)
N
=
INT_MAX
;
return
N
;
if
(
n
>
INT_MAX
)
n
=
INT_MAX
;
return
n
;
}
static
void
lookup_comp
(
struct
ntc_data
*
data
,
unsigned
int
ohm
,
...
...
@@ -335,7 +335,7 @@ static void lookup_comp(struct ntc_data *data, unsigned int ohm,
*
i_high
=
end
-
1
;
}
static
int
get_temp_m
C
(
struct
ntc_data
*
data
,
unsigned
int
ohm
)
static
int
get_temp_m
c
(
struct
ntc_data
*
data
,
unsigned
int
ohm
)
{
int
low
,
high
;
int
temp
;
...
...
@@ -343,10 +343,10 @@ static int get_temp_mC(struct ntc_data *data, unsigned int ohm)
lookup_comp
(
data
,
ohm
,
&
low
,
&
high
);
if
(
low
==
high
)
{
/* Unable to use linear approximation */
temp
=
data
->
comp
[
low
].
temp_
C
*
1000
;
temp
=
data
->
comp
[
low
].
temp_
c
*
1000
;
}
else
{
temp
=
data
->
comp
[
low
].
temp_
C
*
1000
+
((
data
->
comp
[
high
].
temp_
C
-
data
->
comp
[
low
].
temp_C
)
*
temp
=
data
->
comp
[
low
].
temp_
c
*
1000
+
((
data
->
comp
[
high
].
temp_
c
-
data
->
comp
[
low
].
temp_c
)
*
1000
*
((
int
)
ohm
-
(
int
)
data
->
comp
[
low
].
ohm
))
/
((
int
)
data
->
comp
[
high
].
ohm
-
(
int
)
data
->
comp
[
low
].
ohm
);
}
...
...
@@ -355,16 +355,16 @@ static int get_temp_mC(struct ntc_data *data, unsigned int ohm)
static
int
ntc_thermistor_get_ohm
(
struct
ntc_data
*
data
)
{
int
read_u
V
;
int
read_u
v
;
if
(
data
->
pdata
->
read_ohm
)
return
data
->
pdata
->
read_ohm
();
if
(
data
->
pdata
->
read_u
V
)
{
read_u
V
=
data
->
pdata
->
read_uV
(
data
->
pdata
);
if
(
read_u
V
<
0
)
return
read_u
V
;
return
get_ohm_of_thermistor
(
data
,
read_u
V
);
if
(
data
->
pdata
->
read_u
v
)
{
read_u
v
=
data
->
pdata
->
read_uv
(
data
->
pdata
);
if
(
read_u
v
<
0
)
return
read_u
v
;
return
get_ohm_of_thermistor
(
data
,
read_u
v
);
}
return
-
EINVAL
;
}
...
...
@@ -393,7 +393,7 @@ static ssize_t ntc_show_temp(struct device *dev,
if
(
ohm
<
0
)
return
ohm
;
return
sprintf
(
buf
,
"%d
\n
"
,
get_temp_m
C
(
data
,
ohm
));
return
sprintf
(
buf
,
"%d
\n
"
,
get_temp_m
c
(
data
,
ohm
));
}
static
SENSOR_DEVICE_ATTR
(
temp1_type
,
S_IRUGO
,
ntc_show_type
,
NULL
,
0
);
...
...
@@ -432,19 +432,19 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
}
/* Either one of the two is required. */
if
(
!
pdata
->
read_u
V
&&
!
pdata
->
read_ohm
)
{
if
(
!
pdata
->
read_u
v
&&
!
pdata
->
read_ohm
)
{
dev_err
(
&
pdev
->
dev
,
"Both read_u
V
and read_ohm missing. Need either one of the two.
\n
"
);
"Both read_u
v
and read_ohm missing. Need either one of the two.
\n
"
);
return
-
EINVAL
;
}
if
(
pdata
->
read_u
V
&&
pdata
->
read_ohm
)
{
if
(
pdata
->
read_u
v
&&
pdata
->
read_ohm
)
{
dev_warn
(
&
pdev
->
dev
,
"Only one of read_u
V and read_ohm is needed; ignoring read_uV
.
\n
"
);
pdata
->
read_u
V
=
NULL
;
"Only one of read_u
v and read_ohm is needed; ignoring read_uv
.
\n
"
);
pdata
->
read_u
v
=
NULL
;
}
if
(
pdata
->
read_u
V
&&
(
pdata
->
pullup_uV
==
0
||
if
(
pdata
->
read_u
v
&&
(
pdata
->
pullup_uv
==
0
||
(
pdata
->
pullup_ohm
==
0
&&
pdata
->
connect
==
NTC_CONNECTED_GROUND
)
||
(
pdata
->
pulldown_ohm
==
0
&&
pdata
->
connect
==
...
...
@@ -452,7 +452,7 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
(
pdata
->
connect
!=
NTC_CONNECTED_POSITIVE
&&
pdata
->
connect
!=
NTC_CONNECTED_GROUND
)))
{
dev_err
(
&
pdev
->
dev
,
"Required data to use read_u
V
not supplied.
\n
"
);
"Required data to use read_u
v
not supplied.
\n
"
);
return
-
EINVAL
;
}
...
...
drivers/hwmon/via686a.c
浏览文件 @
088ce2ac
...
...
@@ -125,7 +125,7 @@ static const u8 VIA686A_REG_TEMP_HYST[] = { 0x3a, 0x3e, 0x1e };
* (These conversions were contributed by Jonathan Teh Soon Yew
* <j.teh@iname.com>)
*/
static
inline
u8
IN_TO_REG
(
long
val
,
int
in
N
um
)
static
inline
u8
IN_TO_REG
(
long
val
,
int
in
_n
um
)
{
/*
* To avoid floating point, we multiply constants by 10 (100 for +12V).
...
...
@@ -134,29 +134,29 @@ static inline u8 IN_TO_REG(long val, int inNum)
* by an additional 10000 (100000 for +12V): 1000 for val and 10 (100)
* for the constants.
*/
if
(
in
N
um
<=
1
)
if
(
in
_n
um
<=
1
)
return
(
u8
)
clamp_val
((
val
*
21024
-
1205000
)
/
250000
,
0
,
255
);
else
if
(
in
N
um
==
2
)
else
if
(
in
_n
um
==
2
)
return
(
u8
)
clamp_val
((
val
*
15737
-
1205000
)
/
250000
,
0
,
255
);
else
if
(
in
N
um
==
3
)
else
if
(
in
_n
um
==
3
)
return
(
u8
)
clamp_val
((
val
*
10108
-
1205000
)
/
250000
,
0
,
255
);
else
return
(
u8
)
clamp_val
((
val
*
41714
-
12050000
)
/
2500000
,
0
,
255
);
}
static
inline
long
IN_FROM_REG
(
u8
val
,
int
in
N
um
)
static
inline
long
IN_FROM_REG
(
u8
val
,
int
in
_n
um
)
{
/*
* To avoid floating point, we multiply constants by 10 (100 for +12V).
* We also multiply them by 1000 because we want 0.001V/bit for the
* output value. Rounding is done.
*/
if
(
in
N
um
<=
1
)
if
(
in
_n
um
<=
1
)
return
(
long
)
((
250000
*
val
+
1330000
+
21024
/
2
)
/
21024
);
else
if
(
in
N
um
==
2
)
else
if
(
in
_n
um
==
2
)
return
(
long
)
((
250000
*
val
+
1330000
+
15737
/
2
)
/
15737
);
else
if
(
in
N
um
==
3
)
else
if
(
in
_n
um
==
3
)
return
(
long
)
((
250000
*
val
+
1330000
+
10108
/
2
)
/
10108
);
else
return
(
long
)
((
2500000
*
val
+
13300000
+
41714
/
2
)
/
41714
);
...
...
@@ -210,10 +210,10 @@ static inline u8 FAN_TO_REG(long rpm, int div)
* VIA register values 0-255. I *10 before rounding, so we get tenth-degree
* precision. (I could have done all 1024 values for our 10-bit readings,
* but the function is very linear in the useful range (0-80 deg C), so
* we'll just use linear interpolation for 10-bit readings.) So, temp
LUT
* we'll just use linear interpolation for 10-bit readings.) So, temp
_lut
* is the temp at via register values 0-255:
*/
static
const
s16
temp
LUT
[]
=
{
static
const
s16
temp
_lut
[]
=
{
-
709
,
-
688
,
-
667
,
-
646
,
-
627
,
-
607
,
-
589
,
-
570
,
-
553
,
-
536
,
-
519
,
-
503
,
-
487
,
-
471
,
-
456
,
-
442
,
-
428
,
-
414
,
-
400
,
-
387
,
-
375
,
-
362
,
-
350
,
-
339
,
-
327
,
-
316
,
-
305
,
-
295
,
-
285
,
-
275
,
-
265
,
...
...
@@ -261,7 +261,7 @@ static const s16 tempLUT[] = {
* - 2.525453e-04*val^3 + 1.424593e-02*val^2 + 2.148941e+00*val +7.275808e+01)
* Note that n=161:
*/
static
const
u8
via
LUT
[]
=
{
static
const
u8
via
_lut
[]
=
{
12
,
12
,
13
,
14
,
14
,
15
,
16
,
16
,
17
,
18
,
18
,
19
,
20
,
20
,
21
,
22
,
23
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
,
31
,
32
,
33
,
35
,
36
,
37
,
39
,
40
,
41
,
43
,
45
,
46
,
48
,
49
,
51
,
53
,
55
,
57
,
59
,
60
,
62
,
64
,
66
,
...
...
@@ -284,26 +284,26 @@ static const u8 viaLUT[] = {
*/
static
inline
u8
TEMP_TO_REG
(
long
val
)
{
return
via
LUT
[
val
<=
-
50000
?
0
:
val
>=
110000
?
160
:
return
via
_lut
[
val
<=
-
50000
?
0
:
val
>=
110000
?
160
:
(
val
<
0
?
val
-
500
:
val
+
500
)
/
1000
+
50
];
}
/* for 8-bit temperature hyst and over registers */
#define TEMP_FROM_REG(val) ((long)temp
LUT
[val] * 100)
#define TEMP_FROM_REG(val) ((long)temp
_lut
[val] * 100)
/* for 10-bit temperature readings */
static
inline
long
TEMP_FROM_REG10
(
u16
val
)
{
u16
eight
B
its
=
val
>>
2
;
u16
two
B
its
=
val
&
3
;
u16
eight
_b
its
=
val
>>
2
;
u16
two
_b
its
=
val
&
3
;
/* no interpolation for these */
if
(
two
Bits
==
0
||
eightB
its
==
255
)
return
TEMP_FROM_REG
(
eight
B
its
);
if
(
two
_bits
==
0
||
eight_b
its
==
255
)
return
TEMP_FROM_REG
(
eight
_b
its
);
/* do some linear interpolation */
return
(
temp
LUT
[
eightBits
]
*
(
4
-
twoB
its
)
+
temp
LUT
[
eightBits
+
1
]
*
twoB
its
)
*
25
;
return
(
temp
_lut
[
eight_bits
]
*
(
4
-
two_b
its
)
+
temp
_lut
[
eight_bits
+
1
]
*
two_b
its
)
*
25
;
}
#define DIV_FROM_REG(val) (1 << (val))
...
...
include/linux/platform_data/ntc_thermistor.h
浏览文件 @
088ce2ac
...
...
@@ -45,8 +45,8 @@ struct ntc_thermistor_platform_data {
* chan: iio_channel pointer to communicate with the ADC which the
* thermistor is using for conversion of the analog values.
*/
int
(
*
read_u
V
)(
struct
ntc_thermistor_platform_data
*
);
unsigned
int
pullup_u
V
;
int
(
*
read_u
v
)(
struct
ntc_thermistor_platform_data
*
);
unsigned
int
pullup_u
v
;
unsigned
int
pullup_ohm
;
unsigned
int
pulldown_ohm
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录