Re: [PATCH v8 10/22] counter: Standardize to ERANGE for limit exceeded errors
From: Jonathan Cameron <jic23@kernel.org>
Date: 2021-02-21 14:04:01
Also in:
linux-iio, lkml
On Tue, 16 Feb 2021 10:26:52 +0900 William Breathitt Gray [off-list ref] wrote:
On Sun, Feb 14, 2021 at 05:10:21PM +0000, Jonathan Cameron wrote:quoted
On Fri, 12 Feb 2021 21:13:34 +0900 William Breathitt Gray [off-list ref] wrote:quoted
ERANGE is a semantically better error code to return when an argument value falls outside the supported limit range of a device.#define ERANGE 34 /* Math result not representable */ Not generally applicable to a parameter being out of range despite the name. #define EINVAL 22 /* Invalid argument */ Is probably closer to what we want to describe here. JonathanThe comment for ERANGE in error-base.h may be terse to a fault. I believe there's a connotation here provided by ERANGE that is absent from EINVAL: primarily that the device buffer is incapable of supporting the desired value (i.e. there is a hardware limitation). This is why strtoul() returns ERANGE if the correct value is outside the range of representable values: the result of the operation is valid in theory (it would be an unsigned integer), but it cannot be returned to the user due to a limitation of the hardware to support that value (e.g. 32-bit registers) [1]. The changes in this patch follow the same logic: these are arguments that are valid in theory (e.g. they are unsigned integers), but the underlying devices are incapable of processing such a value (e.g. the 104-QUAD-8 can only handle 24-bit values). [1] https://stackoverflow.com/a/34981398/1806289
Its a bit of a stretch, but I can't claim to feel that strongly about this. Jonathan
William Breathitt Gray
_______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel