From 45cdf3c4218dab39f890a33ad63f4bc501d9d60d Mon Sep 17 00:00:00 2001 From: Federico Vaga <federico.vaga@gmail.com> Date: Sun, 8 Jan 2012 13:32:42 +0100 Subject: [PATCH] trigger fire: check if trigger is busy When a trigger fire it is set to STATUS_ON until data_done(); so, one transfer at time is allowed. Signed-off-by: Federico Vaga <federico.vaga@gmail.com> Acked-by: Alessandro Rubini <rubini@gnudd.com> --- include/linux/zio-trigger.h | 8 ++++++++ zio-sys.c | 11 +++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/linux/zio-trigger.h b/include/linux/zio-trigger.h index e4088de..f9460f2 100644 --- a/include/linux/zio-trigger.h +++ b/include/linux/zio-trigger.h @@ -51,6 +51,14 @@ struct zio_ti { const struct file_operations *f_op; }; + +/* first 4bit are reserved for zio object universal flags */ +enum zti_flag_mask { + ZTI_STATUS = 0x10, + ZTI_STATUS_OFF = 0x00, /* trigger is idle */ + ZTI_STATUS_ON = 0x10, /* trigger fire and transfer occurs */ +}; + #define to_zio_ti(_kobj) container_of(_kobj, struct zio_ti, head.kobj) void zio_fire_trigger(struct zio_ti *ti); diff --git a/zio-sys.c b/zio-sys.c index 09be9e5..60dd71a 100644 --- a/zio-sys.c +++ b/zio-sys.c @@ -122,7 +122,7 @@ void zio_generic_data_done(struct zio_cset *cset) /* We may have a new block ready, or not */ chan->active_block = zbuf->b_op->retr_block(chan->bi); } - return; + goto out; } /* DIR_INPUT */ cset_for_each(cset, chan) { @@ -133,6 +133,8 @@ void zio_generic_data_done(struct zio_cset *cset) if (zbuf->b_op->store_block(bi, block)) /* may fail, no prob */ zbuf->b_op->free_block(bi, block); } +out: + ti->flags &= (~ZTI_STATUS); } EXPORT_SYMBOL(zio_generic_data_done); @@ -152,8 +154,6 @@ static void __zio_fire_input_trigger(struct zio_ti *ti) pr_debug("%s:%d\n", __func__, __LINE__); - /* FIXME: check if a trigger is already pending */ - /* Allocate the buffer for the incoming sample, in active channels */ cset_for_each(cset, chan) { ctrl = zio_alloc_control(GFP_ATOMIC); @@ -204,7 +204,10 @@ void zio_fire_trigger(struct zio_ti *ti) /* If the trigger runs too early, ti->cset is still NULL */ if (!ti->cset) return; - + /* check if previouvs fire is still running*/ + if ((ti->flags & ZTI_STATUS) == ZTI_STATUS_ON) + return; + ti->flags |= ZTI_STATUS_ON; /* Copy the stamp (we are software driven anyways) */ ti->current_ctrl->tstamp.secs = ti->tstamp.tv_sec; ti->current_ctrl->tstamp.ticks = ti->tstamp.tv_nsec; -- GitLab