On Sat, 2018-02-24 at 12:18 +0000, Jonathan Cameron wrote: > On Fri, 16 Feb 2018 14:09:15 +0200 > Alexandru Ardelean <alexandru.ardelean@xxxxxxxxxx> wrote: > > > This is a small cleanup of the driver's init code. > > It does not fix anything. > > > > The `devm_iio_kfifo_allocate()` function is used instead of > > `iio_kfifo_allocate()`. This removes the need for explicit deallocation of > > the driver's iio_buffer, which will now be handled via > > `iio_device_unregister()`. > > > > The `setup_ops` assignment has been moved into the `ad5933_probe()` call, > > since it's a one-liner. > > > > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@xxxxxxxxxx> > > --- > > > > Note: this change is based on top of `fixes-togreg-post-rc1` branch which > > contains commit (7d2b8e6aaf9: staging: iio: ad5933: switch buffer mode to > > software) > > It will take a few weeks for that to get to my togreg branch so please > do remind me if it has and I seem to have forgotten this! > > Jonathan I'm a bit new to how things progress in the iio subtree. [Curious] Is there a recommended branch that is regularly updated with accepted patches ? Or which branches do I need to rebase when submitting other patches ? Reason is: to rebase other patches once a patch after has been accepted. That's also for cases when submitting patches like this one [small updates/cleanups]. Rebasing often, would allow for patches [like this] to be sent a bit more frequently. I'm assuming that the current way-of-doing-things is geared to organizing patches to be sent to Greg. I'm not asking for such a branch to be created [or anything]. Just want to get a feel for how things work, so that I can adapt how I organize myself [with submission of patches]. Alex > > > > > drivers/staging/iio/impedance-analyzer/ad5933.c | 35 +++++++------------------ > > 1 file changed, 10 insertions(+), 25 deletions(-) > > > > diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c > > index 3bcf49466361..1cab67b3a81e 100644 > > --- a/drivers/staging/iio/impedance-analyzer/ad5933.c > > +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c > > @@ -635,22 +635,6 @@ static const struct iio_buffer_setup_ops ad5933_ring_setup_ops = { > > .postdisable = ad5933_ring_postdisable, > > }; > > > > -static int ad5933_register_ring_funcs_and_init(struct iio_dev *indio_dev) > > -{ > > - struct iio_buffer *buffer; > > - > > - buffer = iio_kfifo_allocate(); > > - if (!buffer) > > - return -ENOMEM; > > - > > - iio_device_attach_buffer(indio_dev, buffer); > > - > > - /* Ring buffer functions - here trigger setup related */ > > - indio_dev->setup_ops = &ad5933_ring_setup_ops; > > - > > - return 0; > > -} > > - > > static void ad5933_work(struct work_struct *work) > > { > > struct ad5933_state *st = container_of(work, > > @@ -714,12 +698,19 @@ static int ad5933_probe(struct i2c_client *client, > > int ret, voltage_uv = 0; > > struct ad5933_platform_data *pdata = dev_get_platdata(&client->dev); > > struct ad5933_state *st; > > + struct iio_buffer *buffer; > > struct iio_dev *indio_dev; > > > > indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st)); > > if (!indio_dev) > > return -ENOMEM; > > > > + buffer = devm_iio_kfifo_allocate(&client->dev); > > + if (!buffer) > > + return -ENOMEM; > > + > > + iio_device_attach_buffer(indio_dev, buffer); > > + > > st = iio_priv(indio_dev); > > i2c_set_clientdata(client, indio_dev); > > st->client = client; > > @@ -763,23 +754,18 @@ static int ad5933_probe(struct i2c_client *client, > > indio_dev->modes = (INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE); > > indio_dev->channels = ad5933_channels; > > indio_dev->num_channels = ARRAY_SIZE(ad5933_channels); > > - > > - ret = ad5933_register_ring_funcs_and_init(indio_dev); > > - if (ret) > > - goto error_disable_reg; > > + indio_dev->setup_ops = &ad5933_ring_setup_ops; > > > > ret = ad5933_setup(st); > > if (ret) > > - goto error_unreg_ring; > > + goto error_disable_reg; > > > > ret = iio_device_register(indio_dev); > > if (ret) > > - goto error_unreg_ring; > > + goto error_disable_reg; > > > > return 0; > > > > -error_unreg_ring: > > - iio_kfifo_free(indio_dev->buffer); > > error_disable_reg: > > regulator_disable(st->reg); > > > > @@ -792,7 +778,6 @@ static int ad5933_remove(struct i2c_client *client) > > struct ad5933_state *st = iio_priv(indio_dev); > > > > iio_device_unregister(indio_dev); > > - iio_kfifo_free(indio_dev->buffer); > > regulator_disable(st->reg); > > > > return 0; > > ��.n��������+%������w��{.n�����{��(��)��jg��������ݢj����G�������j:+v���w�m������w�������h�����٥