From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE14BC433E6 for ; Sun, 21 Feb 2021 14:04:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B341764EE0 for ; Sun, 21 Feb 2021 14:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229945AbhBUOEB (ORCPT ); Sun, 21 Feb 2021 09:04:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:52736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229663AbhBUOD7 (ORCPT ); Sun, 21 Feb 2021 09:03:59 -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 8E86E64EE0; Sun, 21 Feb 2021 14:03:15 +0000 (UTC) Date: Sun, 21 Feb 2021 14:03:12 +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: <20210221140312.299b0e5a@archlinux> In-Reply-To: References: <7fa80c10fcd10d1d47d1bddced2b2cca3ff59ba9.1613131238.git.vilhelm.gray@gmail.com> <20210214171021.41b3e4e3@archlinux> 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 Tue, 16 Feb 2021 10:26:52 +0900 William Breathitt Gray wrote: > On Sun, Feb 14, 2021 at 05:10:21PM +0000, Jonathan Cameron wrote: > > 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 > > The comment for ERANGE in error-base.h may be terse to a fault. I > believe there's a connotation here provided by ERANGE that is absent > from EINVAL: primarily that the device buffer is incapable of supporting > the desired value (i.e. there is a hardware limitation). > > This is why strtoul() returns ERANGE if the correct value is outside the > range of representable values: the result of the operation is valid in > theory (it would be an unsigned integer), but it cannot be returned to > the user due to a limitation of the hardware to support that value (e.g. > 32-bit registers) [1]. > > The changes in this patch follow the same logic: these are arguments > that are valid in theory (e.g. they are unsigned integers), but the > underlying devices are incapable of processing such a value (e.g. the > 104-QUAD-8 can only handle 24-bit values). > > [1] https://stackoverflow.com/a/34981398/1806289 Its a bit of a stretch, but I can't claim to feel that strongly about this. Jonathan > > William Breathitt Gray From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF1CCC433DB for ; Sun, 21 Feb 2021 14:04:55 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6357464EE0 for ; Sun, 21 Feb 2021 14:04:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6357464EE0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ujdBr8OwvE3RgfmNLPUVwRX2yiOMWKI+VdozpmuRv3g=; b=oHRIH/A4eANZUj2+1iIVf7UoQ Flg/tekhrARLtwBQv9UhEZ6Ne7c44sK4e2A1eiGEmBHY89TSsgPt79Oya8gIE0uuEmut1CJHIVdip R5mMXY+9JzYro3leUriufah6uSmJpR27ByU/Odi64m0poozORveR8S9zhKqZsFfcUhsxRpKqKfrt2 AlX0vUCe/lV6JvBmWmXUd0l97fp7dbgkMa3c2qvLD9ci7clPWkDxMlJRKV0CHj4yFxDPaT7lwzx1N BtxrLPiyX5EmGc9wUPoe+qUoGf0rTNTnOpCw4r9GGiMASt3ChhlFpjVvW2K+43hxDD7ztTDXGOG9d 66zq0Xo3A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lDpKW-0002vm-8c; Sun, 21 Feb 2021 14:03:24 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lDpKT-0002uy-14 for linux-arm-kernel@lists.infradead.org; Sun, 21 Feb 2021 14:03:22 +0000 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 8E86E64EE0; Sun, 21 Feb 2021 14:03:15 +0000 (UTC) Date: Sun, 21 Feb 2021 14:03:12 +0000 From: Jonathan Cameron To: William Breathitt Gray Subject: Re: [PATCH v8 10/22] counter: Standardize to ERANGE for limit exceeded errors Message-ID: <20210221140312.299b0e5a@archlinux> In-Reply-To: References: <7fa80c10fcd10d1d47d1bddced2b2cca3ff59ba9.1613131238.git.vilhelm.gray@gmail.com> <20210214171021.41b3e4e3@archlinux> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210221_090321_200237_ABA330B2 X-CRM114-Status: GOOD ( 21.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kamel.bouhara@bootlin.com, gwendal@chromium.org, a.fatoum@pengutronix.de, david@lechnology.com, linux-iio@vger.kernel.org, patrick.havelange@essensium.com, alexandre.belloni@bootlin.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org, o.rempel@pengutronix.de, kernel@pengutronix.de, fabrice.gasnier@st.com, syednwaris@gmail.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, alexandre.torgue@st.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 16 Feb 2021 10:26:52 +0900 William Breathitt Gray wrote: > On Sun, Feb 14, 2021 at 05:10:21PM +0000, Jonathan Cameron wrote: > > 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 > > The comment for ERANGE in error-base.h may be terse to a fault. I > believe there's a connotation here provided by ERANGE that is absent > from EINVAL: primarily that the device buffer is incapable of supporting > the desired value (i.e. there is a hardware limitation). > > This is why strtoul() returns ERANGE if the correct value is outside the > range of representable values: the result of the operation is valid in > theory (it would be an unsigned integer), but it cannot be returned to > the user due to a limitation of the hardware to support that value (e.g. > 32-bit registers) [1]. > > The changes in this patch follow the same logic: these are arguments > that are valid in theory (e.g. they are unsigned integers), but the > underlying devices are incapable of processing such a value (e.g. the > 104-QUAD-8 can only handle 24-bit values). > > [1] https://stackoverflow.com/a/34981398/1806289 Its a bit of a stretch, but I can't claim to feel that strongly about this. Jonathan > > William Breathitt Gray _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel