summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2026-08-03 16:00:52 +0200
committerTakashi Iwai <tiwai@suse.de>2026-08-04 18:05:07 +0200
commit7c458597a2e9f19e51eec83cd60a4e2e4e3c8d55 (patch)
tree2ca51658d61d70a2e2dec1e1a81b27e0d712c32a
parent5713fea91f183a3d21966856b41f5fbc358fc1f8 (diff)
ALSA: hda: tas2781: Use auto-cleanup for put_device()
A temporary refcount management of a struct device can be done gracefully with __clean(put_device) for avoiding potential leaks. No functional change but just a code cleanup. Cc: Shenghao Ding <shenghao-ding@ti.com> Cc: Kevin Lu <kevin-lu@ti.com> Cc: Baojun Xu <baojun.xu@ti.com> Cc: Sen Wang <sen@ti.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20260803140100.919071-2-tiwai@suse.de
-rw-r--r--sound/hda/codecs/side-codecs/tas2781_hda_i2c.c6
-rw-r--r--sound/hda/codecs/side-codecs/tas2781_hda_spi.c9
2 files changed, 6 insertions, 9 deletions
diff --git a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
index 624db967f17b..6c502c34e015 100644
--- a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
+++ b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
@@ -88,7 +88,6 @@ static int tas2781_read_acpi(struct tasdevice_priv *p, const char *hid)
{
struct gpio_desc *speaker_id;
struct acpi_device *adev;
- struct device *physdev;
LIST_HEAD(resources);
const char *sub;
uint32_t subid;
@@ -101,7 +100,8 @@ static int tas2781_read_acpi(struct tasdevice_priv *p, const char *hid)
return -ENODEV;
}
- physdev = get_device(acpi_get_first_physical_node(adev));
+ struct device *physdev __free(put_device) =
+ get_device(acpi_get_first_physical_node(adev));
ret = acpi_dev_get_resources(adev, &resources, tas2781_get_i2c_res, p);
if (ret < 0) {
dev_err(p->dev, "Failed to get ACPI resource.\n");
@@ -151,14 +151,12 @@ static int tas2781_read_acpi(struct tasdevice_priv *p, const char *hid)
end_2563:
acpi_dev_free_resource_list(&resources);
strscpy(p->dev_name, hid, sizeof(p->dev_name));
- put_device(physdev);
acpi_dev_put(adev);
return 0;
err:
dev_err(p->dev, "read acpi error, ret: %d\n", ret);
- put_device(physdev);
acpi_dev_put(adev);
return ret;
diff --git a/sound/hda/codecs/side-codecs/tas2781_hda_spi.c b/sound/hda/codecs/side-codecs/tas2781_hda_spi.c
index 271c56a79c32..d3b2a746e1a7 100644
--- a/sound/hda/codecs/side-codecs/tas2781_hda_spi.c
+++ b/sound/hda/codecs/side-codecs/tas2781_hda_spi.c
@@ -328,7 +328,6 @@ static int tas2781_read_acpi(struct tas2781_hda *tas_hda,
{
struct tasdevice_priv *p = tas_hda->priv;
struct acpi_device *adev;
- struct device *physdev;
u32 values[HDA_MAX_COMPONENTS];
const char *property;
size_t nval;
@@ -341,7 +340,9 @@ static int tas2781_read_acpi(struct tas2781_hda *tas_hda,
}
strscpy(p->dev_name, hid, sizeof(p->dev_name));
- physdev = get_device(acpi_get_first_physical_node(adev));
+
+ struct device *physdev __free(put_device) =
+ get_device(acpi_get_first_physical_node(adev));
acpi_dev_put(adev);
if (!physdev)
return -ENODEV;
@@ -381,13 +382,11 @@ static int tas2781_read_acpi(struct tas2781_hda *tas_hda,
goto err;
}
}
- put_device(physdev);
return 0;
+
err:
dev_err(p->dev, "read acpi error, ret: %d\n", ret);
- put_device(physdev);
-
return ret;
}