[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <c5dbcd525d1c04c474fc3988ded9b509eb12ac9e.1623201081.git.vilhelm.gray@gmail.com>
Date: Wed, 9 Jun 2021 10:31:22 +0900
From: William Breathitt Gray <vilhelm.gray@...il.com>
To: jic23@...nel.org
Cc: linux-stm32@...md-mailman.stormreply.com, kernel@...gutronix.de,
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,
jarkko.nikula@...ux.intel.com,
William Breathitt Gray <vilhelm.gray@...il.com>,
Fabrice Gasnier <fabrice.gasnier@...s.st.com>
Subject: [PATCH v11 19/33] 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@...ux.intel.com>
Cc: Oleksij Rempel <o.rempel@...gutronix.de>
Cc: Maxime Coquelin <mcoquelin.stm32@...il.com>
Cc: Alexandre Torgue <alexandre.torgue@...com>
Acked-by: Syed Nayyar Waris <syednwaris@...il.com>
Reviewed-by: David Lechner <david@...hnology.com>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@...s.st.com>
Signed-off-by: William Breathitt Gray <vilhelm.gray@...il.com>
---
drivers/counter/104-quad-8.c | 6 +++---
drivers/counter/intel-qep.c | 2 +-
drivers/counter/interrupt-cnt.c | 3 +++
drivers/counter/stm32-lptimer-cnt.c | 2 +-
4 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c
index b7d6c1c43655..0409b1771fd9 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);
@@ -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);
diff --git a/drivers/counter/intel-qep.c b/drivers/counter/intel-qep.c
index ab10ba33f46a..7b4eb8ff8348 100644
--- a/drivers/counter/intel-qep.c
+++ b/drivers/counter/intel-qep.c
@@ -320,7 +320,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) {
diff --git a/drivers/counter/interrupt-cnt.c b/drivers/counter/interrupt-cnt.c
index 0e07607f2cd3..f27dea317965 100644
--- a/drivers/counter/interrupt-cnt.c
+++ b/drivers/counter/interrupt-cnt.c
@@ -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;
diff --git a/drivers/counter/stm32-lptimer-cnt.c b/drivers/counter/stm32-lptimer-cnt.c
index 78f383b77bd2..49aeb9e393f3 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;
--
2.32.0
Powered by blists - more mailing lists