Message ID | 20210820165927.4524-3-mihail.chindris@analog.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | iio: Add output buffer support and DAC example | expand |
Hi Mihail, I love your patch! Perhaps something to improve: [auto build test WARNING on 94a853eca720ac9e385e59f27e859b4a01123f58] url: https://github.com/0day-ci/linux/commits/Mihail-Chindris/iio-Add-output-buffer-support-and-DAC-example/20210821-010349 base: 94a853eca720ac9e385e59f27e859b4a01123f58 config: mips-randconfig-s031-20210821 (attached as .config) compiler: mipsel-linux-gcc (GCC) 11.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # apt-get install sparse # sparse version: v0.6.3-348-gf0e6938b-dirty # https://github.com/0day-ci/linux/commit/4ad051f1e5a488f51842037c42fa17b5a1ce1d38 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Mihail-Chindris/iio-Add-output-buffer-support-and-DAC-example/20210821-010349 git checkout 4ad051f1e5a488f51842037c42fa17b5a1ce1d38 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=mips SHELL=/bin/bash drivers/iio/buffer/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> sparse warnings: (new ones prefixed by >>) command-line: note: in included file: builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_ACQUIRE redefined builtin:0:0: sparse: this was the original definition builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_SEQ_CST redefined builtin:0:0: sparse: this was the original definition builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_ACQ_REL redefined builtin:0:0: sparse: this was the original definition builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_RELEASE redefined builtin:0:0: sparse: this was the original definition >> drivers/iio/buffer/kfifo_buf.c:165:9: sparse: sparse: cast to restricted __poll_t vim +165 drivers/iio/buffer/kfifo_buf.c 152 153 static int iio_kfifo_remove_from(struct iio_buffer *r, void *data) 154 { 155 int ret; 156 struct iio_kfifo *kf = iio_to_kfifo(r); 157 158 if (kfifo_size(&kf->kf) < 1) 159 return -EBUSY; 160 161 ret = kfifo_out(&kf->kf, data, 1); 162 if (ret != 1) 163 return -EBUSY; 164 > 165 wake_up_interruptible_poll(&r->pollq, POLLOUT | POLLWRNORM); 166 167 return 0; 168 } 169 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
On Fri, 2021-08-20 at 16:59 +0000, Mihail Chindris wrote: > From: Lars-Peter Clausen <lars@metafoo.de> > > Add output buffer support to the kfifo buffer implementation. > > The implementation is straight forward and mostly just wraps the > kfifo > API to provide the required operations. > > Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> > Signed-off-by: Mihail Chindris <mihail.chindris@analog.com> > --- > drivers/iio/buffer/kfifo_buf.c | 50 > ++++++++++++++++++++++++++++++++++ > 1 file changed, 50 insertions(+) > > diff --git a/drivers/iio/buffer/kfifo_buf.c > b/drivers/iio/buffer/kfifo_buf.c > index 516eb3465de1..7368db2d5c32 100644 > --- a/drivers/iio/buffer/kfifo_buf.c > +++ b/drivers/iio/buffer/kfifo_buf.c > @@ -138,10 +138,60 @@ static void iio_kfifo_buffer_release(struct > iio_buffer *buffer) > kfree(kf); > } > > +static size_t iio_kfifo_buf_space_available(struct iio_buffer *r) > +{ > + struct iio_kfifo *kf = iio_to_kfifo(r); > + size_t avail; > + > + mutex_lock(&kf->user_lock); > + avail = kfifo_avail(&kf->kf); > + mutex_unlock(&kf->user_lock); > + > + return avail; > +} > + > +static int iio_kfifo_remove_from(struct iio_buffer *r, void *data) > +{ > + int ret; > + struct iio_kfifo *kf = iio_to_kfifo(r); > + > + if (kfifo_size(&kf->kf) < 1) > + return -EBUSY; > + > + ret = kfifo_out(&kf->kf, data, 1); > + if (ret != 1) > + return -EBUSY; > + > + wake_up_interruptible_poll(&r->pollq, POLLOUT | POLLWRNORM); > + > + return 0; > +} > + > +static int iio_kfifo_write(struct iio_buffer *r, size_t n, > + const char __user *buf) > +{ nit: I would align this with the open parenthesis... - Nuno Sá
diff --git a/drivers/iio/buffer/kfifo_buf.c b/drivers/iio/buffer/kfifo_buf.c index 516eb3465de1..7368db2d5c32 100644 --- a/drivers/iio/buffer/kfifo_buf.c +++ b/drivers/iio/buffer/kfifo_buf.c @@ -138,10 +138,60 @@ static void iio_kfifo_buffer_release(struct iio_buffer *buffer) kfree(kf); } +static size_t iio_kfifo_buf_space_available(struct iio_buffer *r) +{ + struct iio_kfifo *kf = iio_to_kfifo(r); + size_t avail; + + mutex_lock(&kf->user_lock); + avail = kfifo_avail(&kf->kf); + mutex_unlock(&kf->user_lock); + + return avail; +} + +static int iio_kfifo_remove_from(struct iio_buffer *r, void *data) +{ + int ret; + struct iio_kfifo *kf = iio_to_kfifo(r); + + if (kfifo_size(&kf->kf) < 1) + return -EBUSY; + + ret = kfifo_out(&kf->kf, data, 1); + if (ret != 1) + return -EBUSY; + + wake_up_interruptible_poll(&r->pollq, POLLOUT | POLLWRNORM); + + return 0; +} + +static int iio_kfifo_write(struct iio_buffer *r, size_t n, + const char __user *buf) +{ + struct iio_kfifo *kf = iio_to_kfifo(r); + int ret, copied; + + mutex_lock(&kf->user_lock); + if (!kfifo_initialized(&kf->kf) || n < kfifo_esize(&kf->kf)) + ret = -EINVAL; + else + ret = kfifo_from_user(&kf->kf, buf, n, &copied); + mutex_unlock(&kf->user_lock); + if (ret) + return ret; + + return copied; +} + static const struct iio_buffer_access_funcs kfifo_access_funcs = { .store_to = &iio_store_to_kfifo, .read = &iio_read_kfifo, .data_available = iio_kfifo_buf_data_available, + .remove_from = &iio_kfifo_remove_from, + .write = &iio_kfifo_write, + .space_available = &iio_kfifo_buf_space_available, .request_update = &iio_request_update_kfifo, .set_bytes_per_datum = &iio_set_bytes_per_datum_kfifo, .set_length = &iio_set_length_kfifo,