Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

counter: microchip-tcb-capture: Fix CMR value check

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")
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Kamel Bouhara <kamel.bouhara@bootlin.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20201114232805.253108-1-vilhelm.gray@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

William Breathitt Gray and committed by
Jonathan Cameron
3418bd7c 0449fc4e

+10 -6
+10 -6
drivers/counter/microchip-tcb-capture.c
··· 183 183 184 184 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr); 185 185 186 - *action = MCHP_TC_SYNAPSE_ACTION_NONE; 187 - 188 - if (cmr & ATMEL_TC_ETRGEDG_NONE) 186 + switch (cmr & ATMEL_TC_ETRGEDG) { 187 + default: 189 188 *action = MCHP_TC_SYNAPSE_ACTION_NONE; 190 - else if (cmr & ATMEL_TC_ETRGEDG_RISING) 189 + break; 190 + case ATMEL_TC_ETRGEDG_RISING: 191 191 *action = MCHP_TC_SYNAPSE_ACTION_RISING_EDGE; 192 - else if (cmr & ATMEL_TC_ETRGEDG_FALLING) 192 + break; 193 + case ATMEL_TC_ETRGEDG_FALLING: 193 194 *action = MCHP_TC_SYNAPSE_ACTION_FALLING_EDGE; 194 - else if (cmr & ATMEL_TC_ETRGEDG_BOTH) 195 + break; 196 + case ATMEL_TC_ETRGEDG_BOTH: 195 197 *action = MCHP_TC_SYNAPSE_ACTION_BOTH_EDGE; 198 + break; 199 + } 196 200 197 201 return 0; 198 202 }