Commit e2ff3198 authored by William Breathitt Gray's avatar William Breathitt Gray Committed by Jonathan Cameron
Browse files

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: default avatarSyed Nayyar Waris <syednwaris@gmail.com>
Reviewed-by: default avatarDavid Lechner <david@lechnology.com>
Reviewed-by: default avatarFabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: default avatarWilliam Breathitt Gray <vilhelm.gray@gmail.com>
Link: https://lore.kernel.org/r/ae8d3b20b8b02c96b1c9898ffa2f9fa5d99edc81.1627990337.git.vilhelm.gray@gmail.com


Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent b11eed15
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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);

@@ -669,7 +669,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);

@@ -714,7 +714,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);

+1 −1
Original line number Diff line number Diff line
@@ -319,7 +319,7 @@ static ssize_t spike_filter_ns_write(struct counter_device *counter,
	}

	if (length > INTEL_QEPFLT_MAX_COUNT(length))
		return -EINVAL;
		return -ERANGE;

	mutex_lock(&qep->lock);
	if (qep->enabled) {
+3 −0
Original line number Diff line number Diff line
@@ -107,6 +107,9 @@ static int interrupt_cnt_write(struct counter_device *counter,
{
	struct interrupt_cnt_priv *priv = counter->priv;

	if (val != (typeof(priv->count.counter))val)
		return -ERANGE;

	atomic_set(&priv->count, val);

	return 0;
+1 −1
Original line number Diff line number Diff line
@@ -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;