Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp436248pxb; Sat, 20 Feb 2021 08:34:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvJiYvlNwUC203OSk1UsASeHg4xTRl1PsZy4oz6seZXMnxGmDSD+YsETtuW5rU/HWZ5fU+ X-Received: by 2002:a17:906:9bf8:: with SMTP id de56mr13394668ejc.425.1613838848277; Sat, 20 Feb 2021 08:34:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613838848; cv=none; d=google.com; s=arc-20160816; b=Zj0qsLRnfeHzX+RSFigIxdYMMCSH/9OUhlKqKAmMzmombcnZSDCvGWqJXcuB/u0aN1 LDYDaac9lc8RVQ9QsL6tSj06vnOovxPms/xwWJG4qGt0dc5mhklXn7I/XicQeHyTgInJ p/zVNi0vcMtfOGy1IIHvP8/JFqpZoawrm7BtUYXRkFA9WCHxQn83Rm6eJEzG9bIIUxP2 eGFzX1ypGodxm/sZE10t5cs7Akz1bN0sxgNphgJmJRLbcHRsFGjGyatz3X+xO/SwyRUF 9R6UNuQc/6TNv4oBJLPfh/As7FJOmSk36XsQwRfybOqX5VLxSmIo+kEDYE4SOhsM1bwp jgaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=ihzSQU1VPZbn2yYTLCpMZ8Md74uPTutyPKGtlry1dT0=; b=OeweIvt9omY8jcr/5+Fov6hAOut9vio30VNcBhYK5JpPYiR3YBkPJdjr8gCEl6wJNZ aol4q3CoLE7jLpw8lkQm2rTvotGfpg9eodLgTc5dtYyU3sT9xvRRc0r8vRIJPDRn6PAQ aMFl/G35YbqmK8uRjDpnEYcbnPU4aFgJqFtPnT8f9mnM2KbNIeRhTtRpbPRMO8F+yIrD A5EnvRioQ9JZCT5Ckz869iSy2VtzZkpS8xQ9lJlNp5hQmPNikDhrxq36EJocSGD2Yb+A nr9M3Gc+7fCLCZ6l5GpMhRoDdvBco2/cknnTlWzR5qqtEZrgilUbExutpz8TQPgKl7nn nGWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=ky9BSwkW; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cy16si952374edb.431.2021.02.20.08.33.45; Sat, 20 Feb 2021 08:34:08 -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; dkim=fail header.i=@lechnology.com header.s=default header.b=ky9BSwkW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229884AbhBTQaz (ORCPT + 99 others); Sat, 20 Feb 2021 11:30:55 -0500 Received: from vern.gendns.com ([98.142.107.122]:59590 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229784AbhBTQat (ORCPT ); Sat, 20 Feb 2021 11:30:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ihzSQU1VPZbn2yYTLCpMZ8Md74uPTutyPKGtlry1dT0=; b=ky9BSwkWUReOIoFkYNxbbgO7DJ 3hvp2upv75H/ZJRaXJfC4p9uwtgTp8z2FeAr7FizSQDN7gMk0MyFpwVqUdgMjScoJV19A+XApqTVt 9Qiu0LPSJvZt5RjT1OHvw5kW295q+R/rltjdw8ag06P8RCdvf9NTg93nQfxBhaQYAXWVCWnDlA2+H cOcAq8O818XQ11i/NdqgpgDj53Czyd3Z+q7t1YFsOeRM1V+/+LqjzaEG0bWSecffXYXHjCnEpydkp mr/X0ToEJ5XfMxvNzcQHeC6BITZT7mB8zgJmhjCx/cFdSeCm0zTSAfddtrSeqjmdEE8y+zphEM190 YaFUrMuA==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:57396 helo=[192.168.0.134]) by vern.gendns.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lDV8u-00072X-Go; Sat, 20 Feb 2021 11:30:04 -0500 Subject: Re: [PATCH v8 03/22] counter: 104-quad-8: Return error when invalid mode during ceiling_write To: William Breathitt Gray , 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, 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 References: <2be0c071e7730ea16b8faa1efcd3d0d908e7f9db.1613131238.git.vilhelm.gray@gmail.com> From: David Lechner Message-ID: <8e7daaad-e824-a823-1465-327cbc90ab23@lechnology.com> Date: Sat, 20 Feb 2021 10:30:03 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <2be0c071e7730ea16b8faa1efcd3d0d908e7f9db.1613131238.git.vilhelm.gray@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/12/21 6:13 AM, William Breathitt Gray wrote: > The 104-QUAD-8 only has two count modes where a ceiling value makes > sense: Range Limit and Modulo-N. Outside of these two modes, setting a > ceiling value is an invalid operation -- so let's report it as such by > returning -EINVAL. > > Fixes: fc069262261c ("counter: 104-quad-8: Add lock guards - generic interface") > Cc: Syed Nayyar Waris > Signed-off-by: William Breathitt Gray > --- > drivers/counter/104-quad-8.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c > index 9691f8612be8..f0608b21196a 100644 > --- a/drivers/counter/104-quad-8.c > +++ b/drivers/counter/104-quad-8.c > @@ -714,13 +714,14 @@ static ssize_t quad8_count_ceiling_write(struct counter_device *counter, > switch (priv->count_mode[count->id]) { > case 1: > case 3: > + mutex_unlock(&priv->lock); > quad8_preset_register_set(priv, count->id, ceiling); > - break; > + return len; > } > > mutex_unlock(&priv->lock); > > - return len; > + return -EINVAL; > } > > static ssize_t quad8_count_preset_enable_read(struct counter_device *counter, > What happens if the register is written to when in the wrong mode? If it doesn't hurt anything, I would suggest always writing the register instead so that users don't have to know worry about the fact that the mode has to be set first.