summaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi
diff options
context:
space:
mode:
authorChris Opperman <eklikeroomys@gmail.com>2018-06-13 19:14:35 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-06-17 09:05:11 +0200
commit2665df51017b15119987913bfa39d02d71cb7232 (patch)
tree05f90d6c15d4ae1e54114d804acd52f6910208d1 /drivers/staging/comedi
parentfbe1be81b2840f4f5a25405e92cf67b69bafe9c1 (diff)
downloadblackbird-op-linux-2665df51017b15119987913bfa39d02d71cb7232.tar.gz
blackbird-op-linux-2665df51017b15119987913bfa39d02d71cb7232.zip
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: Chris Opperman <eklikeroomys@gmail.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi')
-rw-r--r--drivers/staging/comedi/drivers.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 9d733471ca2e..57dd63d548b7 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -473,21 +473,21 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice *s,
{
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
+ unsigned long long scans_left;
+ unsigned long long samples_left;
- if (cmd->stop_src == TRIG_COUNT) {
- unsigned int scans_left = __comedi_nscans_left(s, cmd->stop_arg);
- 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 (cmd->stop_src != TRIG_COUNT)
+ return nsamples;
- if (samples_left < nsamples)
- nsamples = samples_left;
- }
+ scans_left = __comedi_nscans_left(s, cmd->stop_arg);
+ 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;
}
EXPORT_SYMBOL_GPL(comedi_nsamples_left);
OpenPOWER on IntegriCloud