summaryrefslogtreecommitdiff
path: root/drivers/counter/interrupt-cnt.c
diff options
context:
space:
mode:
authorWilliam Breathitt Gray <vilhelm.gray@gmail.com>2021-08-03 21:06:13 +0900
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2021-08-09 20:17:36 +0100
commite2ff3198c580a3a3acfdc50cce5b5f8a941cbcd1 (patch)
treec362f49faac490020b6d8225340a7bb48e301ec3 /drivers/counter/interrupt-cnt.c
parentb11eed1554e8ea33b748094ea73d8b42fa2bbe3b (diff)
downloadlwn-e2ff3198c580a3a3acfdc50cce5b5f8a941cbcd1.tar.gz
lwn-e2ff3198c580a3a3acfdc50cce5b5f8a941cbcd1.zip
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>
Diffstat (limited to 'drivers/counter/interrupt-cnt.c')
-rw-r--r--drivers/counter/interrupt-cnt.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/counter/interrupt-cnt.c b/drivers/counter/interrupt-cnt.c
index 5df7cd13d4c7..66cac4900327 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;