From patchwork Wed Nov 11 16:38:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 11898179 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=-12.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 883B6C5517A for ; Wed, 11 Nov 2020 16:39:13 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 EF2CE2072C for ; Wed, 11 Nov 2020 16:39:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="u6qGDPGu"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S6ejkkcP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF2CE2072C 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=SI4ng+meRooDpIPWOUJrMdo5yBGSo7Q7WwMUujc4cnw=; b=u6qGDPGuj8bi9KxZfOoksnqpMz MVtU/a9sXB8HJlEgI2sRTRn3cl7JtoGllinFcrmK+f8YZOvNMhfBNr6/TZ2Au3hElH917BfdZxsRB U14ospCOVmA3WQWGg27lc4rTXcGGQl+qrMiv7E1snDUFOcmbhzZRngU9aE2pWqj/p8GWeakrMXmHa Fa4WpEdssTU2498RPSqDxHoQs6mrZ9eTKU4RIJXEC9sNUAJ1zS9cvyyLojLDklO2Z5YH8e4kigOAT PyRqY1GsgsadpSH9juLJuwM6xhtRpD1whENm3APC8J1ODc9I7bpkjk/Yk99ctqu/8dSp5KTTa+k6w UX9xsENg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kct8o-0007IS-7o; Wed, 11 Nov 2020 16:38:38 +0000 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kct8l-0007I5-Er for linux-arm-kernel@lists.infradead.org; Wed, 11 Nov 2020 16:38:36 +0000 Received: by mail-qk1-x743.google.com with SMTP id q5so2198591qkc.12 for ; Wed, 11 Nov 2020 08:38:35 -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=5Ie/2g6h8fCMTgltIfv3Rfz0bo0YdcuquD7nLS1t6eg=; b=S6ejkkcPJz8EcNc+0Mp1+79wtHpaIv3/yiOHomedgDAmUL0q48zC8AH5XHUQtv6lSi N55COLQs1QlJnTjju6+m7I8aZ17xngDMxitQ2NGkZe1Mi2u6GrDqwod9mGajVSHmIrp4 MHqzwbPMKZxM6OlhSwZQgflmOz/Cqqp/GzM6qII7PqwivMcTl+KYpX0VcrRKoAgfyHb4 H23koW2AgNrmVyUyRBDdQ0vNWIPHX5hpeVZA3QSvblJ10P1Cd+GR7LawX+RfH9y070/V O/QkwXRy/BeBu6Uvk3hHcCqovgJ6wp7C3FFXHY6FePX9RskbRGCngoGs2t6aYZKu3Z1b U0dA== 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=5Ie/2g6h8fCMTgltIfv3Rfz0bo0YdcuquD7nLS1t6eg=; b=Wt5SFOO+ZhLHDha18OvipRLnwBFqBsGQ1cvRtcfZ3smh+PdAuvDxhIeK25eCCSWxpM 4s25hrR/oxySroC+gsevL1fND9EhdOk9Fxt3oBwjVoHNDTn3WjpvB86ZGJctqes54V7I s+hU99pMPCz10NGmeXztrb0HScmIEH+rO3FziP97QLFoiLg6O4XKk6RuzMvNUsCDDyYA iNCrkXnk70CuaeY0zW7VCjtKbS/rkiOS6tS0gYYIAoRVDc5Gzdn80ukrjT4DstxHzOqz xwbacOI6tN54+FxINzbFyJmQveBPAilmxDntLs5HHQ0v0BEZmFqnfJfh1lo9u8T27mUB t9LQ== X-Gm-Message-State: AOAM530zI6UwzjeNM+5hVkPm0PJiAF5Gr4/hV0DPZKx62VXoVCNSDQgi VOthAAEd65CqMoNmf7eC9ZA= X-Google-Smtp-Source: ABdhPJyIbrh+4qgDsQQCVk/MHG7XDX40xL7zIDdJhzoJah7E7HCKx5G8Vxr7QIfkf5GgrQLhig7LVQ== X-Received: by 2002:a37:4ac4:: with SMTP id x187mr25631324qka.197.1605112713595; Wed, 11 Nov 2020 08:38:33 -0800 (PST) Received: from localhost.localdomain (072-189-064-225.res.spectrum.com. [72.189.64.225]) by smtp.gmail.com with ESMTPSA id l28sm2615051qkl.7.2020.11.11.08.38.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2020 08:38:32 -0800 (PST) From: William Breathitt Gray To: jic23@kernel.org Subject: [PATCH] counter: microchip-tcb-capture: Fix CMR value check Date: Wed, 11 Nov 2020 11:38:07 -0500 Message-Id: <20201111163807.10201-1-vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201111_113835_538662_04378C6D X-CRM114-Status: GOOD ( 12.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kamel Bouhara , alexandre.belloni@bootlin.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, William Breathitt Gray , robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Signed-off-by: William Breathitt Gray Acked-by: Alexandre Belloni --- 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..142b389fc9db 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_BOTH) { + 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; }