Re: [PATCH v5 0/3] iio: adc: add support for the MAX34417 Four-Channel High Dynamic Range Power Accumulator

From: Neil Armstrong

Date: Mon Nov 16 2026 - 04:34:42 EST


On 11/14/26 19:46, Jonathan Cameron wrote:
On Mon, 9 Nov 2026 10:52:22 +0100
Neil Armstrong <neil.armstrong@xxxxxxxxxx> wrote:

On 11/8/26 00:09, Jonathan Cameron wrote:
On Wed, 4 Nov 2026 09:45:02 +0100
Neil Armstrong <neil.armstrong@xxxxxxxxxx> wrote:

<snip>

But for the other reports:
- [Medium] iio: adc: max34417: shared accumulators clobbered on CAM power/energy read

This is a tough one, today if either we read power or energy, we erase the accumulated
power+count in the context, the context accumulator is only here to make sure we don't
loose data from other channels, like if we had a single HW channel.
This simulates this, if we had a single HW channel, at each UPDATE we would get back
to 0 in hardware anyway if we did read the power or energy.


I'm only half understanding this. Let me see...

I'd expect userspace to see accumulated values since we enabled the channel
rather than since last read. I think that's the final suggestion from
sashiko.

Oh this changes quite a lot of things.
How do we handle overflow in this case ? we disable the channel and enable again to reset the state ?

Is it possible to accumulate into a sufficiently large type that overflow won't happen in a feasible
timescale? Anything else is going to be a but unpredictable for userspace if it
is expecting an accumulated number. The other things that accumulate in IIO tend to be
moderately small so it's never been an issue (things like step counters).

The hardware can store up to 4.55h of data with it's 56bit with the default rate,
we store in 64bit in software, so we can store up to 256 times so up to 48.53 days.

It's possible to lower the SPS to 8, in this mode we can store up to 6211 days of data.
I plan to add this mode afterwards.

I'll switch to this and clear the overflow only if we disable the POWER channel.

Neil


Jonathan