[PATCH] counter: interrupt-cnt: Convert atomic_t -> atomic_long_t

A. Sverdlin posted 1 patch 10 months, 1 week ago
drivers/counter/interrupt-cnt.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[PATCH] counter: interrupt-cnt: Convert atomic_t -> atomic_long_t
Posted by A. Sverdlin 10 months, 1 week ago
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
Re: [PATCH] counter: interrupt-cnt: Convert atomic_t -> atomic_long_t
Posted by William Breathitt Gray 9 months, 1 week ago
On Mon, 31 Mar 2025 17:22:20 +0200, A. Sverdlin wrote:
> 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
> 
> [...]

Applied, thanks!

[1/1] counter: interrupt-cnt: Convert atomic_t -> atomic_long_t
      commit: 08e2a660b1601963ced37ac8e8d8c134a97f167e

Best regards,
-- 
William Breathitt Gray <wbg@kernel.org>
Re: [PATCH] counter: interrupt-cnt: Convert atomic_t -> atomic_long_t
Posted by Sverdlin, Alexander 9 months, 1 week ago
Dear maintainers,

On Mon, 2025-03-31 at 17:22 +0200, A. Sverdlin wrote:
> 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>

I've noticed that the patch has been marked as "Changes Requested" in
the patchwork, could it be a mistake? Because I never received any
change request.

> ---
>  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;
>  }

-- 
Alexander Sverdlin
Siemens AG
www.siemens.com
Re: [PATCH] counter: interrupt-cnt: Convert atomic_t -> atomic_long_t
Posted by Jonathan Cameron 9 months, 1 week ago
On Fri, 2 May 2025 09:24:18 +0000
"Sverdlin, Alexander" <alexander.sverdlin@siemens.com> wrote:

> Dear maintainers,
> 
> On Mon, 2025-03-31 at 17:22 +0200, A. Sverdlin wrote:
> > 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>  
> 
> I've noticed that the patch has been marked as "Changes Requested" in
> the patchwork, could it be a mistake? Because I never received any
> change request.

Probably a miss click by me if you mean the IIO patchwork.
I tend to mark all counter stuff as handled elsewhere rather than keeping
track of it in that patchwork instance. 

Jonathan

> 
> > ---
> >  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;
> >  }  
> 
Re: [PATCH] counter: interrupt-cnt: Convert atomic_t -> atomic_long_t
Posted by Oleksij Rempel 9 months, 1 week ago
Hi Alexander,

On Fri, May 02, 2025 at 09:24:18AM +0000, Sverdlin, Alexander wrote:
> Dear maintainers,
> 
> On Mon, 2025-03-31 at 17:22 +0200, A. Sverdlin wrote:
> > 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>
> 
> I've noticed that the patch has been marked as "Changes Requested" in
> the patchwork, could it be a mistake? Because I never received any
> change request.

Sorry for delay
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |