staging: comedi: Improved readability of function comedi_nsamples_left.
PATCH v5 1/1 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.
---
Changes v5:
a) Moved additional text to below the cut-off line.
drivers/staging/comedi/drivers.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/staging/comedi/drivers.c +13 -13
@@ -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);
--
2.1.4
Quoted 11 lines · Chris Opperman
Improve readability of
comedi_nsamples_left:
a) Reduce nesting by using more return statements.
b) Declare variablesscans_leftandsamples_leftat start of function.
c) Change type ofscans_Leftto unsigned long long to avoid cast.Signed-off-by Chris Opperman <[email protected]>---
Changes v5:
a) Moved additional text to below the cut-off line.
The "Changes v5" text is a bit incomplete without the earlier change history, but let's forget that since the previous change history was a bit messed up anyway.
Quoted 43 lines
drivers/staging/comedi/drivers.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)drivers/staging/comedi/drivers.c +13
-14@@ -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); --
Quoted 2 lines
2.1.4
The actual patch looks fine thanks!
Signature · 4 lines
-=( Ian Abbott <[email protected]> || Web: www.mev.co.uk )=- -=( MEV Ltd. is a company registered in England & Wales. )=- -=( Registered number: 02862268. Registered address: )=- -=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-
Hi Ian,
Thank you! Are there any more steps for me to take to complete this patch process?
Kind Regards,
Chris Opperman
Quoted 5 lines · Chris Opperman
Hi Ian,
Thank you! Are there any more steps for me to take to complete this patch process?
No. You're done... Greg will apply the patch in a week or two and you'll get an email.
regards,
dan carpenter