All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] counter: interrupt-cnt: Convert atomic_t -> atomic_long_t
@ 2025-03-31 15:22 A. Sverdlin
  2025-05-02  9:24 ` Sverdlin, Alexander
  2025-05-02 15:11 ` William Breathitt Gray
  0 siblings, 2 replies; 5+ messages in thread
From: A. Sverdlin @ 2025-03-31 15:22 UTC (permalink / raw)
  To: linux-iio
  Cc: Alexander Sverdlin, Oleksij Rempel, Pengutronix Kernel Team,
	William Breathitt Gray, linux-kernel

From: Alexander Sverdlin <alexander.sverdlin@siemens.com>

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>
---
 drivers/counter/interrupt-cnt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/counter/interrupt-cnt.c b/drivers/counter/interrupt-cnt.c
index 949598d51575a..8df5457b0a076 100644
--- a/drivers/counter/interrupt-cnt.c
+++ b/drivers/counter/interrupt-cnt.c
@@ -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;
 }
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-05-05 12:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-31 15:22 [PATCH] counter: interrupt-cnt: Convert atomic_t -> atomic_long_t A. Sverdlin
2025-05-02  9:24 ` Sverdlin, Alexander
2025-05-02 12:19   ` Oleksij Rempel
2025-05-05 12:04   ` Jonathan Cameron
2025-05-02 15:11 ` William Breathitt Gray

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.