counter: Standardize to ERANGE for limit exceeded errors

ERANGE is a semantically better error code to return when an argument
value falls outside the supported limit range of a device.

Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Acked-by: Syed Nayyar Waris <syednwaris@gmail.com>
Reviewed-by: David Lechner <david@lechnology.com>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Link: https://lore.kernel.org/r/ae8d3b20b8b02c96b1c9898ffa2f9fa5d99edc81.1627990337.git.vilhelm.gray@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
William Breathitt Gray 2021-08-03 21:06:13 +09:00 коммит произвёл Jonathan Cameron
Родитель b11eed1554
Коммит e2ff3198c5
4 изменённых файлов: 8 добавлений и 5 удалений

Просмотреть файл

@ -154,7 +154,7 @@ static int quad8_count_write(struct counter_device *counter,
/* Only 24-bit values are supported */ /* Only 24-bit values are supported */
if (val > 0xFFFFFF) if (val > 0xFFFFFF)
return -EINVAL; return -ERANGE;
mutex_lock(&priv->lock); mutex_lock(&priv->lock);
@ -669,7 +669,7 @@ static ssize_t quad8_count_preset_write(struct counter_device *counter,
/* Only 24-bit values are supported */ /* Only 24-bit values are supported */
if (preset > 0xFFFFFF) if (preset > 0xFFFFFF)
return -EINVAL; return -ERANGE;
mutex_lock(&priv->lock); mutex_lock(&priv->lock);
@ -714,7 +714,7 @@ static ssize_t quad8_count_ceiling_write(struct counter_device *counter,
/* Only 24-bit values are supported */ /* Only 24-bit values are supported */
if (ceiling > 0xFFFFFF) if (ceiling > 0xFFFFFF)
return -EINVAL; return -ERANGE;
mutex_lock(&priv->lock); mutex_lock(&priv->lock);

Просмотреть файл

@ -319,7 +319,7 @@ static ssize_t spike_filter_ns_write(struct counter_device *counter,
} }
if (length > INTEL_QEPFLT_MAX_COUNT(length)) if (length > INTEL_QEPFLT_MAX_COUNT(length))
return -EINVAL; return -ERANGE;
mutex_lock(&qep->lock); mutex_lock(&qep->lock);
if (qep->enabled) { if (qep->enabled) {

Просмотреть файл

@ -107,6 +107,9 @@ static int interrupt_cnt_write(struct counter_device *counter,
{ {
struct interrupt_cnt_priv *priv = counter->priv; struct interrupt_cnt_priv *priv = counter->priv;
if (val != (typeof(priv->count.counter))val)
return -ERANGE;
atomic_set(&priv->count, val); atomic_set(&priv->count, val);
return 0; return 0;

Просмотреть файл

@ -283,7 +283,7 @@ static ssize_t stm32_lptim_cnt_ceiling_write(struct counter_device *counter,
return ret; return ret;
if (ceiling > STM32_LPTIM_MAX_ARR) if (ceiling > STM32_LPTIM_MAX_ARR)
return -EINVAL; return -ERANGE;
priv->ceiling = ceiling; priv->ceiling = ceiling;