[PATCH v8 10/22] counter: Standardize to ERANGE for limit exceeded errors
Jonathan Cameron
jic23 at kernel.org
Sun Feb 21 09:03:12 EST 2021
On Tue, 16 Feb 2021 10:26:52 +0900
William Breathitt Gray <vilhelm.gray at gmail.com> wrote:
> On Sun, Feb 14, 2021 at 05:10:21PM +0000, Jonathan Cameron wrote:
> > On Fri, 12 Feb 2021 21:13:34 +0900
> > William Breathitt Gray <vilhelm.gray at gmail.com> wrote:
> >
> > > 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.
> >
> > Jonathan
>
> The 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
More information about the linux-arm-kernel
mailing list