public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@jic23.retrosnub.co.uk>
To: Swen Kalski <kalski.swen@gmail.com>
Cc: linux-iio@vger.kernel.org, gregkh@linuxfoundation.org
Subject: Re: [PATCH] Add early return to Method because the else can be ignored.
Date: Fri, 26 Mar 2021 11:31:25 +0000	[thread overview]
Message-ID: <20210326113125.4b3e68ed@jic23-huawei> (raw)
In-Reply-To: <20210324122050.GA28987@kernel-dev>

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;
>  }
>  


      parent reply	other threads:[~2021-03-26 11:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24 12:20 [PATCH] Add early return to Method because the else can be ignored Swen Kalski
2021-03-24 12:32 ` Greg KH
2021-03-26 11:31 ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210326113125.4b3e68ed@jic23-huawei \
    --to=jic23@jic23.retrosnub.co.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=kalski.swen@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox