From patchwork Sat Nov 14 23:28:05 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: 11905889 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 56558C5519F for ; Sat, 14 Nov 2020 23:29:23 +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 8AA7924137 for ; Sat, 14 Nov 2020 23:29:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="w10VJUjy"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UbZRIwRO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8AA7924137 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=LvDkvoYvdAtTGK80U0PIT1gqdHoCB4IEG6mGtkV6dSI=; b=w10VJUjyFqurIuY2KgFmG4EPh5 4MJ1ApddQ4UNp+22dAPxqOLYYDCZEW0VDtIVZ+y1ak4LLF+SpJsqkQtWvPReQX3aTr2O0B6pglgs1 Eqpy2hW4HAwDk2a3wfD7LNBUUJaOY9WAnnW6AvEqx86Psmnov+y+N/nE6c/EgEtY/DgukVn7GnQMZ Hc2BzgfUtdEa1zYM3ZbWZR3/paooC/I5Nb5QOAl2o6J63RwQ4XqL8ZxcHg70YJkbDJCIvTVcmPioG 3PumH991OoxW8oRynhO/fYJJahnoEYM/q2H7G+PFYpexxRMb90hhx2yLcal7hzrumQ3nQYg/L9bam Gpd1/xVA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ke4y4-0008Mk-Ok; Sat, 14 Nov 2020 23:28:28 +0000 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ke4y1-0008MF-5F for linux-arm-kernel@lists.infradead.org; Sat, 14 Nov 2020 23:28:26 +0000 Received: by mail-qt1-x844.google.com with SMTP id 7so10134335qtp.1 for ; 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=Vxc7BxTseTuZUHQE9Mg7B0FJGH0kbVkEoTo1z/AgokwEksy/YL8QpguK85TmfFxADI MOSgbtmP0IBGNE3b77Y94pLVMuBsL+PJP1W4dtcR28DDrj2D5wnVfgO57eHyFD5q5Ovj HHochJQ3eltVL4ysi7c79je3ZjyrJbW9daKupAuWF5CnmjYArtcqPgMOqgnBcxGUeT1r eML58k3ARVU1e0AS+K2rWX5hlIgSkhEl6LW811SzJ/oXJPw2nQuocyTYM84CfM7co3jl bvRqnxzTUBS1N2KahbD9FvY/mFVoP9X0+6vTfU86S3K1A5tiM8y86yJO6RIJ8c45b/lq 3eaQ== X-Gm-Message-State: AOAM5336LW9rf23rJ87LgwhJbQhWUDFS5FURPAbVE44xa/C1Nn7Tw3si 0kWHDthDeuadToLj7XyMqe8= X-Google-Smtp-Source: ABdhPJz/Nm2vZQnKSMQPtQdgh8a7vdzmisfu6umiOzujJEmgdGL/Tu0tWzLcLzH2IcuwJpc7WHLEkg== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201114_182825_512345_A72906BF X-CRM114-Status: GOOD ( 12.37 ) 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 Acked-by: Alexandre Belloni Signed-off-by: William Breathitt Gray Acked-by: Kamel Bouhara --- 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; }