mirror of
https://gitlab.com/manzerbredes/ina260-sysfs-driver.git
synced 2025-06-07 07:07:41 +00:00
Minor changes
This commit is contained in:
parent
407619c860
commit
ec8bd3d7a1
1 changed files with 28 additions and 4 deletions
32
ina260.c
32
ina260.c
|
@ -80,7 +80,7 @@ struct client_data {
|
||||||
static int ina260_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
|
static int ina260_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
|
||||||
u32 attr, int channel, long *val)
|
u32 attr, int channel, long *val)
|
||||||
{
|
{
|
||||||
int rvalue, reg, err;
|
int rvalue, reg, err, rem;
|
||||||
struct client_data *cdata=dev_get_drvdata(dev);
|
struct client_data *cdata=dev_get_drvdata(dev);
|
||||||
switch(type){
|
switch(type){
|
||||||
case hwmon_power:
|
case hwmon_power:
|
||||||
|
@ -101,7 +101,7 @@ static int ina260_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
|
||||||
} else if(type == hwmon_power) {
|
} else if(type == hwmon_power) {
|
||||||
*val=10*rvalue*1000;
|
*val=10*rvalue*1000;
|
||||||
} else{
|
} else{
|
||||||
*val=div_u64(rvalue*25,100)+rvalue;
|
*val=div_u64_rem(rvalue*25,100,&rem)+rvalue+div_u64(rem,10);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -131,8 +131,32 @@ INA260_REG_STORE(alert_limit,INA260_REG_ALERTLIMIT)
|
||||||
static umode_t ina260_hwmon_is_visible(const void *drvdata,
|
static umode_t ina260_hwmon_is_visible(const void *drvdata,
|
||||||
enum hwmon_sensor_types type,
|
enum hwmon_sensor_types type,
|
||||||
u32 attr, int channel){
|
u32 attr, int channel){
|
||||||
return 0444;
|
switch (type) {
|
||||||
}
|
case hwmon_in:
|
||||||
|
switch (attr) {
|
||||||
|
case hwmon_in_input:
|
||||||
|
return 0444;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
case hwmon_curr:
|
||||||
|
switch (attr) {
|
||||||
|
case hwmon_curr_input:
|
||||||
|
return 0444;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
case hwmon_power:
|
||||||
|
switch (attr) {
|
||||||
|
case hwmon_power_input:
|
||||||
|
return 0444;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
static const struct hwmon_channel_info * ina260_hwmon_info[] = {
|
static const struct hwmon_channel_info * ina260_hwmon_info[] = {
|
||||||
HWMON_CHANNEL_INFO(in,HWMON_I_INPUT),
|
HWMON_CHANNEL_INFO(in,HWMON_I_INPUT),
|
||||||
HWMON_CHANNEL_INFO(power,HWMON_P_INPUT),
|
HWMON_CHANNEL_INFO(power,HWMON_P_INPUT),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue