]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
counter: interrupt-cnt: Convert atomic_t -> atomic_long_t
authorAlexander Sverdlin <alexander.sverdlin@siemens.com>
Mon, 31 Mar 2025 15:22:20 +0000 (17:22 +0200)
committerWilliam Breathitt Gray <wbg@kernel.org>
Fri, 2 May 2025 13:46:01 +0000 (22:46 +0900)
Convert the internal counter type to atomic_long_t, which:
- doesn't change much for existing in-tree users as they are 32-bit anyway
  (stm32/i.MX6)
- doesn't introduce performace penalty on 32-bit platforms
- provides 64-bit resolution on 64-bit platforms with virtually no
  preformance penalty

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://lore.kernel.org/r/20250331152222.2263776-1-alexander.sverdlin@siemens.com
Signed-off-by: William Breathitt Gray <wbg@kernel.org>
drivers/counter/interrupt-cnt.c

index 949598d51575a1a2e575095f298d7fe8fae3e14c..8df5457b0a0765dd0c9bdabb3ca39b2eec949e82 100644 (file)
@@ -15,7 +15,7 @@
 #define INTERRUPT_CNT_NAME "interrupt-cnt"
 
 struct interrupt_cnt_priv {
-       atomic_t count;
+       atomic_long_t count;
        struct gpio_desc *gpio;
        int irq;
        bool enabled;
@@ -29,7 +29,7 @@ static irqreturn_t interrupt_cnt_isr(int irq, void *dev_id)
        struct counter_device *counter = dev_id;
        struct interrupt_cnt_priv *priv = counter_priv(counter);
 
-       atomic_inc(&priv->count);
+       atomic_long_inc(&priv->count);
 
        counter_push_event(counter, COUNTER_EVENT_CHANGE_OF_STATE, 0);
 
@@ -89,7 +89,7 @@ static int interrupt_cnt_read(struct counter_device *counter,
 {
        struct interrupt_cnt_priv *priv = counter_priv(counter);
 
-       *val = atomic_read(&priv->count);
+       *val = atomic_long_read(&priv->count);
 
        return 0;
 }
@@ -102,7 +102,7 @@ static int interrupt_cnt_write(struct counter_device *counter,
        if (val != (typeof(priv->count.counter))val)
                return -ERANGE;
 
-       atomic_set(&priv->count, val);
+       atomic_long_set(&priv->count, val);
 
        return 0;
 }