[PATCH v8 10/22] counter: Standardize to ERANGE for limit exceeded errors
Jonathan Cameron
jic23 at kernel.org
Sun Feb 14 12:10:21 EST 2021
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
>
> Cc: Syed Nayyar Waris <syednwaris at gmail.com>
> Cc: Fabrice Gasnier <fabrice.gasnier at st.com>
> Cc: Maxime Coquelin <mcoquelin.stm32 at gmail.com>
> Cc: Alexandre Torgue <alexandre.torgue at st.com>
> Signed-off-by: William Breathitt Gray <vilhelm.gray at gmail.com>
> ---
> drivers/counter/104-quad-8.c | 6 +++---
> drivers/counter/stm32-lptimer-cnt.c | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c
> index 674263b4d2c4..a2cabb028db0 100644
> --- a/drivers/counter/104-quad-8.c
> +++ b/drivers/counter/104-quad-8.c
> @@ -154,7 +154,7 @@ static int quad8_count_write(struct counter_device *counter,
>
> /* Only 24-bit values are supported */
> if (val > 0xFFFFFF)
> - return -EINVAL;
> + return -ERANGE;
>
> mutex_lock(&priv->lock);
>
> @@ -671,7 +671,7 @@ static ssize_t quad8_count_preset_write(struct counter_device *counter,
>
> /* Only 24-bit values are supported */
> if (preset > 0xFFFFFF)
> - return -EINVAL;
> + return -ERANGE;
>
> mutex_lock(&priv->lock);
>
> @@ -716,7 +716,7 @@ static ssize_t quad8_count_ceiling_write(struct counter_device *counter,
>
> /* Only 24-bit values are supported */
> if (ceiling > 0xFFFFFF)
> - return -EINVAL;
> + return -ERANGE;
>
> mutex_lock(&priv->lock);
>
> diff --git a/drivers/counter/stm32-lptimer-cnt.c b/drivers/counter/stm32-lptimer-cnt.c
> index daf988e7b208..d5f9d580d06d 100644
> --- a/drivers/counter/stm32-lptimer-cnt.c
> +++ b/drivers/counter/stm32-lptimer-cnt.c
> @@ -283,7 +283,7 @@ static ssize_t stm32_lptim_cnt_ceiling_write(struct counter_device *counter,
> return ret;
>
> if (ceiling > STM32_LPTIM_MAX_ARR)
> - return -EINVAL;
> + return -ERANGE;
>
> priv->ceiling = ceiling;
>
More information about the linux-arm-kernel
mailing list