From patchwork Fri Mar 19 11:00:38 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: 12150819 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.7 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,URIBL_BLOCKED, 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 C539FC433E0 for ; Fri, 19 Mar 2021 11:08:59 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 0D68364F04 for ; Fri, 19 Mar 2021 11:08:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D68364F04 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=desiato.20200630; 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=lvnEgE8yP35wCC3USZ6cnIzUgY6l+Z2t67QaBzY+3f4=; b=TfJvkPyo/oFDt3MmbK8o5BHzR D6jJbEFejKZYMN6l2M8iaosQI6AndJaiq4D3qtEtf0E+rPC/ReWbuReLvJs3dmQZn4BIckD557UGn JcFZToORhI1it4lil7k8/1eDrEF2WAxIylruqGQZ2UjZsobjyiJEgKmXedJzvGcEp62t2Aj+ZTRtG zzmKiEDfUvOI5hl+gmZOu6rgdEryKWioajamOOqwSPoVEndWIBo2W92wWhwTmErVOhcmQFswTeDQD 6bGZwJbUMz9o8/p/ysb/qmqcjQTdBbwxxK+Ort+cNKdmjcB3O66gfxmFy6KxR/uIsRIhJXx7117ZV 4ImEWdjaQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNCxL-007FHl-83; Fri, 19 Mar 2021 11:06:15 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNCtr-007Dei-WC for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 11:02:43 +0000 Received: by mail-pf1-x430.google.com with SMTP id y200so5626906pfb.5 for ; Fri, 19 Mar 2021 04:02:39 -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=zPb+gWSSK34KYiB/GIEQN8ZRP7v+HVonTQM6Ywh1zp8=; b=GbwBST6OLctHRPpje6CQQ6A0Etw7HHv1ibi/PtZt9dyNRoMGuT/crP0iLQKj+aLj6I K/IwLftAjimPHfvY9mp3porI9HYjP7YXlIOnP1uJkPtYFabbNtskz2nJXNmU/rnVqQ2x 6HKZl7I0BLC//HE9GOXCad+5TGP1HsfWiGMnmOdcxhxnFB7qLpBLLEh5OiojaBuHNPUz ARmLhaNGvylVdtTbIT0UTfCa5UdaEJ2GwiQGtRgh3J0tbKxm6RjyhHxIkhkg8psrUO0m M/WP+Jnw1swX2FmDEitAolGz7NkD0SupqG/Y9GOTNuL5ZYt1Jq2JigRVC+rrdrnu8nq9 yXxg== 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=zPb+gWSSK34KYiB/GIEQN8ZRP7v+HVonTQM6Ywh1zp8=; b=ckwVrhtbQFhQ3wysRnaEnDNbiDLWnv0fXPY04Dc/quijt9rWC028NF6OZTIOaLeRdR XNB4jUbNLp05pi04Cx5Q4aNZSCuq5nXGQUzZKnjPYPFd8Qc2N0naWSRVzRct+qdUmtQB hFz0BMaDfMxbijjX9B+LFr5G+ny6wY7dA/2/6KfHomO++ldQkyiRadj2Q2z3hNc1/TgJ sFIgj1cK2HYkueUqL+fOJDoeGh8pnf8LfoS2VuSez7qe/Jqh/dwXh9q9bzwm/gqnqT3/ BIZcqDSBirI/pK86auCcbOzoyfAF+hvy76xlnrXPLyryV9IgzkaISEpd4d9OcorQnOQ2 +ijA== X-Gm-Message-State: AOAM532M2IM7h9qzAbNvl6W+y63DdGFhTPmkXP3m//F87srRQTGdjzwe TLyH22a2lsVoa4tJbMteR7w= X-Google-Smtp-Source: ABdhPJw5U90GgbXrwB9X3j7ERBM6UKrmDzqcszz+pkiLkuNCUFc69EhY4Lrh6+GU35xS6cCocLbUcA== X-Received: by 2002:a65:520d:: with SMTP id o13mr10970910pgp.57.1616151758644; Fri, 19 Mar 2021 04:02:38 -0700 (PDT) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id i22sm4879042pjz.56.2021.03.19.04.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 04:02:38 -0700 (PDT) From: William Breathitt Gray To: jic23@kernel.org 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, William Breathitt Gray Subject: [PATCH v10 19/33] counter: Standardize to ERANGE for limit exceeded errors Date: Fri, 19 Mar 2021 20:00:38 +0900 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210319_110241_473065_7F7EC702 X-CRM114-Status: GOOD ( 14.38 ) 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: Syed Nayyar Waris Cc: Oleksij Rempel Cc: Fabrice Gasnier Cc: Maxime Coquelin Cc: Alexandre Torgue Reviewed-by: David Lechner Signed-off-by: William Breathitt Gray Reviewed-by: Fabrice Gasnier Acked-by: Syed Nayyar Waris --- drivers/counter/104-quad-8.c | 6 +++--- drivers/counter/interrupt-cnt.c | 3 +++ drivers/counter/stm32-lptimer-cnt.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index b7d6c1c43655..0409b1771fd9 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/interrupt-cnt.c b/drivers/counter/interrupt-cnt.c index 0e07607f2cd3..f27dea317965 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;