Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2543145pxb; Tue, 9 Mar 2021 05:22:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+C7prWI8G+XeZl8DCXp4Bzz0yhVKY0q3ZTn8pN4oOhuBhuVe3ctG28bjdtVUjIykGra7y X-Received: by 2002:a17:906:d153:: with SMTP id br19mr19811376ejb.360.1615296133822; Tue, 09 Mar 2021 05:22:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615296133; cv=none; d=google.com; s=arc-20160816; b=pVpLUY0t8zBXAx+4/LpR/pzUmJV5xwWhKT0v2W0MIGjUuc0kNk5Br+tCzCNJ4gnVWP c43thZAbb37DwndR7u+u8OTwPggtgWUM3FimSgF9pp/lH2zwWzZaKjsI0FKnCyvjpLKl bBoVq3dC7d8ciq7Tc70af1V+IJoEX7yJZPFbJq1Cz3RoN1zfpSjvyM5N2IcDQNkFXGy9 YLeexbRg7wHYIhAtAdmdyKQ8pe6lkbvxNUkQK727oZyDlq+NkiBwG6Muv3i1vDGzibDT BexILPqJtwElUO+jCDR+GkfeJaL9CKtgwP84Apt9I56JLWTfGYv4IsyBkryv+wvOgzdX eaAw== 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:date:subject:cc:to:from :dkim-signature; bh=Uo8aZJ7uFJm9IN0X5m8O12CJstLR4Mg3ThLr0VJ0OLA=; b=H5w3ApD03LkpulODj2ZLXBr6AZHWn1PeUL5nMZYsSWuLDSrI86+dNFwki9UPeJd4la 1ZALCzkX+8pp/Wf87mUIQWD9uIcRrRid7M1rUxzNcgw1Mep7bX3eWf6LbyNeZQCLc6Ot mlVWbRneDbpSb0nnE+Y61BhnL28gyZQ3gXicOKVbRAACdNtIE84IrnLqAp3kC++E7CQh xfujKE61Vo9+jwWyKfJuu/XlRFhX6AE+6XE+AZdeYkzCrl3+Znmbi0gTrR0W6FAyFeVh 7J6gQrq+Hd8G7Zv2GJdgCOshMiVG9YuGT7Gnh4mmHo4kp0nUNskMZY+PxPmrpi09X/tA ia0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iyVwdDeb; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d2si3137101ejm.291.2021.03.09.05.21.51; Tue, 09 Mar 2021 05:22: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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iyVwdDeb; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231200AbhCINU7 (ORCPT + 99 others); Tue, 9 Mar 2021 08:20:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231131AbhCINUc (ORCPT ); Tue, 9 Mar 2021 08:20:32 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81AD7C06174A; Tue, 9 Mar 2021 05:20:32 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id c16so6568703ply.0; Tue, 09 Mar 2021 05:20:32 -0800 (PST) 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=Uo8aZJ7uFJm9IN0X5m8O12CJstLR4Mg3ThLr0VJ0OLA=; b=iyVwdDeb0d9ar/SgQS8NCqCJF8zBmbqYEU7YVIcfERfeXU9rRk+X9zQwpng9qVLZda d1yQFwkRQ8moVuHOC4RaL4Eo+CI1Jg13S3Hg6IASCNLMFxuYym7guA7qAb4WPvmIhWn6 P/fdq6zIxxYWhKwBGjfuOapE0xGM0vv5wE20G+6Ri5Twoc+Wx5yUlWsdz13BfRWUowNs saUOHkge4Z82XVoDKISrpPzLWDywMrP/a+UBj+RSFBKZNgXdtK1ZH2UiUnola7ptT952 yBn8kK5z87O+8qTLztPBkh6iP7/J+wmtH/wZUR+UVgqVXKcvt1/VcQUQF/CG6wjMMSJy lFzQ== 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=Uo8aZJ7uFJm9IN0X5m8O12CJstLR4Mg3ThLr0VJ0OLA=; b=oc1KcUyDV8LjJQ11TAx/r83sWhaFHFd/tACCdEQC6KYxUkxRXONjX+0Dvxl9JE+0bX zCPYI8+bOlV0KiUB2EVJ+NtaClo81W8MxGRyLKHVai+pzrJ9I6xnfNplb8IttOseFW0e VaKXTmw8uKKdtqZUpcav8INtcTwjTCV8CU5IyRH15tKFJOEcWJw3AkI2/DxuoZnV6QBF YnALzTqmD3+AihLrFxC5V5KkxvMMGRIvxTEH1iwgqNbiF9/Bc9j0bvfZM8oP9BHHhhvd DLUJG4yif/P3w58f1gMLnkSeanTrw0lR7IAm5HqAEWy779Ce/ay6UY0yz5iY9btmUp0m mlWA== X-Gm-Message-State: AOAM531pbiuAoWNWzN4UVTQ0Nc5zYTP3kKj3qirHV+f/yzWGfFgTp2so Q4J+9fJS8BgNNU39Pkekoqk= X-Received: by 2002:a17:90a:cca:: with SMTP id 10mr4613485pjt.103.1615296032134; Tue, 09 Mar 2021 05:20:32 -0800 (PST) Received: from localhost.localdomain ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id y9sm7647421pfl.201.2021.03.09.05.20.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 05:20:31 -0800 (PST) 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 v9 04/33] counter: 104-quad-8: Return error when invalid mode during ceiling_write Date: Tue, 9 Mar 2021 22:19:17 +0900 Message-Id: X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 4bb9abffae48..233a3acc1377 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, -- 2.30.1