Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2146211pxb; Sat, 14 Nov 2020 15:31:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyx9bdo3EnJeTqyDgXhFZFiEhNYr8l75SEtSsgIF8kYUhiWA6Uss6yL0Fdw3oXCOpuGWpM X-Received: by 2002:a05:6402:1a58:: with SMTP id bf24mr8996213edb.191.1605396671798; Sat, 14 Nov 2020 15:31:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605396671; cv=none; d=google.com; s=arc-20160816; b=XnTqpy0hVK0r4h0BWikTf8QDhQ/tIFdqPTcf0tL+vtWvmfCskvgQ2+gaPorLHv6OP5 ctCWKKyz3FQGfXbk8Ul/qJYEfDg/y2sTojStzTdfWZP2BYzKHhol2bQlFiANOrI9P5/M mrwYLDqd19kr8NegHuvxDWR+fjvVniLFaJPWksJNVG23DQe51aXYqMAyOTK/vYW7v/I1 +mCKYs+8JBtpV+4mabKdi5hJT7Hq8VolRDkH9bYJaw70uTyvLMuILmQU0j5sHv4Dzl9b XqB7U2xenz5Rz/y72ejX3SkR8V7zMIa5n4xLgSNezS/dfDAKWKjwXeznQGriHe+yr/Z8 9/Dg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=pEEvmIH+xLHYOZ5QQR7HSpYTdM1EvSRmH2wXZTi8hzE=; b=jHYRZ67ZOkHDydFrqM2M77Z5nBe9Zfq+3PmCm3gduD40nDZkAQoK7OGjWU1u9rtBS9 bC9BLxuPXxJyhG1nAu2KVqzy532TF04YB+Z1oyAzHLxQyNjd01e4nrEhVqNjcRgTcbfy o4bop+DUus9qTtwxB5HDx/fjn2QR/vohSs7ajOtGNS9AmbZSHFLqlYqydMX4ttiaeDZp g/CPEykltc8TmGrutFnkfaTcV/R83rmlsYXfe3LSKeN9z1f4jm0udRgPpdWC5jq8wo6W cftpuqZGj/bu05avX8fbdiGhuZwYOz7jLkrIAZBasGx7+lRXpRp09MBV6eEtz2GOOyxv 2ITA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UbZRIwRO; 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 o1si8040034ejn.643.2020.11.14.15.30.47; Sat, 14 Nov 2020 15:31:11 -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=UbZRIwRO; 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 S1726310AbgKNX2Z (ORCPT + 99 others); Sat, 14 Nov 2020 18:28:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbgKNX2Y (ORCPT ); Sat, 14 Nov 2020 18:28:24 -0500 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C54EC0613D1; Sat, 14 Nov 2020 15:28:24 -0800 (PST) Received: by mail-qt1-x843.google.com with SMTP id p12so10109107qtp.7; Sat, 14 Nov 2020 15:28:24 -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:mime-version :content-transfer-encoding; bh=pEEvmIH+xLHYOZ5QQR7HSpYTdM1EvSRmH2wXZTi8hzE=; b=UbZRIwROaDs4ijKnxts5kDfUPWEXHMA8ejCVABuoIwxuCxnglLfjsfpMc27bhaB5Cn 6u/Pv/nLNiWiOgF7CIET1SOSjlQEZU3oNQ7k59UiF/GkpTY+c4l5DraPTDb53F1Y3IXP I4aNHL2ZbZU5l4Wsh05tpzmyN338vcXLlXm17ZXeveE1iTZz8HEnxaITnulNh5z5empS qeuAfgtfhi0FwdVC7zFNzVEFYUs/htAaKdv9hHzXTD+ijj8Jo0sfVA2olIQAyJBwn6Nb k37Npz5qY+r1N/0bHO/pbBqVt5O14Bb5tyP9ZxuYggvEoD9wAmPsXmrVXMGrFKa/2Wnk Ypbg== 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:mime-version :content-transfer-encoding; bh=pEEvmIH+xLHYOZ5QQR7HSpYTdM1EvSRmH2wXZTi8hzE=; b=VZF8jlqSzYqymkHvBEFZIbgl4EeqK65ui3TYny1fldE46+jSuUjHUIhf1hOHsndVGZ wbx/PxYRbbbAhH1qpsXgnApHZ+2SeSdhbc3Tv0VYpRojiB5tI6yB6Jmcq6RiEsAlR6Cu pCjaFB0hR+CY4L1+WhhbXOr3i01szErlG4aN+xG5fTYZL4tOwXaRhAjJd+i5WK/EKmfj JgmKi9DkzYqdcnVNu5WegsiBNYaNVVskxL0aL7JSbMqn9nBHW9v7A21IewRt0gfxfDOr kO/J+/yNXD+whKQ0VybKKBrxCdatCFtLP5QMhcP60cEQGFULwSt+Wf8sMl9pEIyyoK9W 08Mw== X-Gm-Message-State: AOAM5316D185cWL911TXaAjFT+tMI9jAObl74osVWyhUMnmnW1/8nbap ifrf/XP9FuqgdPSAiiY3PA0= X-Received: by 2002:a05:622a:86:: with SMTP id o6mr8106003qtw.147.1605396503546; Sat, 14 Nov 2020 15:28:23 -0800 (PST) Received: from localhost.localdomain (072-189-064-225.res.spectrum.com. [72.189.64.225]) by smtp.gmail.com with ESMTPSA id h125sm9630656qkc.36.2020.11.14.15.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Nov 2020 15:28:22 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Cc: robh+dt@kernel.org, alexandre.belloni@bootlin.com, linux-arm-kernel@lists.infradead.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, William Breathitt Gray , Kamel Bouhara Subject: [PATCH v2] counter: microchip-tcb-capture: Fix CMR value check Date: Sat, 14 Nov 2020 18:28:05 -0500 Message-Id: <20201114232805.253108-1-vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ATMEL_TC_ETRGEDG_* defines are not masks but rather possible values for CMR. This patch fixes the action_get() callback to properly check for these values rather than mask them. Fixes: 106b104137fd ("counter: Add microchip TCB capture counter") Cc: Kamel Bouhara Acked-by: Alexandre Belloni Signed-off-by: William Breathitt Gray --- drivers/counter/microchip-tcb-capture.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/counter/microchip-tcb-capture.c b/drivers/counter/microchip-tcb-capture.c index 039c54a78aa5..710acc0a3704 100644 --- a/drivers/counter/microchip-tcb-capture.c +++ b/drivers/counter/microchip-tcb-capture.c @@ -183,16 +183,20 @@ static int mchp_tc_count_action_get(struct counter_device *counter, regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr); - *action = MCHP_TC_SYNAPSE_ACTION_NONE; - - if (cmr & ATMEL_TC_ETRGEDG_NONE) + switch (cmr & ATMEL_TC_ETRGEDG) { + default: *action = MCHP_TC_SYNAPSE_ACTION_NONE; - else if (cmr & ATMEL_TC_ETRGEDG_RISING) + break; + case ATMEL_TC_ETRGEDG_RISING: *action = MCHP_TC_SYNAPSE_ACTION_RISING_EDGE; - else if (cmr & ATMEL_TC_ETRGEDG_FALLING) + break; + case ATMEL_TC_ETRGEDG_FALLING: *action = MCHP_TC_SYNAPSE_ACTION_FALLING_EDGE; - else if (cmr & ATMEL_TC_ETRGEDG_BOTH) + break; + case ATMEL_TC_ETRGEDG_BOTH: *action = MCHP_TC_SYNAPSE_ACTION_BOTH_EDGE; + break; + } return 0; } -- 2.29.2