Module: xenomai-head Branch: master Commit: 252538ed93089f58263629129d39fadd3199548a URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=252538ed93089f58263629129d39fadd3199548a
Author: Alexis Berlemont <alexis.berlem...@gmail.com> Date: Sat May 23 05:23:22 2009 +0200 Slightly optimize the function comedi_get_chan() --- ksrc/drivers/comedi/buffer.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ksrc/drivers/comedi/buffer.c b/ksrc/drivers/comedi/buffer.c index 305efd9..8187042 100644 --- a/ksrc/drivers/comedi/buffer.c +++ b/ksrc/drivers/comedi/buffer.c @@ -152,15 +152,21 @@ int comedi_get_chan(comedi_dev_t * dev, unsigned int type, int idx_subd) in this command... */ for (i = 0; i < cmd->nb_chan; i++) tmp_size += dev->transfer->subds[idx]->chan_desc-> - chans[CR_CHAN(cmd->chan_descs[i])].nb_bits / 8; + chans[CR_CHAN(cmd->chan_descs[i])].nb_bits; + + /* Translation bits -> bytes */ + tmp_size /= 8; tmp_count = dev->transfer->bufs[idx]->mng_count % tmp_size; + /* Translation bytes -> bits */ + tmp_count *= 8; + /* ...and find the channel the last munged sample was related with */ for (i = 0; tmp_count > 0 && i < cmd->nb_chan; i++) tmp_count -= dev->transfer->subds[idx]->chan_desc-> - chans[CR_CHAN(cmd->chan_descs[i])].nb_bits / 8; + chans[CR_CHAN(cmd->chan_descs[i])].nb_bits; if (tmp_count == 0) return i; _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git