From patchwork Tue Jul 13 09:53:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 12373381 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=-13.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 823CCC11F67 for ; Tue, 13 Jul 2021 09:58:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 56B7761158 for ; Tue, 13 Jul 2021 09:58:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 56B7761158 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com 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=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=c6TqnMkY/WMSvrjxJGPpI1XLQuOOZ5LSNv4wW4SlTdY=; b=0d79VufRWEzk/x ebp4r0jfGUKWXnffNDh1yCyToHjaOodSGOgbYdGdC/b0geQCO8uVr6FqAI+YNIfIw/qkUQQt/m5Ik tb7AgNovjqj59IpcRzMC/yC5QLEIwbcilfaoup9abQ6+QyeL0cOsGQPTk2/ogbMgCdVlFtW4M4iJR p7POjHODbayaU1CSCdkaeacjOrCTeZWaK8XJAHZiD9ewbxLN+vTxku8jlKwOI/iAyU4/tORrxjQJi 475IVPOSsAi7QiGe4RYCOP8vFJ/ZhaKx8Qs04Ug8ApLgcoWmmXcCZnk6cl2merUXDI7jVIVEHbp0h NG2rQPJ0u392WNmy1DsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3F95-009kDm-SG; Tue, 13 Jul 2021 09:56:09 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3F6z-009jdZ-Q8 for linux-arm-kernel@lists.infradead.org; Tue, 13 Jul 2021 09:53:59 +0000 Received: by mail-pf1-x42d.google.com with SMTP id j199so19082735pfd.7 for ; Tue, 13 Jul 2021 02:53:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=stljVzismgi0bhtAbjcWPPl7QduNl8XesIvoC90of/Y=; b=XbqbBYt2KAlG3Au5ST8HktTGY8nR/iVlmTPfNPtKlHejTMWpvIAi1rty+h5f4iQLHE nJXvg3R96ugxInztBlrgyDUwlPlR8ZR5+vE3DyTuJXpEDGLMoNAMNIe3anaw7IVwY34n qhNu4yWR1zY7b30U6/xItFlqhZjMtoXQ5Khn8oFPSRh5rtjQ0zxTZKBzdBRTlNH9By5/ uamK3z3t43yzWYuCUGqARsrkq/8Xoko0odTVsqujpwIqPA2El8XxDGHnMJ6Ih5ocfxHw RmY/qkUpRLzFfdkEACjgeuKNf4NsXjwh5qGJUPrXsziVCPNvzdenTIGHvLndzj41MPFZ utUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=stljVzismgi0bhtAbjcWPPl7QduNl8XesIvoC90of/Y=; b=ZHjIxacwYFvaFYDvZRt3qeLLKDcxRlm30o1KyNCiK0dek7PINFXjbfML5v/t4GbgwQ SAMAEyc21keYeotH+WQCLpKYu/rKTZ4HrbVU2r03sH874iVrqVjtrttBrCJnJLbmy7TB yMoBhCLtRAtPap2ghX7vcUtBJdFEEgf0VK7x8UM65zWn3DfeQ7Fi+LVmVaCWmpPvshkQ dUMJ0uk4hFkS4k3P2/aW5wYPErYUysvflqElfIYGg0JLfcxmE36qndd68TDtM/Vq503J CGroI2XguTWi0TV5QY3oCLc3ky9GLE8uG72ia8AO4P5rEQ6NZaaoIDNxajkY+gdj/hbq etlA== X-Gm-Message-State: AOAM530/3Lq2l1P0Ex9tZN39n/E5AH7AnwtJmqidXz2KSKX4qNyZnzPP 4x/1138iQi7c9YYHC1g6EhE= X-Google-Smtp-Source: ABdhPJwvrFfpLw+74Tmy0kgPix7l+4vhDX9i+6oMqVqeiHrrv4/yf8ifuQ/AwxIDzsU9gxJ8SiZ6Eg== X-Received: by 2002:a62:87c6:0:b029:327:8be4:978e with SMTP id i189-20020a6287c60000b02903278be4978emr3659746pfe.50.1626170036164; Tue, 13 Jul 2021 02:53:56 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id f6sm18153854pfj.28.2021.07.13.02.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 02:53:55 -0700 (PDT) From: William Breathitt Gray To: jic23@kernel.org 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, William Breathitt Gray , Fabrice Gasnier Subject: [PATCH v13 03/17] counter: Standardize to ERANGE for limit exceeded errors Date: Tue, 13 Jul 2021 18:53:07 +0900 Message-Id: <275a0de80b2eb272f5dc1641c511ed601c9f5848.1626165765.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210713_025357_915959_0903E576 X-CRM114-Status: GOOD ( 15.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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 8d7ae28fbd67..85dd328ae1f6 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 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;