diff mbox series

Add early return to Method because the else can be ignored.

Message ID 20210324122050.GA28987@kernel-dev (mailing list archive)
State New, archived
Headers show
Series Add early return to Method because the else can be ignored. | expand

Commit Message

Swen Kalski March 24, 2021, 12:20 p.m. UTC
---
 drivers/staging/comedi/comedi_buf.c | 56 ++++++++++++++---------------
 1 file changed, 28 insertions(+), 28 deletions(-)

Comments

Greg Kroah-Hartman March 24, 2021, 12:32 p.m. UTC | #1
On Wed, Mar 24, 2021 at 01:20:50PM +0100, Swen Kalski wrote:
> ---
>  drivers/staging/comedi/comedi_buf.c | 56 ++++++++++++++---------------
>  1 file changed, 28 insertions(+), 28 deletions(-)
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch does not have a Signed-off-by: line.  Please read the
  kernel file, Documentation/SubmittingPatches and resend it after
  adding that line.  Note, the line needs to be in the body of the
  email, before the patch, not at the bottom of the patch or in the
  email signature.

- You did not specify a description of why the patch is needed, or
  possibly, any description at all, in the email body.  Please read the
  section entitled "The canonical patch format" in the kernel file,
  Documentation/SubmittingPatches for what is needed in order to
  properly describe the change.

- You did not write a descriptive Subject: for the patch, allowing Greg,
  and everyone else, to know what this patch is all about.  Please read
  the section entitled "The canonical patch format" in the kernel file,
  Documentation/SubmittingPatches for what a proper Subject: line should
  look like.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot
Jonathan Cameron March 26, 2021, 11:31 a.m. UTC | #2
On Wed, 24 Mar 2021 13:20:50 +0100
Swen Kalski <kalski.swen@gmail.com> wrote:

IIO isn't the right list for comedi related patches.
Take a look at MAINTAINERS

However it is marked odd fixes only so I'm not sure on how receptive
they will be to tidying up like this.

+ all the stuff in Greg's 'bot' response :)

Jonathan



> ---
>  drivers/staging/comedi/comedi_buf.c | 56 ++++++++++++++---------------
>  1 file changed, 28 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c
> index 3ef3ddabf139..05927fb321ba 100644
> --- a/drivers/staging/comedi/comedi_buf.c
> +++ b/drivers/staging/comedi/comedi_buf.c
> @@ -366,42 +366,42 @@ static unsigned int comedi_buf_munge(struct comedi_subdevice *s,
>  				     unsigned int num_bytes)
>  {
>  	struct comedi_async *async = s->async;
> -	unsigned int count = 0;
>  	const unsigned int num_sample_bytes = comedi_bytes_per_sample(s);
> +	unsigned int count = 0;
>  
>  	if (!s->munge || (async->cmd.flags & CMDF_RAWDATA)) {
>  		async->munge_count += num_bytes;
> -		count = num_bytes;
> -	} else {
> -		/* don't munge partial samples */
> -		num_bytes -= num_bytes % num_sample_bytes;
> -		while (count < num_bytes) {
> -			int block_size = num_bytes - count;
> -			unsigned int buf_end;
> +		return num_bytes;
> +	}
>  
> -			buf_end = async->prealloc_bufsz - async->munge_ptr;
> -			if (block_size > buf_end)
> -				block_size = buf_end;
> +	/* don't munge partial samples */
> +	num_bytes -= num_bytes % num_sample_bytes;
> +	while (count < num_bytes) {
> +		int block_size = num_bytes - count;
> +		unsigned int buf_end;
>  
> -			s->munge(s->device, s,
> -				 async->prealloc_buf + async->munge_ptr,
> -				 block_size, async->munge_chan);
> +		buf_end = async->prealloc_bufsz - async->munge_ptr;
> +		if (block_size > buf_end)
> +			block_size = buf_end;
>  
> -			/*
> -			 * ensure data is munged in buffer before the
> -			 * async buffer munge_count is incremented
> -			 */
> -			smp_wmb();
> -
> -			async->munge_chan += block_size / num_sample_bytes;
> -			async->munge_chan %= async->cmd.chanlist_len;
> -			async->munge_count += block_size;
> -			async->munge_ptr += block_size;
> -			async->munge_ptr %= async->prealloc_bufsz;
> -			count += block_size;
> -		}
> -	}
> +		s->munge(s->device, s,
> +			 async->prealloc_buf + async->munge_ptr,
> +			 block_size, async->munge_chan);
>  
> +		/*
> +		 * ensure data is munged in buffer before the
> +		 * async buffer munge_count is incremented
> +		 */
> +		smp_wmb();
> +
> +		async->munge_chan += block_size / num_sample_bytes;
> +		async->munge_chan %= async->cmd.chanlist_len;
> +		async->munge_count += block_size;
> +		async->munge_ptr += block_size;
> +		async->munge_ptr %= async->prealloc_bufsz;
> +		count += block_size;
> +	}
> +	
>  	return count;
>  }
>
diff mbox series

Patch

diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c
index 3ef3ddabf139..05927fb321ba 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -366,42 +366,42 @@  static unsigned int comedi_buf_munge(struct comedi_subdevice *s,
 				     unsigned int num_bytes)
 {
 	struct comedi_async *async = s->async;
-	unsigned int count = 0;
 	const unsigned int num_sample_bytes = comedi_bytes_per_sample(s);
+	unsigned int count = 0;
 
 	if (!s->munge || (async->cmd.flags & CMDF_RAWDATA)) {
 		async->munge_count += num_bytes;
-		count = num_bytes;
-	} else {
-		/* don't munge partial samples */
-		num_bytes -= num_bytes % num_sample_bytes;
-		while (count < num_bytes) {
-			int block_size = num_bytes - count;
-			unsigned int buf_end;
+		return num_bytes;
+	}
 
-			buf_end = async->prealloc_bufsz - async->munge_ptr;
-			if (block_size > buf_end)
-				block_size = buf_end;
+	/* don't munge partial samples */
+	num_bytes -= num_bytes % num_sample_bytes;
+	while (count < num_bytes) {
+		int block_size = num_bytes - count;
+		unsigned int buf_end;
 
-			s->munge(s->device, s,
-				 async->prealloc_buf + async->munge_ptr,
-				 block_size, async->munge_chan);
+		buf_end = async->prealloc_bufsz - async->munge_ptr;
+		if (block_size > buf_end)
+			block_size = buf_end;
 
-			/*
-			 * ensure data is munged in buffer before the
-			 * async buffer munge_count is incremented
-			 */
-			smp_wmb();
-
-			async->munge_chan += block_size / num_sample_bytes;
-			async->munge_chan %= async->cmd.chanlist_len;
-			async->munge_count += block_size;
-			async->munge_ptr += block_size;
-			async->munge_ptr %= async->prealloc_bufsz;
-			count += block_size;
-		}
-	}
+		s->munge(s->device, s,
+			 async->prealloc_buf + async->munge_ptr,
+			 block_size, async->munge_chan);
 
+		/*
+		 * ensure data is munged in buffer before the
+		 * async buffer munge_count is incremented
+		 */
+		smp_wmb();
+
+		async->munge_chan += block_size / num_sample_bytes;
+		async->munge_chan %= async->cmd.chanlist_len;
+		async->munge_count += block_size;
+		async->munge_ptr += block_size;
+		async->munge_ptr %= async->prealloc_bufsz;
+		count += block_size;
+	}
+	
 	return count;
 }