diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2023-08-15 11:21:19 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2023-08-15 11:21:19 +0200 |
| commit | 413576211c7be4b895a388dacd1770bb2a78997b (patch) | |
| tree | 8440fe60a99ec1fe807e7d1d72df410c6335a418 | |
| parent | 88e8a7b7f6cd897b489e4372c42f63f88bce7aaa (diff) | |
Minor changes
| -rwxr-xr-x | ina260.c | 30 |
1 files changed, 27 insertions, 3 deletions
@@ -69,7 +69,7 @@ struct client_data { static int ina260_hwmon_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long *val) { - int rvalue, reg, err; + int rvalue, reg, err, rem; struct client_data *cdata = dev_get_drvdata(dev); switch (type) { @@ -91,7 +91,7 @@ static int ina260_hwmon_read(struct device *dev, enum hwmon_sensor_types type, else if (type == hwmon_power) *val = rvalue * 10000; else - *val = div_u64(rvalue * 25, 100) + rvalue; + *val = div_u64_rem(rvalue * 25, 100, &rem) + rvalue + div_u64(rem, 10); return 0; } @@ -120,7 +120,31 @@ INA260_REG_STORE(alert_limit, INA260_REG_ALERTLIMIT) static umode_t ina260_hwmon_is_visible(const void *drvdata, 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[] = { |
