That one is a bit obscure.What kind of error to return in the case it does not fit - ENOEXEC (Exec format error) ?+ /* Use 32-bit value, since practically there is no need in 64 bits */We should check it fits and if doesn't return an error rather than pretending all was fine.
+ *val = (u32)readings[ch->scan_index].value;
I'd go with either -ERANGE I think as we are reflecting that the clamp to 32 bit
is not representable.