mirror of
https://gitlab.com/manzerbredes/ina260-sysfs-driver.git
synced 2025-04-19 04:09:45 +00:00
Minor changes
This commit is contained in:
parent
88e8a7b7f6
commit
413576211c
1 changed files with 27 additions and 3 deletions
30
ina260.c
30
ina260.c
|
@ -69,7 +69,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) {
|
||||||
|
@ -91,7 +91,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 = rvalue * 10000;
|
*val = rvalue * 10000;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,31 @@ 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, u32 attr, int channel)
|
enum hwmon_sensor_types type, 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[] = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue