Commit aca289f7 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Takashi Iwai

ALSA: hda: cs35l41: Call put_device() in the scope of get_device()

When put_device() is called in another function it's hard to realize
that and easy to "fix" the code in a wrong way. Instead, move
put_device() to be in the same scope as get_device(), so we prevent
appearance of any attempts to "fix" the code.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220905165826.35979-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 4c8d695c
...@@ -1154,7 +1154,6 @@ static int cs35l41_no_acpi_dsd(struct cs35l41_hda *cs35l41, struct device *physd ...@@ -1154,7 +1154,6 @@ static int cs35l41_no_acpi_dsd(struct cs35l41_hda *cs35l41, struct device *physd
hw_cfg->gpio2.func = CS35L41_INTERRUPT; hw_cfg->gpio2.func = CS35L41_INTERRUPT;
hw_cfg->gpio2.valid = true; hw_cfg->gpio2.valid = true;
hw_cfg->valid = true; hw_cfg->valid = true;
put_device(physdev);
if (strncmp(hid, "CLSA0100", 8) == 0) { if (strncmp(hid, "CLSA0100", 8) == 0) {
hw_cfg->bst_type = CS35L41_EXT_BOOST_NO_VSPK_SWITCH; hw_cfg->bst_type = CS35L41_EXT_BOOST_NO_VSPK_SWITCH;
...@@ -1204,9 +1203,10 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i ...@@ -1204,9 +1203,10 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
property = "cirrus,dev-index"; property = "cirrus,dev-index";
ret = device_property_count_u32(physdev, property); ret = device_property_count_u32(physdev, property);
if (ret <= 0) if (ret <= 0) {
return cs35l41_no_acpi_dsd(cs35l41, physdev, id, hid); ret = cs35l41_no_acpi_dsd(cs35l41, physdev, id, hid);
goto err_put_physdev;
}
if (ret > ARRAY_SIZE(values)) { if (ret > ARRAY_SIZE(values)) {
ret = -EINVAL; ret = -EINVAL;
goto err; goto err;
...@@ -1295,8 +1295,9 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i ...@@ -1295,8 +1295,9 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
return 0; return 0;
err: err:
put_device(physdev);
dev_err(cs35l41->dev, "Failed property %s: %d\n", property, ret); dev_err(cs35l41->dev, "Failed property %s: %d\n", property, ret);
err_put_physdev:
put_device(physdev);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment