From: Markus Elfring <Markus.Elfring@web.de>
To: linux-sound@vger.kernel.org, Jaroslav Kysela <perex@perex.cz>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Takashi Iwai <tiwai@suse.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Julia Lawall <julia.lawall@inria.fr>
Subject: [PATCH] ASoC: mc13783: Use scope-based resource management in mc13783_codec_probe()
Date: Sun, 15 Sep 2024 21:50:39 +0200 [thread overview]
Message-ID: <21094235-3f45-4a67-a463-7b4658b9ee06@web.de> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 15 Sep 2024 21:41:00 +0200
Scope-based resource management became supported also for another
programming interface by contributions of Jonathan Cameron on 2024-02-25.
See also the commit 9448e55d032d99af8e23487f51a542d51b2f1a48 ("of:
Add cleanup.h based auto release via __free(device_node) markings").
* Thus use the attribute “__free(device_node)”.
* Reduce the scope for the local variable “np”.
* Omit explicit of_node_put() calls accordingly.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/soc/codecs/mc13783.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c
index 086ac97e8386..ed894bfc6a1c 100644
--- a/sound/soc/codecs/mc13783.c
+++ b/sound/soc/codecs/mc13783.c
@@ -733,7 +733,6 @@ static int __init mc13783_codec_probe(struct platform_device *pdev)
{
struct mc13783_priv *priv;
struct mc13xxx_codec_platform_data *pdata = pdev->dev.platform_data;
- struct device_node *np;
int ret;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
@@ -744,23 +743,18 @@ static int __init mc13783_codec_probe(struct platform_device *pdev)
priv->adc_ssi_port = pdata->adc_ssi_port;
priv->dac_ssi_port = pdata->dac_ssi_port;
} else {
- np = of_get_child_by_name(pdev->dev.parent->of_node, "codec");
+ struct device_node *np __free(device_node)
+ = of_get_child_by_name(pdev->dev.parent->of_node, "codec");
if (!np)
return -ENOSYS;
ret = of_property_read_u32(np, "adc-port", &priv->adc_ssi_port);
- if (ret) {
- of_node_put(np);
+ if (ret)
return ret;
- }
ret = of_property_read_u32(np, "dac-port", &priv->dac_ssi_port);
- if (ret) {
- of_node_put(np);
+ if (ret)
return ret;
- }
-
- of_node_put(np);
}
dev_set_drvdata(&pdev->dev, priv);
--
2.46.0
reply other threads:[~2024-09-15 19:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=21094235-3f45-4a67-a463-7b4658b9ee06@web.de \
--to=markus.elfring@web.de \
--cc=Jonathan.Cameron@huawei.com \
--cc=broonie@kernel.org \
--cc=julia.lawall@inria.fr \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox