Messages in this thread | | | Date | Wed, 7 Jan 2015 13:48:40 +0100 | Subject | Re: [v8, 5/5] hwmon: ina2xx: allow to change the averaging rate at run-time | From | Bartosz Golaszewski <> |
| |
2015-01-06 19:18 GMT+01:00 Guenter Roeck <linux@roeck-us.net>: > ina226_avg_val() calculates the average value from ina226_avg_tab > and then you loop through ina226_avg_tab to find the index into ina226_avg_tab > again, only to use the thus calculated index for accessing ina226_avg_tab[] > once more. Think about it. A simple > avg = ina226_avg_tab[INA226_READ_AVG(data->regs[INA2XX_CONFIG])]; > return snprintf(buf, PAGE_SIZE, "%d\n", avg); > or even > return snprintf(buf, PAGE_SIZE, "%d\n", > ina226_avg_tab[INA226_READ_AVG(data->regs[INA2XX_CONFIG])]); > > would accomplish exactly the same.
This was stupid, I admit. Fixed in the new version. Hope it's ok now.
> I kind of dislike that attribute name. I don't have a better idea though, so > I'll let it pass unless you have a better idea.
I don't really. What's wrong with this one?
Bart
| |