Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: cs4271: free reset gpio in cs4271_remove()
@ 2014-02-19 11:07 Daniel Mack
  2014-02-19 11:15 ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Mack @ 2014-02-19 11:07 UTC (permalink / raw)
  To: broonie, subaparts; +Cc: brian.austin, alsa-devel, Paul.Handrigan, Daniel Mack

The reset GPIO line is acquired in cs4271_probe(), so it should be
freed from cs4271_remove() as well. This way, the driver can unloaded
and reloaded more than once.

Signed-off-by: Daniel Mack <zonque@gmail.com>
---
 sound/soc/codecs/cs4271.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c
index ce05fd9..aeaa5c6 100644
--- a/sound/soc/codecs/cs4271.c
+++ b/sound/soc/codecs/cs4271.c
@@ -604,9 +604,11 @@ static int cs4271_remove(struct snd_soc_codec *codec)
 {
 	struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
 
-	if (gpio_is_valid(cs4271->gpio_nreset))
+	if (gpio_is_valid(cs4271->gpio_nreset)) {
 		/* Set codec to the reset state */
 		gpio_set_value(cs4271->gpio_nreset, 0);
+		devm_gpio_free(codec->dev, cs4271->gpio_nreset);
+	}
 
 	return 0;
 };
-- 
1.8.5.3

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

* Re: [PATCH] ASoC: cs4271: free reset gpio in cs4271_remove()
  2014-02-19 11:07 [PATCH] ASoC: cs4271: free reset gpio in cs4271_remove() Daniel Mack
@ 2014-02-19 11:15 ` Mark Brown
  2014-02-19 11:24   ` Daniel Mack
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2014-02-19 11:15 UTC (permalink / raw)
  To: Daniel Mack; +Cc: brian.austin, subaparts, alsa-devel, Paul.Handrigan


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

On Wed, Feb 19, 2014 at 12:07:12PM +0100, Daniel Mack wrote:

> +	if (gpio_is_valid(cs4271->gpio_nreset)) {
>  		/* Set codec to the reset state */
>  		gpio_set_value(cs4271->gpio_nreset, 0);
> +		devm_gpio_free(codec->dev, cs4271->gpio_nreset);
> +	}

If it's being requested as a managed resource shouldn't it be being
freed automatically?

[-- 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] 7+ messages in thread

* Re: [PATCH] ASoC: cs4271: free reset gpio in cs4271_remove()
  2014-02-19 11:15 ` Mark Brown
@ 2014-02-19 11:24   ` Daniel Mack
  2014-02-19 11:43     ` Mark Brown
  2014-02-19 11:43     ` Lars-Peter Clausen
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Mack @ 2014-02-19 11:24 UTC (permalink / raw)
  To: Mark Brown; +Cc: brian.austin, subaparts, alsa-devel, Paul.Handrigan

On 02/19/2014 12:15 PM, Mark Brown wrote:
> On Wed, Feb 19, 2014 at 12:07:12PM +0100, Daniel Mack wrote:
> 
>> +	if (gpio_is_valid(cs4271->gpio_nreset)) {
>>  		/* Set codec to the reset state */
>>  		gpio_set_value(cs4271->gpio_nreset, 0);
>> +		devm_gpio_free(codec->dev, cs4271->gpio_nreset);
>> +	}
> 
> If it's being requested as a managed resource shouldn't it be being
> freed automatically?
> 

Nope, as the module itself will not go away necessarily. I hit the bug
when unloading and reloading the machine driver. cs4271_probe(codec)
will fail to acquire and drive the reset line, and the codec stays in reset.

Daniel

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

* Re: [PATCH] ASoC: cs4271: free reset gpio in cs4271_remove()
  2014-02-19 11:24   ` Daniel Mack
@ 2014-02-19 11:43     ` Mark Brown
  2014-02-19 12:09       ` Daniel Mack
  2014-02-19 11:43     ` Lars-Peter Clausen
  1 sibling, 1 reply; 7+ messages in thread
From: Mark Brown @ 2014-02-19 11:43 UTC (permalink / raw)
  To: Daniel Mack; +Cc: brian.austin, subaparts, alsa-devel, Paul.Handrigan


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

On Wed, Feb 19, 2014 at 12:24:23PM +0100, Daniel Mack wrote:
> On 02/19/2014 12:15 PM, Mark Brown wrote:
> > On Wed, Feb 19, 2014 at 12:07:12PM +0100, Daniel Mack wrote:

> >> +	if (gpio_is_valid(cs4271->gpio_nreset)) {
> >>  		/* Set codec to the reset state */
> >>  		gpio_set_value(cs4271->gpio_nreset, 0);
> >> +		devm_gpio_free(codec->dev, cs4271->gpio_nreset);
> >> +	}

> > If it's being requested as a managed resource shouldn't it be being
> > freed automatically?

> Nope, as the module itself will not go away necessarily. I hit the bug
> when unloading and reloading the machine driver. cs4271_probe(codec)
> will fail to acquire and drive the reset line, and the codec stays in reset.

The fix here is to move the resource acquisition to the bus level probe
instead of the ASoC card startup.

[-- 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] 7+ messages in thread

* Re: [PATCH] ASoC: cs4271: free reset gpio in cs4271_remove()
  2014-02-19 11:24   ` Daniel Mack
  2014-02-19 11:43     ` Mark Brown
@ 2014-02-19 11:43     ` Lars-Peter Clausen
  1 sibling, 0 replies; 7+ messages in thread
From: Lars-Peter Clausen @ 2014-02-19 11:43 UTC (permalink / raw)
  To: Daniel Mack
  Cc: brian.austin, Mark Brown, subaparts, alsa-devel, Paul.Handrigan

On 02/19/2014 12:24 PM, Daniel Mack wrote:
> On 02/19/2014 12:15 PM, Mark Brown wrote:
>> On Wed, Feb 19, 2014 at 12:07:12PM +0100, Daniel Mack wrote:
>>
>>> +	if (gpio_is_valid(cs4271->gpio_nreset)) {
>>>   		/* Set codec to the reset state */
>>>   		gpio_set_value(cs4271->gpio_nreset, 0);
>>> +		devm_gpio_free(codec->dev, cs4271->gpio_nreset);
>>> +	}
>>
>> If it's being requested as a managed resource shouldn't it be being
>> freed automatically?
>>
>
> Nope, as the module itself will not go away necessarily. I hit the bug
> when unloading and reloading the machine driver. cs4271_probe(codec)
> will fail to acquire and drive the reset line, and the codec stays in reset.
>

In my opinion a better solution is to move the requesting of the GPIO from 
the CODEC probe() function to the SPI/I2C probe() functions. Actually it 
looks as if most of the code (if not all) in the CODEC probe() function 
should be done when the driver is probed.

- Lars

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

* Re: [PATCH] ASoC: cs4271: free reset gpio in cs4271_remove()
  2014-02-19 11:43     ` Mark Brown
@ 2014-02-19 12:09       ` Daniel Mack
  2014-02-19 14:00         ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Mack @ 2014-02-19 12:09 UTC (permalink / raw)
  To: Mark Brown; +Cc: brian.austin, subaparts, alsa-devel, Paul.Handrigan

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/19/2014 12:43 PM, Mark Brown wrote:
> On Wed, Feb 19, 2014 at 12:24:23PM +0100, Daniel Mack wrote:
>> On 02/19/2014 12:15 PM, Mark Brown wrote:
>>> On Wed, Feb 19, 2014 at 12:07:12PM +0100, Daniel Mack wrote:
> 
>>>> +	if (gpio_is_valid(cs4271->gpio_nreset)) { /* Set codec to
>>>> the reset state */ gpio_set_value(cs4271->gpio_nreset, 0); +
>>>> devm_gpio_free(codec->dev, cs4271->gpio_nreset); +	}
> 
>>> If it's being requested as a managed resource shouldn't it be
>>> being freed automatically?
> 
>> Nope, as the module itself will not go away necessarily. I hit
>> the bug when unloading and reloading the machine driver.
>> cs4271_probe(codec) will fail to acquire and drive the reset
>> line, and the codec stays in reset.
> 
> The fix here is to move the resource acquisition to the bus level
> probe instead of the ASoC card startup.
> 

Alright. I thought there was a verdict once that resource claiming
should be done right before usage, but you're right, it really rather
belongs into the bus probe functions.

I'll send another version.


Thanks!
Daniel

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJTBJ72AAoJELphMRr8Y1QkXt8P/RErTL26/X3s/MnYfhuPDzsx
T7oU/YSpYvcqBVBab3rZjbyELRPqcrWO0XaiVFLiOqwt2KslKK/k8zz8gZIsvOxM
YzheQMzI45sosYCFf1OssC7ojwTTks/hwgKzOj0Hi0aWtSVYRgV2kvg8S4tiwEzl
OpM9Z4r0lCw9kJidlSwPCXcg+s4BN6xMcqaTIFfU1QCQ84dxHwzhf7cYZliOtWEv
FlnMVKYAtBVCACVqBxHS+2OdopcTuwQ0aqts7UMXFq2MGCIYf6Fyq/qmmCMuaZrN
yDcm3fpJodIoZo20nIf2zpaPGgD7ce+LK/Mu46sZ4MFRBxHgGlQ0C2UNZgNlVILI
mY6hj8s44kCptX1sDPTviYoRnxQ4PTAdRUjfVRuShjkEFi8WHKEbIHwLqn0BvjSB
FaaESTg5NhBJsAroTK83nqqY7MxcLZV4YBhnoH4Mhc2IZHa5hOxcHy5crGyUUEGF
4QWMJoHW+J3s8malsvwcNj8Fv4a6SaeptNr+4EkGW/lwrVAjl/03Ei7MvvqApyPm
TSRuBXQUbiJhxBpkAMhFQ7jIj3Gw+CcgiudcwLA1sVdN2uTvbe/YRas/ZlWQn/W9
TVihbfTM8apHwCacyJYX7yE16eJ162AznYqCZC5ZCJ1L2k8ep30bhwEJk2nq4GP1
6FikGJ1wGOLdvDbwOc8b
=dthk
-----END PGP SIGNATURE-----

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

* Re: [PATCH] ASoC: cs4271: free reset gpio in cs4271_remove()
  2014-02-19 12:09       ` Daniel Mack
@ 2014-02-19 14:00         ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2014-02-19 14:00 UTC (permalink / raw)
  To: Daniel Mack; +Cc: brian.austin, subaparts, alsa-devel, Paul.Handrigan


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

On Wed, Feb 19, 2014 at 01:09:27PM +0100, Daniel Mack wrote:

> Alright. I thought there was a verdict once that resource claiming
> should be done right before usage, but you're right, it really rather
> belongs into the bus probe functions.

No, that's not ever been the case as far as I can recall.  There were
some things it used to not be possible to do due to the ASoC level I/O
only working after the card comes up but that's a different issue.

[-- 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] 7+ messages in thread

end of thread, other threads:[~2014-02-19 14:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-19 11:07 [PATCH] ASoC: cs4271: free reset gpio in cs4271_remove() Daniel Mack
2014-02-19 11:15 ` Mark Brown
2014-02-19 11:24   ` Daniel Mack
2014-02-19 11:43     ` Mark Brown
2014-02-19 12:09       ` Daniel Mack
2014-02-19 14:00         ` Mark Brown
2014-02-19 11:43     ` Lars-Peter Clausen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox