Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2060865pxt; Sun, 8 Aug 2021 10:08:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3cMXHcEBFZPqEchpl12ebXqqRt3YCrXhlTCxS7JeAmtyo7pSRb5zcCcU7AGOoZp26/FXD X-Received: by 2002:a17:906:6855:: with SMTP id a21mr19000582ejs.97.1628442499078; Sun, 08 Aug 2021 10:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628442499; cv=none; d=google.com; s=arc-20160816; b=sxmw8Bz1Dt/NYrB6ORcx4Mn2JVy9im2nSrr2inNU8k3vbESYXR7EjziTM1bvua6g0W deD3AiJNiVM5cASoT5JmZp1xw5MI0IlnzXkfMbINVv5cZtuUeYTYyBiSoLCz8xwZxxE9 1igv5cVfurYSMQDgUPD9fXHPJhcL8vsv/UpuwSXfN7pPw7FszOEzN2+nOZ/i2lczel3r QAFL+7ggwutzWVJ8vDK8RS/St92hfsyPdS0+m3ZA6xrFY4rfW1leW/9jxnlokPYjHtjM ABcvuHQ/zKWfr4IM9c+zJG1sd1oj5qkCpG3uBnlNFPpcg73GIqD6qgP49m66/Yzcy2eT jHRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=aMyYnKAi8sRkIpcds6ht6h++F3paJ+I5osawhLCmwxQ=; b=FLp/wg1ff9bbef4tuUnh1rLbcGqyHDN13sF6MiRIcrfkGhmg3CsMt2xxrFS1KMTnJ0 2XY+sK7CO8PLR5EYnaFD/JiEcYfx4wKBrAHMnQUwD92Oy+PfKOjtXehC2OWeRMGOQoYg yunq12LjA5/sFKyT0iwdstIG9Lf+5hi84MHYL4vh0bg/akfZ5r0VU41eyYeduMJ0kFO7 rxwdcWgQnRFigP2zlYnysk5oC+fMhd6cuzJ/5y+mnwwGmNP/bkhI3QpGoOar0xqzQHZU 6rm4jGRw14EFHWe2kOWM6S6w7JeuuffH5jyE3KRXOk0RrcbtgmBXnFZ0rGV/ZBndu0S+ 6qWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z25si14489003ejj.275.2021.08.08.10.07.55; Sun, 08 Aug 2021 10:08:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232095AbhHHRGb (ORCPT + 99 others); Sun, 8 Aug 2021 13:06:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:40702 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232013AbhHHRGa (ORCPT ); Sun, 8 Aug 2021 13:06:30 -0400 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 76DF460E93; Sun, 8 Aug 2021 17:06:06 +0000 (UTC) Date: Sun, 8 Aug 2021 18:08:55 +0100 From: Jonathan Cameron To: William Breathitt Gray Cc: linux-stm32@st-md-mailman.stormreply.com, kernel@pengutronix.de, a.fatoum@pengutronix.de, kamel.bouhara@bootlin.com, gwendal@chromium.org, alexandre.belloni@bootlin.com, david@lechnology.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, syednwaris@gmail.com, patrick.havelange@essensium.com, fabrice.gasnier@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, o.rempel@pengutronix.de, jarkko.nikula@linux.intel.com, Fabrice Gasnier Subject: Re: [PATCH v14 03/17] counter: Standardize to ERANGE for limit exceeded errors Message-ID: <20210808180855.1251f06c@jic23-huawei> In-Reply-To: References: X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 3 Aug 2021 21:06:13 +0900 William Breathitt Gray wrote: > 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 > Cc: Oleksij Rempel > Cc: Maxime Coquelin > Cc: Alexandre Torgue > Acked-by: Syed Nayyar Waris > Reviewed-by: David Lechner > Reviewed-by: Fabrice Gasnier > Signed-off-by: William Breathitt Gray Just for the record, I'll note this is an ABI change. However, I'm fairly sure it's the category of no one will notice and so we are fine to change it. Applied, Thanks, Jonathan > --- > 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 b358b2b2b883..d54efdb8d393 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 1a9512e28519..204f94577666 100644 > --- a/drivers/counter/intel-qep.c > +++ b/drivers/counter/intel-qep.c > @@ -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) { > 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; > 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; >