diff mbox

staging: iio: ad5933: merge ring init function into probe function

Message ID 20180216120915.19277-1-alexandru.ardelean@analog.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alexandru Ardelean Feb. 16, 2018, 12:09 p.m. UTC
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@analog.com>
---

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)

 drivers/staging/iio/impedance-analyzer/ad5933.c | 35 +++++++------------------
 1 file changed, 10 insertions(+), 25 deletions(-)

Comments

Jonathan Cameron Feb. 24, 2018, 12:18 p.m. UTC | #1
On Fri, 16 Feb 2018 14:09:15 +0200
Alexandru Ardelean <alexandru.ardelean@analog.com> 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@analog.com>
> ---
> 
> 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

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

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexandru Ardelean Feb. 26, 2018, 7:44 a.m. UTC | #2
T24gU2F0LCAyMDE4LTAyLTI0IGF0IDEyOjE4ICswMDAwLCBKb25hdGhhbiBDYW1lcm9uIHdyb3Rl
Og0KPiBPbiBGcmksIDE2IEZlYiAyMDE4IDE0OjA5OjE1ICswMjAwDQo+IEFsZXhhbmRydSBBcmRl
bGVhbiA8YWxleGFuZHJ1LmFyZGVsZWFuQGFuYWxvZy5jb20+IHdyb3RlOg0KPiANCj4gPiBUaGlz
IGlzIGEgc21hbGwgY2xlYW51cCBvZiB0aGUgZHJpdmVyJ3MgaW5pdCBjb2RlLg0KPiA+IEl0IGRv
ZXMgbm90IGZpeCBhbnl0aGluZy4NCj4gPiANCj4gPiBUaGUgYGRldm1faWlvX2tmaWZvX2FsbG9j
YXRlKClgIGZ1bmN0aW9uIGlzIHVzZWQgaW5zdGVhZCBvZg0KPiA+IGBpaW9fa2ZpZm9fYWxsb2Nh
dGUoKWAuICBUaGlzIHJlbW92ZXMgdGhlIG5lZWQgZm9yIGV4cGxpY2l0IGRlYWxsb2NhdGlvbiBv
Zg0KPiA+IHRoZSBkcml2ZXIncyBpaW9fYnVmZmVyLCB3aGljaCB3aWxsIG5vdyBiZSBoYW5kbGVk
IHZpYQ0KPiA+IGB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AtZXJyb3JfdW5yZWdfcmluZzoNCj4gPiAtCWlpb19rZmlmb19mcmVlKGluZGlvX2Rl
di0+YnVmZmVyKTsNCj4gPiAgZXJyb3JfZGlzYWJsZV9yZWc6DQo+ID4gIAlyZWd1bGF0b3JfZGlz
YWJsZShzdC0+cmVnKTsNCj4gPiAgDQo+ID4gQEAgLTc5Miw3ICs3NzgsNiBAQCBzdGF0aWMgaW50
IGFkNTkzM19yZW1vdmUoc3RydWN0IGkyY19jbGllbnQgKmNsaWVudCkNCj4gPiAgCXN0cnVjdCBh
ZDU5MzNfc3RhdGUgKnN0ID0gaWlvX3ByaXYoaW5kaW9fZGV2KTsNCj4gPiAgDQo+ID4gIAlpaW9f
ZGV2aWNlX3VucmVnaXN0ZXIoaW5kaW9fZGV2KTsNCj4gPiAtCWlpb19rZmlmb19mcmVlKGluZGlv
X2Rldi0+YnVmZmVyKTsNCj4gPiAgCXJlZ3VsYXRvcl9kaXNhYmxlKHN0LT5yZWcpOw0KPiA+ICAN
Cj4gPiAgCXJldHVybiAwOw0KPiANCj4g
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Daniel Baluta Feb. 26, 2018, 10:47 a.m. UTC | #3
On Mon, Feb 26, 2018 at 9:44 AM, Ardelean, Alexandru
<alexandru.Ardelean@analog.com> wrote:
> 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@analog.com> 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@analog.com>
>> > ---
>> >
>> > 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 ?


Salut Alexandru,

You can use the togreg branch of iio tree.

thanks,
Daniel.
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jonathan Cameron March 3, 2018, 3 p.m. UTC | #4
On Mon, 26 Feb 2018 12:47:28 +0200
Daniel Baluta <daniel.baluta@gmail.com> wrote:

> On Mon, Feb 26, 2018 at 9:44 AM, Ardelean, Alexandru
> <alexandru.Ardelean@analog.com> wrote:
> > 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@analog.com> 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@analog.com>
> >> > ---
> >> >
> >> > 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 ?  
> 
> 
> Salut Alexandru,
> 
> You can use the togreg branch of iio tree.
That tends to only get updated fairly infrequently except when I'm doing
a pull request but that is 'in theory' the right branch to use.

In practice, the only reason I'd change things in the testing branch
is a build failure or a comment from someone suggesting a reason to pull
a patch.  Mind you I've been pretty bad at remembering to push that out
as well recently :(  I only find out when I realise I didn't get a build
report from 0-day when I get to work on Monday.

Jonathan

> 
> thanks,
> Daniel.

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexandru Ardelean March 5, 2018, 7:24 a.m. UTC | #5
On Sat, 2018-03-03 at 15:00 +0000, Jonathan Cameron wrote:
> On Mon, 26 Feb 2018 12:47:28 +0200

> Daniel Baluta <daniel.baluta@gmail.com> wrote:

> 

> > On Mon, Feb 26, 2018 at 9:44 AM, Ardelean, Alexandru

> > <alexandru.Ardelean@analog.com> wrote:

> > > 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@analog.com> 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@analog.com>

> > > > > ---

> > > > > 

> > > > > 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 ?  

> > 

> > 

> > Salut Alexandru,

> > 

> > You can use the togreg branch of iio tree.

> 

> That tends to only get updated fairly infrequently except when I'm doing

> a pull request but that is 'in theory' the right branch to use.

> 

> In practice, the only reason I'd change things in the testing branch

> is a build failure or a comment from someone suggesting a reason to pull

> a patch.  Mind you I've been pretty bad at remembering to push that out

> as well recently :(  I only find out when I realise I didn't get a build

> report from 0-day when I get to work on Monday.

> 


I don't know about you guys, but I've always been terrible at following email
threads after they go above a certain count.
Which is why I am appreciative when using web-tools like Github, Gitlab, etc and
using email mostly as a notification method.

I admit there's usually some concern/resistance to considering these tools.

[I usually refer to OpenWrt for a lot of examples, since I follow the project].
Currently, OpenWrt has 2 ways of accepting patches: 1 via Github, 1 via email +
patchwork.
The Github repo is just a mirror of the official repo.
[AFAIK] Patches get applied to the official repo and then mirrored on Github.

Alex

> Jonathan

> 

> > 

> > thanks,

> > Daniel.

> 

>
Alexandru Ardelean March 13, 2018, 9:01 a.m. UTC | #6
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@analog.com> 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@analog.com>

> > ---

> > 

> > 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!

> 


Was this supposed to go into one of the recent pull requests ?
Or is this for a later pull ?

Alex

> Jonathan

> 

> > 

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

> 

>
diff mbox

Patch

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;