diff mbox series

[v2,2/2] counter: interrupt-cnt: add counter_push_event()

Message ID 20220203135727.2374052-3-o.rempel@pengutronix.de (mailing list archive)
State Handled Elsewhere
Headers show
Series counter: push event on every pulse | expand

Commit Message

Oleksij Rempel Feb. 3, 2022, 1:57 p.m. UTC
Add counter_push_event() to notify user space about new pulses

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/counter/interrupt-cnt.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

William Breathitt Gray Feb. 4, 2022, 7:35 a.m. UTC | #1
On Thu, Feb 03, 2022 at 02:57:27PM +0100, Oleksij Rempel wrote:
> Add counter_push_event() to notify user space about new pulses
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>

This is a simple solution so if it works for your use-case I'm okay with
it; I think future counter devices could make use of this new
COUNTER_EVENT_CHANGE_OF_STATE event type too, so that's a plus.

I'm going to wait a week to give others time to chime in if they want.
Otherwise I'll give a proper approval for this series next week.

William Breathitt Gray

> ---
>  drivers/counter/interrupt-cnt.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/counter/interrupt-cnt.c b/drivers/counter/interrupt-cnt.c
> index 9e99702470c2..3b13f56bbb11 100644
> --- a/drivers/counter/interrupt-cnt.c
> +++ b/drivers/counter/interrupt-cnt.c
> @@ -26,10 +26,13 @@ struct interrupt_cnt_priv {
>  
>  static irqreturn_t interrupt_cnt_isr(int irq, void *dev_id)
>  {
> -	struct interrupt_cnt_priv *priv = dev_id;
> +	struct counter_device *counter = dev_id;
> +	struct interrupt_cnt_priv *priv = counter_priv(counter);
>  
>  	atomic_inc(&priv->count);
>  
> +	counter_push_event(counter, COUNTER_EVENT_CHANGE_OF_STATE, 0);
> +
>  	return IRQ_HANDLED;
>  }
>  
> @@ -209,7 +212,7 @@ static int interrupt_cnt_probe(struct platform_device *pdev)
>  	irq_set_status_flags(priv->irq, IRQ_NOAUTOEN);
>  	ret = devm_request_irq(dev, priv->irq, interrupt_cnt_isr,
>  			       IRQF_TRIGGER_RISING | IRQF_NO_THREAD,
> -			       dev_name(dev), priv);
> +			       dev_name(dev), counter);
>  	if (ret)
>  		return ret;
>  
> -- 
> 2.30.2
>
diff mbox series

Patch

diff --git a/drivers/counter/interrupt-cnt.c b/drivers/counter/interrupt-cnt.c
index 9e99702470c2..3b13f56bbb11 100644
--- a/drivers/counter/interrupt-cnt.c
+++ b/drivers/counter/interrupt-cnt.c
@@ -26,10 +26,13 @@  struct interrupt_cnt_priv {
 
 static irqreturn_t interrupt_cnt_isr(int irq, void *dev_id)
 {
-	struct interrupt_cnt_priv *priv = dev_id;
+	struct counter_device *counter = dev_id;
+	struct interrupt_cnt_priv *priv = counter_priv(counter);
 
 	atomic_inc(&priv->count);
 
+	counter_push_event(counter, COUNTER_EVENT_CHANGE_OF_STATE, 0);
+
 	return IRQ_HANDLED;
 }
 
@@ -209,7 +212,7 @@  static int interrupt_cnt_probe(struct platform_device *pdev)
 	irq_set_status_flags(priv->irq, IRQ_NOAUTOEN);
 	ret = devm_request_irq(dev, priv->irq, interrupt_cnt_isr,
 			       IRQF_TRIGGER_RISING | IRQF_NO_THREAD,
-			       dev_name(dev), priv);
+			       dev_name(dev), counter);
 	if (ret)
 		return ret;