All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: sgtl5000: Use devm_ functions
@ 2014-07-06  7:08 Himangi Saraogi
  2014-07-07 14:48 ` Mark Brown
  0 siblings, 1 reply; 15+ messages in thread
From: Himangi Saraogi @ 2014-07-06  7:08 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-kernel
  Cc: julia.lawall

This patch introduces the use of managed interfaces like devm_kzalloc,
devm_kstrdup and devm_regulator_register and does avay with the calls to
the functions to free the allocated memory in ldo_regulator_register and
ldo_regulator_remove. The ldo_regulator_remove function is completely
removed as it is no longer required. ldo_regulator_register is called
from a probe function and on failure its value is returned as the
result.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
---
To send to: Liam Girdwood <lgirdwood@gmail.com>,Mark Brown <broonie@kernel.org>,Jaroslav Kysela <perex@perex.cz>,Takashi Iwai <tiwai@suse.de>,alsa-devel@alsa-project.org,linux-kernel@vger.kernel.org
 sound/soc/codecs/sgtl5000.c | 46 +++++++--------------------------------------
 1 file changed, 7 insertions(+), 39 deletions(-)

diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index 249fadb..0efd6d6 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -841,14 +841,15 @@ static int ldo_regulator_register(struct snd_soc_codec *codec,
 	struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
 	struct regulator_config config = { };
 
-	ldo = kzalloc(sizeof(struct ldo_regulator), GFP_KERNEL);
+	ldo = devm_kzalloc(codec->dev, sizeof(struct ldo_regulator),
+			   GFP_KERNEL);
 
 	if (!ldo)
 		return -ENOMEM;
 
-	ldo->desc.name = kstrdup(dev_name(codec->dev), GFP_KERNEL);
+	ldo->desc.name = devm_kstrdup(codec->dev, dev_name(codec->dev),
+				      GFP_KERNEL);
 	if (!ldo->desc.name) {
-		kfree(ldo);
 		dev_err(codec->dev, "failed to allocate decs name memory\n");
 		return -ENOMEM;
 	}
@@ -865,35 +866,17 @@ static int ldo_regulator_register(struct snd_soc_codec *codec,
 	config.driver_data = ldo;
 	config.init_data = init_data;
 
-	ldo->dev = regulator_register(&ldo->desc, &config);
+	ldo->dev = devm_regulator_register(codec->dev, &ldo->desc, &config);
 	if (IS_ERR(ldo->dev)) {
 		int ret = PTR_ERR(ldo->dev);
 
 		dev_err(codec->dev, "failed to register regulator\n");
-		kfree(ldo->desc.name);
-		kfree(ldo);
-
 		return ret;
 	}
 	sgtl5000->ldo = ldo;
 
 	return 0;
 }
-
-static int ldo_regulator_remove(struct snd_soc_codec *codec)
-{
-	struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
-	struct ldo_regulator *ldo = sgtl5000->ldo;
-
-	if (!ldo)
-		return 0;
-
-	regulator_unregister(ldo->dev);
-	kfree(ldo->desc.name);
-	kfree(ldo);
-
-	return 0;
-}
 #else
 static int ldo_regulator_register(struct snd_soc_codec *codec,
 				struct regulator_init_data *init_data,
@@ -902,11 +885,6 @@ static int ldo_regulator_register(struct snd_soc_codec *codec,
 	dev_err(codec->dev, "this setup needs regulator support in the kernel\n");
 	return -EINVAL;
 }
-
-static int ldo_regulator_remove(struct snd_soc_codec *codec)
-{
-	return 0;
-}
 #endif
 
 /*
@@ -1278,23 +1256,17 @@ static int sgtl5000_enable_regulators(struct snd_soc_codec *codec)
 	ret = devm_regulator_bulk_get(codec->dev, ARRAY_SIZE(sgtl5000->supplies),
 				 sgtl5000->supplies);
 	if (ret)
-		goto err_ldo_remove;
+		return ret;
 
 	ret = regulator_bulk_enable(ARRAY_SIZE(sgtl5000->supplies),
 					sgtl5000->supplies);
 	if (ret)
-		goto err_ldo_remove;
+		return ret;
 
 	/* wait for all power rails bring up */
 	udelay(10);
 
 	return 0;
-
-err_ldo_remove:
-	if (!external_vddd)
-		ldo_regulator_remove(codec);
-	return ret;
-
 }
 
 static int sgtl5000_probe(struct snd_soc_codec *codec)
@@ -1359,8 +1331,6 @@ static int sgtl5000_probe(struct snd_soc_codec *codec)
 err:
 	regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies),
 						sgtl5000->supplies);
-	ldo_regulator_remove(codec);
-
 	return ret;
 }
 
@@ -1372,8 +1342,6 @@ static int sgtl5000_remove(struct snd_soc_codec *codec)
 
 	regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies),
 						sgtl5000->supplies);
-	ldo_regulator_remove(codec);
-
 	return 0;
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] ASoC: sgtl5000: Use devm_ functions
  2014-07-06  7:08 [PATCH] ASoC: sgtl5000: Use devm_ functions Himangi Saraogi
@ 2014-07-07 14:48 ` Mark Brown
  2014-07-07 14:58   ` Julia Lawall
  0 siblings, 1 reply; 15+ messages in thread
From: Mark Brown @ 2014-07-07 14:48 UTC (permalink / raw)
  To: Himangi Saraogi
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, alsa-devel,
	linux-kernel, julia.lawall

[-- Attachment #1: Type: text/plain, Size: 922 bytes --]

On Sun, Jul 06, 2014 at 12:38:00PM +0530, Himangi Saraogi wrote:

> diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
> index 249fadb..0efd6d6 100644
> --- a/sound/soc/codecs/sgtl5000.c
> +++ b/sound/soc/codecs/sgtl5000.c
> @@ -841,14 +841,15 @@ static int ldo_regulator_register(struct snd_soc_codec *codec,
>  	struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
>  	struct regulator_config config = { };
>  
> -	ldo = kzalloc(sizeof(struct ldo_regulator), GFP_KERNEL);
> +	ldo = devm_kzalloc(codec->dev, sizeof(struct ldo_regulator),
> +			   GFP_KERNEL);

You're using the managed functions within the ASoC level probe functions
which doesn't work - devm_ is only usable as part of the driver model
binding and unbinding.  All this resource allocation needs to be moved
into the device level probe (which is a better thing anyway) before it
is converted to devm.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] ASoC: sgtl5000: Use devm_ functions
  2014-07-07 14:48 ` Mark Brown
@ 2014-07-07 14:58   ` Julia Lawall
  2014-07-07 15:20       ` Fabio Estevam
  0 siblings, 1 reply; 15+ messages in thread
From: Julia Lawall @ 2014-07-07 14:58 UTC (permalink / raw)
  To: Mark Brown
  Cc: Himangi Saraogi, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-kernel, julia.lawall



On Mon, 7 Jul 2014, Mark Brown wrote:

> On Sun, Jul 06, 2014 at 12:38:00PM +0530, Himangi Saraogi wrote:
>
> > diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
> > index 249fadb..0efd6d6 100644
> > --- a/sound/soc/codecs/sgtl5000.c
> > +++ b/sound/soc/codecs/sgtl5000.c
> > @@ -841,14 +841,15 @@ static int ldo_regulator_register(struct snd_soc_codec *codec,
> >  	struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
> >  	struct regulator_config config = { };
> >
> > -	ldo = kzalloc(sizeof(struct ldo_regulator), GFP_KERNEL);
> > +	ldo = devm_kzalloc(codec->dev, sizeof(struct ldo_regulator),
> > +			   GFP_KERNEL);
>
> You're using the managed functions within the ASoC level probe functions
> which doesn't work - devm_ is only usable as part of the driver model
> binding and unbinding.  All this resource allocation needs to be moved
> into the device level probe (which is a better thing anyway) before it
> is converted to devm.

Nevertheless, there is already a call to devm_regulator_bulk_get in
sgtl5000_enable_regulators which calls sgtl5000_replace_vddd_with_ldo
which calls ldo_regulator_register.  That call was introduced by

commit 63e54cd9caa3ce03635810608519e2b37d8bc706
Author: Fabio Estevam <fabio.estevam@freescale.com>
Date:   Thu Apr 24 14:13:08 2014 -0300

It seems that that patch should be reverted?

julia

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: sgtl5000: Use devm_ functions
  2014-07-07 14:58   ` Julia Lawall
@ 2014-07-07 15:20       ` Fabio Estevam
  0 siblings, 0 replies; 15+ messages in thread
From: Fabio Estevam @ 2014-07-07 15:20 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Mark Brown, alsa-devel, Takashi Iwai, linux-kernel,
	Liam Girdwood, Himangi Saraogi

On Mon, Jul 7, 2014 at 11:58 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:

> Nevertheless, there is already a call to devm_regulator_bulk_get in
> sgtl5000_enable_regulators which calls sgtl5000_replace_vddd_with_ldo
> which calls ldo_regulator_register.  That call was introduced by
>
> commit 63e54cd9caa3ce03635810608519e2b37d8bc706
> Author: Fabio Estevam <fabio.estevam@freescale.com>
> Date:   Thu Apr 24 14:13:08 2014 -0300
>
> It seems that that patch should be reverted?

I think so. Russell also reported a kernel oops when unbinding this
module, so I will prepare a patch reverting it.

Thanks

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] ASoC: sgtl5000: Use devm_ functions
@ 2014-07-07 15:20       ` Fabio Estevam
  0 siblings, 0 replies; 15+ messages in thread
From: Fabio Estevam @ 2014-07-07 15:20 UTC (permalink / raw)
  To: Julia Lawall
  Cc: alsa-devel, Takashi Iwai, linux-kernel, Liam Girdwood,
	Mark Brown, Himangi Saraogi

On Mon, Jul 7, 2014 at 11:58 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:

> Nevertheless, there is already a call to devm_regulator_bulk_get in
> sgtl5000_enable_regulators which calls sgtl5000_replace_vddd_with_ldo
> which calls ldo_regulator_register.  That call was introduced by
>
> commit 63e54cd9caa3ce03635810608519e2b37d8bc706
> Author: Fabio Estevam <fabio.estevam@freescale.com>
> Date:   Thu Apr 24 14:13:08 2014 -0300
>
> It seems that that patch should be reverted?

I think so. Russell also reported a kernel oops when unbinding this
module, so I will prepare a patch reverting it.

Thanks

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: sgtl5000: Use devm_ functions
  2014-07-07 15:20       ` Fabio Estevam
  (?)
@ 2014-07-07 15:23       ` Julia Lawall
  2014-07-07 15:34           ` Lars-Peter Clausen
  2014-07-08  8:02           ` Mark Brown
  -1 siblings, 2 replies; 15+ messages in thread
From: Julia Lawall @ 2014-07-07 15:23 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Julia Lawall, Mark Brown, alsa-devel, Takashi Iwai, linux-kernel,
	Liam Girdwood, Himangi Saraogi



On Mon, 7 Jul 2014, Fabio Estevam wrote:

> On Mon, Jul 7, 2014 at 11:58 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
> > Nevertheless, there is already a call to devm_regulator_bulk_get in
> > sgtl5000_enable_regulators which calls sgtl5000_replace_vddd_with_ldo
> > which calls ldo_regulator_register.  That call was introduced by
> >
> > commit 63e54cd9caa3ce03635810608519e2b37d8bc706
> > Author: Fabio Estevam <fabio.estevam@freescale.com>
> > Date:   Thu Apr 24 14:13:08 2014 -0300
> >
> > It seems that that patch should be reverted?
>
> I think so. Russell also reported a kernel oops when unbinding this
> module, so I will prepare a patch reverting it.

There is documentation about what kinds of devm functions exist, but it is
too bad that there is no documentation about where they can be used.
Often there are several levels of function pointers involved, so it can be
hard to figure out whether they can be used just by looking at the code.
I have only taken the strategy of using them in kinds of functions where
someone else has alreadyy figured out that they can be used.

julia

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: sgtl5000: Use devm_ functions
  2014-07-07 15:23       ` [alsa-devel] " Julia Lawall
@ 2014-07-07 15:34           ` Lars-Peter Clausen
  2014-07-08  8:02           ` Mark Brown
  1 sibling, 0 replies; 15+ messages in thread
From: Lars-Peter Clausen @ 2014-07-07 15:34 UTC (permalink / raw)
  To: Julia Lawall, Fabio Estevam
  Cc: alsa-devel, Takashi Iwai, linux-kernel, Liam Girdwood,
	Mark Brown, Himangi Saraogi

On 07/07/2014 05:23 PM, Julia Lawall wrote:
>
>
> On Mon, 7 Jul 2014, Fabio Estevam wrote:
>
>> On Mon, Jul 7, 2014 at 11:58 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>>
>>> Nevertheless, there is already a call to devm_regulator_bulk_get in
>>> sgtl5000_enable_regulators which calls sgtl5000_replace_vddd_with_ldo
>>> which calls ldo_regulator_register.  That call was introduced by
>>>
>>> commit 63e54cd9caa3ce03635810608519e2b37d8bc706
>>> Author: Fabio Estevam <fabio.estevam@freescale.com>
>>> Date:   Thu Apr 24 14:13:08 2014 -0300
>>>
>>> It seems that that patch should be reverted?
>>
>> I think so. Russell also reported a kernel oops when unbinding this
>> module, so I will prepare a patch reverting it.
>
> There is documentation about what kinds of devm functions exist, but it is
> too bad that there is no documentation about where they can be used.
> Often there are several levels of function pointers involved, so it can be
> hard to figure out whether they can be used just by looking at the code.
> I have only taken the strategy of using them in kinds of functions where
> someone else has alreadyy figured out that they can be used.

Yes, it is probably a bit underdocumented. The rule of thumb is don't use it 
anywhere else except for device probe callbacks (and functions that are only 
called from a device probe function) and only for the device that is being 
probed. There are probably a couple of instances in the kernel where the 
manged resource allocators are used in places where they shouldn't be used.

- Lars


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] ASoC: sgtl5000: Use devm_ functions
@ 2014-07-07 15:34           ` Lars-Peter Clausen
  0 siblings, 0 replies; 15+ messages in thread
From: Lars-Peter Clausen @ 2014-07-07 15:34 UTC (permalink / raw)
  To: Julia Lawall, Fabio Estevam
  Cc: alsa-devel, Takashi Iwai, linux-kernel, Liam Girdwood,
	Mark Brown, Himangi Saraogi

On 07/07/2014 05:23 PM, Julia Lawall wrote:
>
>
> On Mon, 7 Jul 2014, Fabio Estevam wrote:
>
>> On Mon, Jul 7, 2014 at 11:58 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>>
>>> Nevertheless, there is already a call to devm_regulator_bulk_get in
>>> sgtl5000_enable_regulators which calls sgtl5000_replace_vddd_with_ldo
>>> which calls ldo_regulator_register.  That call was introduced by
>>>
>>> commit 63e54cd9caa3ce03635810608519e2b37d8bc706
>>> Author: Fabio Estevam <fabio.estevam@freescale.com>
>>> Date:   Thu Apr 24 14:13:08 2014 -0300
>>>
>>> It seems that that patch should be reverted?
>>
>> I think so. Russell also reported a kernel oops when unbinding this
>> module, so I will prepare a patch reverting it.
>
> There is documentation about what kinds of devm functions exist, but it is
> too bad that there is no documentation about where they can be used.
> Often there are several levels of function pointers involved, so it can be
> hard to figure out whether they can be used just by looking at the code.
> I have only taken the strategy of using them in kinds of functions where
> someone else has alreadyy figured out that they can be used.

Yes, it is probably a bit underdocumented. The rule of thumb is don't use it 
anywhere else except for device probe callbacks (and functions that are only 
called from a device probe function) and only for the device that is being 
probed. There are probably a couple of instances in the kernel where the 
manged resource allocators are used in places where they shouldn't be used.

- Lars

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: sgtl5000: Use devm_ functions
  2014-07-07 15:23       ` [alsa-devel] " Julia Lawall
@ 2014-07-08  8:02           ` Mark Brown
  2014-07-08  8:02           ` Mark Brown
  1 sibling, 0 replies; 15+ messages in thread
From: Mark Brown @ 2014-07-08  8:02 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Fabio Estevam, alsa-devel, Takashi Iwai, linux-kernel,
	Liam Girdwood, Himangi Saraogi

[-- Attachment #1: Type: text/plain, Size: 826 bytes --]

On Mon, Jul 07, 2014 at 05:23:39PM +0200, Julia Lawall wrote:

> There is documentation about what kinds of devm functions exist, but it is
> too bad that there is no documentation about where they can be used.
> Often there are several levels of function pointers involved, so it can be
> hard to figure out whether they can be used just by looking at the code.
> I have only taken the strategy of using them in kinds of functions where
> someone else has alreadyy figured out that they can be used.

It should be fairly clear given what they do I'd have thought - the
devm_ functions tie the deallocation of a resource to the unbinding of
a driver from a device so they can only be used to replace things that
get cleaned up in a device model unbind path.  There's not usually a
great deal of indirection going on in those.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] ASoC: sgtl5000: Use devm_ functions
@ 2014-07-08  8:02           ` Mark Brown
  0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2014-07-08  8:02 UTC (permalink / raw)
  To: Julia Lawall
  Cc: alsa-devel, Takashi Iwai, linux-kernel, Liam Girdwood,
	Himangi Saraogi, Fabio Estevam


[-- Attachment #1.1: Type: text/plain, Size: 826 bytes --]

On Mon, Jul 07, 2014 at 05:23:39PM +0200, Julia Lawall wrote:

> There is documentation about what kinds of devm functions exist, but it is
> too bad that there is no documentation about where they can be used.
> Often there are several levels of function pointers involved, so it can be
> hard to figure out whether they can be used just by looking at the code.
> I have only taken the strategy of using them in kinds of functions where
> someone else has alreadyy figured out that they can be used.

It should be fairly clear given what they do I'd have thought - the
devm_ functions tie the deallocation of a resource to the unbinding of
a driver from a device so they can only be used to replace things that
get cleaned up in a device model unbind path.  There's not usually a
great deal of indirection going on in those.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: sgtl5000: Use devm_ functions
  2014-07-08  8:02           ` Mark Brown
  (?)
@ 2014-07-08  8:15           ` Julia Lawall
  2014-07-08 14:52             ` Mark Brown
  -1 siblings, 1 reply; 15+ messages in thread
From: Julia Lawall @ 2014-07-08  8:15 UTC (permalink / raw)
  To: Mark Brown
  Cc: Julia Lawall, Fabio Estevam, alsa-devel, Takashi Iwai,
	linux-kernel, Liam Girdwood, Himangi Saraogi



On Tue, 8 Jul 2014, Mark Brown wrote:

> On Mon, Jul 07, 2014 at 05:23:39PM +0200, Julia Lawall wrote:
>
> > There is documentation about what kinds of devm functions exist, but it is
> > too bad that there is no documentation about where they can be used.
> > Often there are several levels of function pointers involved, so it can be
> > hard to figure out whether they can be used just by looking at the code.
> > I have only taken the strategy of using them in kinds of functions where
> > someone else has alreadyy figured out that they can be used.
>
> It should be fairly clear given what they do I'd have thought - the
> devm_ functions tie the deallocation of a resource to the unbinding of
> a driver from a device so they can only be used to replace things that
> get cleaned up in a device model unbind path.  There's not usually a
> great deal of indirection going on in those.

It is completely clear what they do.  What is not clear is what device
libraries are set up to call the freeing functions at what point.  For
example, I know that that platform drivers are set up for this, but once I
tried to find the lines of code that would justify that, but I could not.
Perhaps I was not patient enough or missed something.

julia

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: sgtl5000: Use devm_ functions
  2014-07-08  8:15           ` [alsa-devel] " Julia Lawall
@ 2014-07-08 14:52             ` Mark Brown
  2014-07-09  5:30               ` Julia Lawall
  0 siblings, 1 reply; 15+ messages in thread
From: Mark Brown @ 2014-07-08 14:52 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Fabio Estevam, alsa-devel, Takashi Iwai, linux-kernel,
	Liam Girdwood, Himangi Saraogi

[-- Attachment #1: Type: text/plain, Size: 931 bytes --]

On Tue, Jul 08, 2014 at 10:15:20AM +0200, Julia Lawall wrote:
> On Tue, 8 Jul 2014, Mark Brown wrote:

> > It should be fairly clear given what they do I'd have thought - the
> > devm_ functions tie the deallocation of a resource to the unbinding of
> > a driver from a device so they can only be used to replace things that
> > get cleaned up in a device model unbind path.  There's not usually a
> > great deal of indirection going on in those.

> It is completely clear what they do.  What is not clear is what device
> libraries are set up to call the freeing functions at what point.  For
> example, I know that that platform drivers are set up for this, but once I
> tried to find the lines of code that would justify that, but I could not.
> Perhaps I was not patient enough or missed something.

All devices do this - it's done as part of the driver model core code so
there is no need for individual buses to do anything.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: sgtl5000: Use devm_ functions
  2014-07-08 14:52             ` Mark Brown
@ 2014-07-09  5:30               ` Julia Lawall
  2014-07-09  8:01                 ` Mark Brown
  0 siblings, 1 reply; 15+ messages in thread
From: Julia Lawall @ 2014-07-09  5:30 UTC (permalink / raw)
  To: Mark Brown
  Cc: Julia Lawall, Fabio Estevam, alsa-devel, Takashi Iwai,
	linux-kernel, Liam Girdwood, Himangi Saraogi



On Tue, 8 Jul 2014, Mark Brown wrote:

> On Tue, Jul 08, 2014 at 10:15:20AM +0200, Julia Lawall wrote:
> > On Tue, 8 Jul 2014, Mark Brown wrote:
> 
> > > It should be fairly clear given what they do I'd have thought - the
> > > devm_ functions tie the deallocation of a resource to the unbinding of
> > > a driver from a device so they can only be used to replace things that
> > > get cleaned up in a device model unbind path.  There's not usually a
> > > great deal of indirection going on in those.
> 
> > It is completely clear what they do.  What is not clear is what device
> > libraries are set up to call the freeing functions at what point.  For
> > example, I know that that platform drivers are set up for this, but once I
> > tried to find the lines of code that would justify that, but I could not.
> > Perhaps I was not patient enough or missed something.
> 
> All devices do this - it's done as part of the driver model core code so
> there is no need for individual buses to do anything.

How should one realize that this does not apply to the original file 
under discussion, sound/soc/codecs/sgtl5000.c?  The associated structure 
is snd_soc_codec_driver.  What code could one look for at the call sites 
of the probe and remove functions to know that managed memory can be used?

thanks,
julia

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: sgtl5000: Use devm_ functions
  2014-07-09  5:30               ` Julia Lawall
@ 2014-07-09  8:01                 ` Mark Brown
  2014-07-09  8:10                   ` Julia Lawall
  0 siblings, 1 reply; 15+ messages in thread
From: Mark Brown @ 2014-07-09  8:01 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Fabio Estevam, alsa-devel, Takashi Iwai, linux-kernel,
	Liam Girdwood, Himangi Saraogi

[-- Attachment #1: Type: text/plain, Size: 710 bytes --]

On Wed, Jul 09, 2014 at 07:30:40AM +0200, Julia Lawall wrote:
> On Tue, 8 Jul 2014, Mark Brown wrote:

> > All devices do this - it's done as part of the driver model core code so
> > there is no need for individual buses to do anything.

> How should one realize that this does not apply to the original file 
> under discussion, sound/soc/codecs/sgtl5000.c?  The associated structure 
> is snd_soc_codec_driver.  What code could one look for at the call sites 
> of the probe and remove functions to know that managed memory can be used?

That's not a device model driver; the way you should realise this is
that there's no device being registered on a bus which is matched by the
driver core.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: sgtl5000: Use devm_ functions
  2014-07-09  8:01                 ` Mark Brown
@ 2014-07-09  8:10                   ` Julia Lawall
  0 siblings, 0 replies; 15+ messages in thread
From: Julia Lawall @ 2014-07-09  8:10 UTC (permalink / raw)
  To: Mark Brown
  Cc: Fabio Estevam, alsa-devel, Takashi Iwai, linux-kernel,
	Liam Girdwood, Himangi Saraogi



On Wed, 9 Jul 2014, Mark Brown wrote:

> On Wed, Jul 09, 2014 at 07:30:40AM +0200, Julia Lawall wrote:
> > On Tue, 8 Jul 2014, Mark Brown wrote:
>
> > > All devices do this - it's done as part of the driver model core code so
> > > there is no need for individual buses to do anything.
>
> > How should one realize that this does not apply to the original file
> > under discussion, sound/soc/codecs/sgtl5000.c?  The associated structure
> > is snd_soc_codec_driver.  What code could one look for at the call sites
> > of the probe and remove functions to know that managed memory can be used?
>
> That's not a device model driver; the way you should realise this is
> that there's no device being registered on a bus which is matched by the
> driver core.

OK, thanks for the clarification.

julia

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-07-09  8:10 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-06  7:08 [PATCH] ASoC: sgtl5000: Use devm_ functions Himangi Saraogi
2014-07-07 14:48 ` Mark Brown
2014-07-07 14:58   ` Julia Lawall
2014-07-07 15:20     ` [alsa-devel] " Fabio Estevam
2014-07-07 15:20       ` Fabio Estevam
2014-07-07 15:23       ` [alsa-devel] " Julia Lawall
2014-07-07 15:34         ` Lars-Peter Clausen
2014-07-07 15:34           ` Lars-Peter Clausen
2014-07-08  8:02         ` [alsa-devel] " Mark Brown
2014-07-08  8:02           ` Mark Brown
2014-07-08  8:15           ` [alsa-devel] " Julia Lawall
2014-07-08 14:52             ` Mark Brown
2014-07-09  5:30               ` Julia Lawall
2014-07-09  8:01                 ` Mark Brown
2014-07-09  8:10                   ` Julia Lawall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.