Skip to content

Commit cbf87bc

Browse files
andy-shevbroonie
authored andcommitted
ASoC: Intel: bytcr_rt5640: Drop reference count of ACPI device after use
Theoretically the device might gone if its reference count drops to 0. This might be the case when we try to find the first physical node of the ACPI device. We need to keep reference to it until we get a result of the above mentioned call. Refactor the code to drop the reference count at the correct place. While at it, move to acpi_dev_put() as symmetrical call to the acpi_dev_get_first_match_dev(). Fixes: a232b96 ("ASoC: Intel: bytcr_rt5640: use HID translation util") Signed-off-by: Andy Shevchenko <[email protected]> Acked-by: Pierre-Louis Bossart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 7218588 commit cbf87bc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sound/soc/intel/boards/bytcr_rt5640.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,13 +1636,18 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
16361636
if (adev) {
16371637
snprintf(byt_rt5640_codec_name, sizeof(byt_rt5640_codec_name),
16381638
"i2c-%s", acpi_dev_name(adev));
1639-
put_device(&adev->dev);
16401639
byt_rt5640_dais[dai_index].codecs->name = byt_rt5640_codec_name;
16411640
} else {
16421641
dev_err(dev, "Error cannot find '%s' dev\n", mach->id);
16431642
return -ENXIO;
16441643
}
16451644

1645+
codec_dev = acpi_get_first_physical_node(adev);
1646+
acpi_dev_put(adev);
1647+
if (!codec_dev)
1648+
return -EPROBE_DEFER;
1649+
priv->codec_dev = get_device(codec_dev);
1650+
16461651
/*
16471652
* swap SSP0 if bytcr is detected
16481653
* (will be overridden if DMI quirk is detected)
@@ -1717,11 +1722,6 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
17171722
byt_rt5640_quirk = quirk_override;
17181723
}
17191724

1720-
codec_dev = acpi_get_first_physical_node(adev);
1721-
if (!codec_dev)
1722-
return -EPROBE_DEFER;
1723-
priv->codec_dev = get_device(codec_dev);
1724-
17251725
if (byt_rt5640_quirk & BYT_RT5640_JD_HP_ELITEP_1000G2) {
17261726
acpi_dev_add_driver_gpios(ACPI_COMPANION(priv->codec_dev),
17271727
byt_rt5640_hp_elitepad_1000g2_gpios);

0 commit comments

Comments
 (0)