On Wed, 24 Mar 2021 13:20:50 +0100 Swen Kalski <kalski.swen@xxxxxxxxx> 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; > } >