diff mbox

[v2,02/23] ASoC: tas2552: Fix kernel crash when the codec is loaded but not part of a card

Message ID 1433423075-14142-3-git-send-email-peter.ujfalusi@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Ujfalusi June 4, 2015, 1:04 p.m. UTC
If the card is not part of any card the tas_data->codec is NULL since it is
set only during snd_soc_codec_driver.probe, which is not yet called.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/codecs/tas2552.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Mark Brown June 4, 2015, 4:25 p.m. UTC | #1
On Thu, Jun 04, 2015 at 04:04:14PM +0300, Peter Ujfalusi wrote:
> If the card is not part of any card the tas_data->codec is NULL since it is
> set only during snd_soc_codec_driver.probe, which is not yet called.

> @@ -120,6 +120,9 @@ static void tas2552_sw_shutdown(struct tas2552_data *tas_data, int sw_shutdown)
>  {
>  	u8 cfg1_reg;
>  
> +	if (!tas_data->codec)
> +		return;
> +

This fixes the crash but isn't whatever the function is doing important
(so we should fix by using regmap for the I/O or something)?
Mark Brown June 4, 2015, 4:50 p.m. UTC | #2
On Thu, Jun 04, 2015 at 04:04:14PM +0300, Peter Ujfalusi wrote:
> If the card is not part of any card the tas_data->codec is NULL since it is
> set only during snd_soc_codec_driver.probe, which is not yet called.

Please put bugfixes like this at the start of the series.
Peter Ujfalusi June 5, 2015, 6:57 a.m. UTC | #3
On 06/04/2015 07:25 PM, Mark Brown wrote:
> On Thu, Jun 04, 2015 at 04:04:14PM +0300, Peter Ujfalusi wrote:
>> If the card is not part of any card the tas_data->codec is NULL since it is
>> set only during snd_soc_codec_driver.probe, which is not yet called.
> 
>> @@ -120,6 +120,9 @@ static void tas2552_sw_shutdown(struct tas2552_data *tas_data, int sw_shutdown)
>>  {
>>  	u8 cfg1_reg;
>>  
>> +	if (!tas_data->codec)
>> +		return;
>> +
> 
> This fixes the crash but isn't whatever the function is doing important
> (so we should fix by using regmap for the I/O or something)?

If the driver's snd_soc_codec_driver->probe is not called we do not initialize
the amplifier.
This function would put the amp to software shutdown, which is the power up
state of the amp.

Hrm, it should use tas2552 instead of tas_dat for the tas2552_data to be
consistent with the rest of the driver.
I will add a patch for this in v3.
diff mbox

Patch

diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c
index ff82f46ba504..df89947f1032 100644
--- a/sound/soc/codecs/tas2552.c
+++ b/sound/soc/codecs/tas2552.c
@@ -120,6 +120,9 @@  static void tas2552_sw_shutdown(struct tas2552_data *tas_data, int sw_shutdown)
 {
 	u8 cfg1_reg;
 
+	if (!tas_data->codec)
+		return;
+
 	if (sw_shutdown)
 		cfg1_reg = 0;
 	else