Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4406024pxb; Sun, 14 Feb 2021 09:13:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDpU33zBv66k1yGf2uWLpQ+xVEO6sHgMOcAld3gYPKI/Oedan5U55XHVVWdefXyG0X6Zjl X-Received: by 2002:a17:906:b7ce:: with SMTP id fy14mr5574682ejb.447.1613322793344; Sun, 14 Feb 2021 09:13:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613322793; cv=none; d=google.com; s=arc-20160816; b=WUGoy+ve26kZKWdPTDqf5GB91DRL+KHQxmiTMDG8YUTW7riUTrFk5s4Edh2/YVBzXI eO9yEv9jiVfmMVWwZB/NQs4W8CBi5tfLxLI8c/o7CRgxWT97memSGuN6RbrMWZKxkSID FWv7I9CmyPdo3yF5sS6DNd3/EhPx4/BUatKQ1DUEKiME1lq/ZlEVaTmas44hFrQAsbyw zMY7glPDeh7IuHs5nHqJg7cfc5Z9cJaJQJEJphxflCMDus78QDS/9PjVaZauz/vXfpR5 HIN2VJQNwrEvc1KrfGbLcE8vpp9plP7JNsNQHnaKypTo+ohlgGL3NIDj/Hjk+CxhobVb /bww== 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=sZZFp4mJTsKRFYomLU8VjyYI3QCHJcJ7r0vGUHvxVCI=; b=GWCWBksdBmGM4x7/Vtz6oDWV758B0LHaAG1nPlyNwlC+8qrNHEiDXoCCqeC8xN3eKk uhlyiQf1ayJj+DTLXc0WlqWDdF4J2iXkzZzBalceA213RNvLqLjNV+ROpaVLdO+gWpfR dnrU982+RG5N6gB4WnC1tNg4D4qMj563ZykCsEEZvQSqIcRV/y25G9L1J6UzfoBmowbd jjBCo6BpaxWnW7An0x9qGiANxX/mJl1UGHtRIoSnMUzQDhnOoEefe4vJJnEdO14iey5A ugc4H7LFVS5RooIJvwF+N4f1IXcHerGefFRjZYFUrYoywk6l3dACpxJ4sPpQEBC99Xw9 x4DQ== 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 f16si12201819edy.306.2021.02.14.09.12.50; Sun, 14 Feb 2021 09:13:13 -0800 (PST) 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 S229788AbhBNRLL (ORCPT + 99 others); Sun, 14 Feb 2021 12:11:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:48310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229740AbhBNRLJ (ORCPT ); Sun, 14 Feb 2021 12:11:09 -0500 Received: from archlinux (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 2838064DBA; Sun, 14 Feb 2021 17:10:24 +0000 (UTC) Date: Sun, 14 Feb 2021 17:10:21 +0000 From: Jonathan Cameron To: William Breathitt Gray Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, 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 Subject: Re: [PATCH v8 10/22] counter: Standardize to ERANGE for limit exceeded errors Message-ID: <20210214171021.41b3e4e3@archlinux> In-Reply-To: <7fa80c10fcd10d1d47d1bddced2b2cca3ff59ba9.1613131238.git.vilhelm.gray@gmail.com> References: <7fa80c10fcd10d1d47d1bddced2b2cca3ff59ba9.1613131238.git.vilhelm.gray@gmail.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; 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 Fri, 12 Feb 2021 21:13:34 +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. #define ERANGE 34 /* Math result not representable */ Not generally applicable to a parameter being out of range despite the name. #define EINVAL 22 /* Invalid argument */ Is probably closer to what we want to describe here. Jonathan > > Cc: Syed Nayyar Waris > Cc: Fabrice Gasnier > Cc: Maxime Coquelin > Cc: Alexandre Torgue > Signed-off-by: William Breathitt Gray > --- > drivers/counter/104-quad-8.c | 6 +++--- > drivers/counter/stm32-lptimer-cnt.c | 2 +- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c > index 674263b4d2c4..a2cabb028db0 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); > > @@ -671,7 +671,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); > > @@ -716,7 +716,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/stm32-lptimer-cnt.c b/drivers/counter/stm32-lptimer-cnt.c > index daf988e7b208..d5f9d580d06d 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; >