Re: [PATCH v1] counter: interrupt-cnt: add counter_push_event()

From: William Breathitt Gray
Date: Wed Nov 24 2021 - 01:09:16 EST


On Tue, Nov 23, 2021 at 02:45:40PM +0100, Oleksij Rempel wrote:
> Add counter_push_event() to notify user space about new pulses
>
> Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
> ---
> drivers/counter/interrupt-cnt.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/counter/interrupt-cnt.c b/drivers/counter/interrupt-cnt.c
> index 8514a87fcbee..b237137b552b 100644
> --- a/drivers/counter/interrupt-cnt.c
> +++ b/drivers/counter/interrupt-cnt.c
> @@ -31,6 +31,8 @@ static irqreturn_t interrupt_cnt_isr(int irq, void *dev_id)
>
> atomic_inc(&priv->count);
>
> + counter_push_event(&priv->counter, COUNTER_EVENT_OVERFLOW, 0);
> +
> return IRQ_HANDLED;
> }
>
> --
> 2.30.2

Hi Oleksij,

It looks like this is pushing a COUNTER_EVENT_OVERFLOW event every time
an interrupt is handled, which I suspect is not what you want to happen.
The COUNTER_EVENT_OVERFLOW event indicates a count value overflow event,
so you'll need to check for a count value overflow before pushing the
event.

It would be good idea to implement a ceiling extension as well (you can
use the COUNTER_COMP_CEILING() macro) so that users can configure the
particular point where the value overflows.

William Breathitt Gray

Attachment: signature.asc
Description: PGP signature