Skip to content

Commit

Permalink
staging: comedi: comedi_fc: tidy up cfc_bytes_per_scan()
Browse files Browse the repository at this point in the history
This function returns the total number of bytes for a full scan of
an async command chanlist. The returned value is an unsigned int.

Change all the local variables to unsigned int and use a local
variable for the s->async->cmd.chanlist_len.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Mar 17, 2014
1 parent a3065bc commit 68ef50f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/staging/comedi/drivers/comedi_fc.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,20 @@ unsigned int cfc_handle_events(struct comedi_device *,

static inline unsigned int cfc_bytes_per_scan(struct comedi_subdevice *s)
{
int num_samples;
int bits_per_sample;
unsigned int chanlist_len = s->async->cmd.chanlist_len;
unsigned int num_samples;
unsigned int bits_per_sample;

switch (s->type) {
case COMEDI_SUBD_DI:
case COMEDI_SUBD_DO:
case COMEDI_SUBD_DIO:
bits_per_sample = 8 * bytes_per_sample(s);
num_samples = (s->async->cmd.chanlist_len +
bits_per_sample - 1) / bits_per_sample;
num_samples = (chanlist_len + bits_per_sample - 1) /
bits_per_sample;
break;
default:
num_samples = s->async->cmd.chanlist_len;
num_samples = chanlist_len;
break;
}
return num_samples * bytes_per_sample(s);
Expand Down

0 comments on commit 68ef50f

Please sign in to comment.