ASoC: fsl: Fix error handling if platform_device_add fails
PATCH 1/1 ASoC: fsl: Fix error handling if platform_device_add fails
Call platform_device_put() instead of platform_device_unregister() if platform_device_add() fails.
--- sound/soc/fsl/mpc8610_hpcd.c | 2 +- sound/soc/fsl/p1022_ds.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
sound/soc/fsl/mpc8610_hpcd.c +1 -1
@@ -505,7 +505,7 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)return 0 ; error_sound: -platform_device_unregister (sound_device); +platform_device_put (sound_device); error:kfree (machine_data); error_alloc:
sound/soc/fsl/p1022_ds.c +1 -1
@@ -506,7 +506,7 @@ static int p1022_ds_probe(struct platform_device *pdev) error:if (sound_device) -platform_device_unregister (sound_device); +platform_device_put (sound_device);kfree (mdata); error_put:
Signature · 1 line
1.7.4.1
Quoted 27 lines · Axel Lin
Call
platform_device_put()instead ofplatform_device_unregister()ifplatform_device_add()fails.Signed-off-by Axel Lin <[email protected]>--- sound/soc/fsl/mpc8610_hpcd.c | 2 +- sound/soc/fsl/p1022_ds.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)sound/soc/fsl/mpc8610_hpcd.c +1
-1@@ -505,7 +505,7 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)return 0 ; error_sound: -platform_device_unregister (sound_device); +platform_device_put (sound_device); error:kfree (machine_data); error_alloc:sound/soc/fsl/p1022_ds.c +0
-0
sound/soc/fsl/p1022_ds.c static int p1022_ds_probe(struct platform_device *pdev) · line 512
Quoted 8 lines
sound/soc/fsl/p1022_ds.c +1
-1@@ -506,7 +506,7 @@ static int p1022_ds_probe(struct platform_device *pdev) error:if (sound_device) -platform_device_unregister (sound_device); +platform_device_put (sound_device);kfree (mdata); error_put:
Mark Brown
AppliedQuoted 2 lines · Axel Lin
Call
platform_device_put()instead ofplatform_device_unregister()ifplatform_device_add()fails.
Applied, thanks.
Quoted 2 lines · Axel Lin
Call
platform_device_put()instead ofplatform_device_unregister()ifplatform_device_add()fails.
What's wrong with calling platform_device_unregister()?
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
Questions for dummy codec driver
In reply to Axel Linhi all,
I have a question for the dummy codec.
As you know, sometimes maybe we only need set the timing from the processor, and codec just only need tx/rx data; So there do not need the codec driver.
After browser the code, there have NO such a dummy codec driver; and for soc-core, there have not such flags to support this situation. Only what i get is sound/soc/codecs/spdif_transciever.c, but it's specific for TI's DaVinci platform.
I want to get the right direction, so here have some works or discussing for that?
Thx,
Leo Yan
Re: Questions for dummy codec driver
Quoted 1 line · Leo Yan
I have a question for the dummy codec.
Don't start new threads by randomly replying to unrelated mails.
Quoted 3 lines
As you know, sometimes maybe we only need set the timing from the processor, and codec just only need tx/rx data; So there do not need the codec driver.
Even a dumb CODEC will have some constraints on things like the sample rates it can support which need to be conveyed to the framework and ideally the audio routing out of the CODEC should be visible for integration with any external output drivers or similar.
Quoted 4 lines
After browser the code, there have NO such a dummy codec driver; and for soc-core, there have not such flags to support this situation. Only what i get is
sound/soc/codecs/spdif_transciever.c, but it's specific for TI's DaVinci platform.
Not at all, what makes you believe that it is platform specific?
Re: Questions for dummy codec driver
Quoted 6 lines · Mark Brown
Quoted 1 line · Leo Yan
I have a question for the dummy codec.
Don't start new threads by randomly replying to unrelated mails.
Sorry for that :-), the alsa-devel is the unrelated mailing list, right? if so, i will note for that later.
Quoted 9 lines
Quoted 3 lines
As you know, sometimes maybe we only need set the timing from the processor, and codec just only need tx/rx data; So there do not need the codec driver.
Even a dumb CODEC will have some constraints on things like the sample rates it can support which need to be conveyed to the framework and ideally the audio routing out of the CODEC should be visible for integration with any external output drivers or similar.
Get it.
On our platform, there have some devices (like hdmi/bt) do not need config from the CODEC driver, they have their own s/w stack and interface to configure; for the audio driver, just need to set the I2S/PCM timing for them. So if there have a common dummy codec driver, then it can meet our requirement well. Otherwise, there will have some duplicate codes for these dummy codecs.
Quoted 6 lines
Quoted 4 lines
After browser the code, there have NO such a dummy codec driver; and for soc-core, there have not such flags to support this situation. Only what i get is
sound/soc/codecs/spdif_transciever.c, but it's specific for TI's DaVinci platform.Not at all, what makes you believe that it is platform specific?
Re: Questions for dummy codec driver
Quoted 6 lines · Leo Yan
On our platform, there have some devices (like hdmi/bt) do not need config from the CODEC driver, they have their own s/w stack and interface to configure; for the audio driver, just need to set the I2S/PCM timing for them. So if there have a common dummy codec driver, then it can meet our requirement well. Otherwise, there will have some duplicate codes for these dummy codecs.
The general thought here has been that for dumb CODECs the boilerplate is sufficiently small and simple to mean that the discoverability from writing a skeletal driver outweighs the cost of having it kicking around
- while there is some boilerplate there it's easier for someone to grab and use this code than it is to work out how exactly to translate the datasheets into code each time they encounter the part. However, a sufficiently well written generic driver would maintain that advantage while reducing the duplication.
Quoted 2 lines · Axel Lin
Call
platform_device_put()instead ofplatform_device_unregister()ifplatform_device_add()fails.
What's wrong with calling platform_device_unregister()?
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
2011/9/27 Tabi Timur-B04825 <[email protected]>:
Quoted 5 lines
Quoted 2 lines · Axel Lin
Call
platform_device_put()instead ofplatform_device_unregister()ifplatform_device_add()fails.What's wrong with calling
platform_device_unregister()?
/**
* platform_device_unregister - unregister a platform-level device
* @pdev: platform device we're unregistering
*
* Unregistration is done in 2 steps. First we release all resources
* and remove it from the subsystem, then we drop reference count by
* calling platform_device_put().
*/
platform_device_unregister() actually calls platform_device_del() and platform_device_put().
If platform_device_add() call fails, we failed to add the platform device to device hierarchy. Thus we can just call platform_device_put() instead.
Quoted 5 lines
--
Timur Tabi
Linux kernel developer at Freescale