[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YCsfXGzfEgRAD9p9@shinobu>
Date: Tue, 16 Feb 2021 10:26:52 +0900
From: William Breathitt Gray <vilhelm.gray@...il.com>
To: Jonathan Cameron <jic23@...nel.org>
Cc: kernel@...gutronix.de, linux-stm32@...md-mailman.stormreply.com,
a.fatoum@...gutronix.de, kamel.bouhara@...tlin.com,
gwendal@...omium.org, alexandre.belloni@...tlin.com,
david@...hnology.com, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
syednwaris@...il.com, patrick.havelange@...ensium.com,
fabrice.gasnier@...com, mcoquelin.stm32@...il.com,
alexandre.torgue@...com, o.rempel@...gutronix.de
Subject: Re: [PATCH v8 10/22] counter: Standardize to ERANGE for limit
exceeded errors
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@...il.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
William Breathitt Gray
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists