* [PATCH 2/3] ALSA: hda: tas2781: Use auto-cleanup for put_device()
2026-08-03 14:00 [PATCH 1/3] ALSA: hda: aw88399: Use auto-cleanup for put_device() Takashi Iwai
@ 2026-08-03 14:00 ` Takashi Iwai
2026-08-03 14:00 ` [PATCH 3/3] ALSA: hda: cs35l41: " Takashi Iwai
2026-08-03 21:26 ` [PATCH 1/3] ALSA: hda: aw88399: " Marco Giunta
2 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2026-08-03 14:00 UTC (permalink / raw)
To: linux-sound; +Cc: linux-kernel, Shenghao Ding, Kevin Lu, Baojun Xu, Sen Wang
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>
---
sound/hda/codecs/side-codecs/tas2781_hda_i2c.c | 6 ++----
sound/hda/codecs/side-codecs/tas2781_hda_spi.c | 9 ++++-----
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;
}
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 3/3] ALSA: hda: cs35l41: Use auto-cleanup for put_device()
2026-08-03 14:00 [PATCH 1/3] ALSA: hda: aw88399: Use auto-cleanup for put_device() Takashi Iwai
2026-08-03 14:00 ` [PATCH 2/3] ALSA: hda: tas2781: " Takashi Iwai
@ 2026-08-03 14:00 ` Takashi Iwai
2026-08-03 21:26 ` [PATCH 1/3] ALSA: hda: aw88399: " Marco Giunta
2 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2026-08-03 14:00 UTC (permalink / raw)
To: linux-sound; +Cc: linux-kernel, patches
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: patches@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/hda/codecs/side-codecs/cs35l41_hda.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/sound/hda/codecs/side-codecs/cs35l41_hda.c b/sound/hda/codecs/side-codecs/cs35l41_hda.c
index c8eba0638ada..62296be45c55 100644
--- a/sound/hda/codecs/side-codecs/cs35l41_hda.c
+++ b/sound/hda/codecs/side-codecs/cs35l41_hda.c
@@ -1915,7 +1915,6 @@ int cs35l41_hda_parse_acpi(struct cs35l41_hda *cs35l41, struct device *physdev,
static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, int id)
{
struct acpi_device *adev;
- struct device *physdev;
struct spi_device *spi;
const char *sub;
int ret;
@@ -1927,7 +1926,8 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
}
cs35l41->dacpi = adev;
- physdev = get_device(acpi_get_first_physical_node(adev));
+ struct device *physdev __free(put_device) =
+ get_device(acpi_get_first_physical_node(adev));
if (!physdev) {
acpi_dev_put(adev);
return -ENODEV;
@@ -1945,13 +1945,9 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
}
ret = cs35l41_hda_parse_acpi(cs35l41, physdev, id);
- if (ret) {
- put_device(physdev);
+ if (ret)
return ret;
- }
out:
- put_device(physdev);
-
cs35l41->bypass_fw = false;
if (cs35l41->control_bus == SPI) {
spi = to_spi_device(cs35l41->dev);
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread