Skip to content
Snippets Groups Projects
Commit 90c6f046 authored by Alessandro Rubini's avatar Alessandro Rubini
Browse files

zio-trigger.h: offer zio_generic_data_done() as inline function


The function used to be called __zio_internal_data_done, in
heklpers.c.  Being used once only, it was expanded inline by the
compiler, so nothing changes for previous code.

However, if a trigger needs to implement its own data_done method, it
will most likely need to replicate this code, so it's better made
avaiable directly to everybody.  An alternative would be running this
code every time, before or after calling t_op->data_done, but we'd
better let each trigger choose the order of its own operations.

Actually, there is one difference: the input active block is set to NULL
after being stored to the current buffer, so the later implementation
of stop_io (used in zio-irq-tdc.c) won't expose a bug.

Signed-off-by: default avatarAlessandro Rubini <rubini@gnudd.com>
Acked-by: default avatarFederico Vaga <federico.vaga@gmail.com>
parent a496ca04
Branches
Tags
No related merge requests found
......@@ -16,51 +16,6 @@
#include <linux/zio-trigger.h>
#include "zio-internal.h"
/* The trigger is armed and the cset spin lock is taken */
static void __zio_internal_data_done(struct zio_cset *cset)
{
struct zio_buffer_type *zbuf;
struct zio_device *zdev;
struct zio_channel *chan;
struct zio_block *block;
struct zio_ti *ti;
struct zio_bi *bi;
pr_debug("%s:%d\n", __func__, __LINE__);
ti = cset->ti;
zdev = cset->zdev;
zbuf = cset->zbuf;
if (unlikely((ti->flags & ZIO_DIR) == ZIO_DIR_OUTPUT)) {
chan_for_each(chan, cset) {
bi = chan->bi;
block = chan->active_block;
if (block)
zbuf->b_op->free_block(chan->bi, block);
/* We may have a new block ready, or not */
chan->active_block = zbuf->b_op->retr_block(chan->bi);
}
return;
}
/* DIR_INPUT */
chan_for_each(chan, cset) {
bi = chan->bi;
block = chan->active_block;
if (!block)
continue;
/* Copy the stamp: it is cset-wide so it lives in the trigger */
chan->current_ctrl->tstamp.secs = ti->tstamp.tv_sec;
chan->current_ctrl->tstamp.ticks = ti->tstamp.tv_nsec;
chan->current_ctrl->tstamp.bins = ti->tstamp_extra;
memcpy(zio_get_ctrl(block), chan->current_ctrl,
ZIO_CONTROL_SIZE);
if (zbuf->b_op->store_block(bi, block)) /* may fail, no prob */
zbuf->b_op->free_block(bi, block);
}
}
/*
* zio_trigger_data_done
* This is a ZIO helper to invoke the data_done trigger operation when a data
......@@ -76,7 +31,7 @@ void zio_trigger_data_done(struct zio_cset *cset)
if (cset->ti->t_op->data_done)
cset->ti->t_op->data_done(cset);
else
__zio_internal_data_done(cset);
zio_generic_data_done(cset);
cset->ti->flags &= ~ZIO_TI_ARMED;
spin_unlock(&cset->lock);
......
......@@ -108,4 +108,54 @@ struct zio_trigger_operations {
void zio_trigger_data_done(struct zio_cset *cset);
int zio_trigger_abort_disable(struct zio_cset *cset, int disable);
/*
* This generic_data_done can be used by triggers, as part of their own.
* If not trigger-specific function is specified, the core calls this one.
* When data_done is called, the trigger is armed and the cset lock is taken
*/
static inline void zio_generic_data_done(struct zio_cset *cset)
{
struct zio_buffer_type *zbuf;
struct zio_device *zdev;
struct zio_channel *chan;
struct zio_block *block;
struct zio_ti *ti;
struct zio_bi *bi;
pr_debug("%s:%d\n", __func__, __LINE__);
ti = cset->ti;
zdev = cset->zdev;
zbuf = cset->zbuf;
if (unlikely((ti->flags & ZIO_DIR) == ZIO_DIR_OUTPUT)) {
chan_for_each(chan, cset) {
bi = chan->bi;
block = chan->active_block;
if (block)
zbuf->b_op->free_block(chan->bi, block);
/* We may have a new block ready, or not */
chan->active_block = zbuf->b_op->retr_block(chan->bi);
}
return;
}
/* DIR_INPUT */
chan_for_each(chan, cset) {
bi = chan->bi;
block = chan->active_block;
if (!block)
continue;
/* Copy the stamp: it is cset-wide so it lives in the trigger */
chan->current_ctrl->tstamp.secs = ti->tstamp.tv_sec;
chan->current_ctrl->tstamp.ticks = ti->tstamp.tv_nsec;
chan->current_ctrl->tstamp.bins = ti->tstamp_extra;
memcpy(zio_get_ctrl(block), chan->current_ctrl,
ZIO_CONTROL_SIZE);
if (zbuf->b_op->store_block(bi, block)) /* may fail, no prob */
zbuf->b_op->free_block(bi, block);
chan->active_block = NULL;
}
}
#endif /* __ZIO_TRIGGER_H__ */
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment