Commit 9064247e authored by Federico Vaga's avatar Federico Vaga

kernel: simplify overflow control function

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent b421b551
......@@ -358,7 +358,7 @@ static int zfad_input_cset_software(struct fa_dev *fa, struct zio_cset *cset)
int err;
/* Check if device memory allows this acquisition */
err = zfat_overflow_detection(cset->ti, ZFAT_POST, cset->ti->nsamples);
err = zfat_overflow_detection(cset->ti);
if (err)
return err;
tmp = kzalloc(sizeof(struct zfad_block), GFP_ATOMIC);
......
......@@ -308,8 +308,7 @@ static int zfat_arm_trigger(struct zio_ti *ti)
dev_dbg(msgdev, "Arming trigger\n");
/* Check if device memory allows this trigger configuration */
err = zfat_overflow_detection(ti, ZFAT_POST,
ti_zattr[ZIO_ATTR_TRIG_POST_SAMP].value);
err = zfat_overflow_detection(ti);
if (err)
return err;
......
......@@ -401,31 +401,23 @@ struct zfad_block {
/* Global variable exported by fa-zio-trg.c */
extern struct zio_trigger_type zfat_type;
static inline int zfat_overflow_detection(struct zio_ti *ti, unsigned int addr,
uint32_t val)
static inline int zfat_overflow_detection(struct zio_ti *ti)
{
struct fa_dev *fa = ti->cset->zdev->priv_d;
struct zio_attribute *ti_zattr = ti->zattr_set.std_zattr;
uint32_t pre_t, post_t, nshot_t, nsamples;
uint32_t nshot_t, nsamples;
size_t shot_size;
if (!addr)
return 0;
pre_t = addr == ZFAT_PRE ? val :
ti_zattr[ZIO_ATTR_TRIG_PRE_SAMP].value;
post_t = addr == ZFAT_POST ? val :
ti_zattr[ZIO_ATTR_TRIG_POST_SAMP].value;
if (ti->cset->trig != &zfat_type)
nshot_t = 1; /* with any other trigger work in one-shot mode */
else
nshot_t = addr == ZFAT_SHOTS_NB ? val :
ti_zattr[ZIO_ATTR_TRIG_N_SHOTS].value;
nshot_t = ti_zattr[ZIO_ATTR_TRIG_N_SHOTS].value;
/*
* +2 because of the timetag at the end
*/
nsamples = pre_t + post_t;
nsamples = ti_zattr[ZIO_ATTR_TRIG_PRE_SAMP].value +
ti_zattr[ZIO_ATTR_TRIG_POST_SAMP].value;
shot_size = ((nsamples + 2) * ti->cset->ssize) * FA100M14B4C_NCHAN;
if ( (shot_size * nshot_t) > FA100M14B4C_MAX_ACQ_BYTE ) {
dev_err(&ti->head.dev, "Cannot acquire, dev memory overflow\n");
......
Markdown is supported
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