Re: [v8, 5/5] hwmon: ina2xx: allow to change the averaging rate at run-time

From: Bartosz Golaszewski
Date: Wed Jan 07 2015 - 07:48:46 EST


2015-01-06 19:18 GMT+01:00 Guenter Roeck <linux@xxxxxxxxxxxx>:
> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/