counter: stm32-timer-cnt: Use TIM_DIER_CCxIE(x) instead of TIM_DIER_CCxIE(x)
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>
Wed, 19 Jun 2024 10:11:44 +0000 (12:11 +0200)
committerLee Jones <lee@kernel.org>
Wed, 26 Jun 2024 15:09:55 +0000 (16:09 +0100)
These two defines have the same purpose and this change doesn't
introduce any differences in drivers/counter/stm32-timer-cnt.o.

The only difference between the two is that

TIM_DIER_CC_IE(1) == TIM_DIER_CC2IE

while

TIM_DIER_CCxIE(1) == TIM_DIER_CC1IE

. That makes it necessary to have an explicit "+ 1" in the user code,
but IMHO this is a good thing as this is the code locatation that
"knows" that for software channel 1 you have to use TIM_DIER_CC2IE
(because software guys start counting at 0, while the relevant hardware
designer started at 1).

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Acked-by: William Breathitt Gray <wbg@kernel.org>
Link: https://lore.kernel.org/r/126bd153a03f39e42645573eecf44ffab5354fc7.1718791090.git.u.kleine-koenig@baylibre.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/counter/stm32-timer-cnt.c

index 0664ef969f797cd3bc74c13fe8ecf0972feb020d..186e73d6ccb455d57c70566a281c62d5299ebe0f 100644 (file)
@@ -465,7 +465,7 @@ static int stm32_count_events_configure(struct counter_device *counter)
                        ret = stm32_count_capture_configure(counter, event_node->channel, true);
                        if (ret)
                                return ret;
-                       dier |= TIM_DIER_CC_IE(event_node->channel);
+                       dier |= TIM_DIER_CCxIE(event_node->channel + 1);
                        break;
                default:
                        /* should never reach this path */
@@ -478,7 +478,7 @@ static int stm32_count_events_configure(struct counter_device *counter)
 
        /* check for disabled capture events */
        for (i = 0 ; i < priv->nchannels; i++) {
-               if (!(dier & TIM_DIER_CC_IE(i))) {
+               if (!(dier & TIM_DIER_CCxIE(i + 1))) {
                        ret = stm32_count_capture_configure(counter, i, false);
                        if (ret)
                                return ret;