From 08eedd5d1d316d71f3a3cf7541ae6438d39d4a5b Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Tue, 25 Jan 2005 23:41:58 +0000 Subject: [PATCH] fix rounding error in bytes_per_scan() for dio subdevices, noted by Ian Abbott . Also, round to nearest sampl_t or lsampl_t size, instead of nearest byte size. --- comedi/drivers/comedi_fc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/comedi/drivers/comedi_fc.c b/comedi/drivers/comedi_fc.c index fc0cedb8..629c4b6c 100644 --- a/comedi/drivers/comedi_fc.c +++ b/comedi/drivers/comedi_fc.c @@ -30,18 +30,22 @@ static inline unsigned int bytes_per_scan( comedi_subdevice *subd ) { + int num_samples; + int bits_per_sample; + switch( subd->type ) { case COMEDI_SUBD_DI: case COMEDI_SUBD_DO: case COMEDI_SUBD_DIO: - return subd->async->cmd.chanlist_len / 8; + bits_per_sample = 8 * bytes_per_sample(subd); + num_samples = (subd->async->cmd.chanlist_len + bits_per_sample - 1) / bits_per_sample; break; default: + num_samples = subd->async->cmd.chanlist_len; break; } - - return subd->async->cmd.chanlist_len * bytes_per_sample( subd ); + return num_samples * bytes_per_sample( subd ); } static void increment_scan_progress( comedi_subdevice *subd, unsigned int num_bytes ) -- 2.26.2