Commit 2665df51 authored by Chris Opperman's avatar Chris Opperman Committed by Greg Kroah-Hartman

staging: comedi: Improved readability of function comedi_nsamples_left.

Improve readability of comedi_nsamples_left:
a) Reduce nesting by using more return statements.
b) Declare variables scans_left and samples_left at start of function.
c) Change type of scans_Left to unsigned long long to avoid cast.
Signed-off-by: default avatarChris Opperman <eklikeroomys@gmail.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fbe1be81
...@@ -473,21 +473,21 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice *s, ...@@ -473,21 +473,21 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice *s,
{ {
struct comedi_async *async = s->async; struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd; struct comedi_cmd *cmd = &async->cmd;
unsigned long long scans_left;
unsigned long long samples_left;
if (cmd->stop_src == TRIG_COUNT) { if (cmd->stop_src != TRIG_COUNT)
unsigned int scans_left = __comedi_nscans_left(s, cmd->stop_arg); return nsamples;
unsigned int scan_pos =
comedi_bytes_to_samples(s, async->scan_progress);
unsigned long long samples_left = 0;
if (scans_left) {
samples_left = ((unsigned long long)scans_left *
cmd->scan_end_arg) - scan_pos;
}
if (samples_left < nsamples) scans_left = __comedi_nscans_left(s, cmd->stop_arg);
nsamples = samples_left; if (!scans_left)
} return 0;
samples_left = scans_left * cmd->scan_end_arg -
comedi_bytes_to_samples(s, async->scan_progress);
if (samples_left < nsamples)
return samples_left;
return nsamples; return nsamples;
} }
EXPORT_SYMBOL_GPL(comedi_nsamples_left); EXPORT_SYMBOL_GPL(comedi_nsamples_left);
......
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