* [PATCH 0/2] ASoC: tas5805m: Adjustments for tas5805m_i2c_probe()
@ 2024-09-16 8:38 Markus Elfring
2024-09-16 8:48 ` [PATCH 1/2] ASoC: tas5805m: Use scope-based resource management in tas5805m_i2c_probe() Markus Elfring
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Markus Elfring @ 2024-09-16 8:38 UTC (permalink / raw)
To: linux-sound, Jaroslav Kysela, Liam Girdwood, Mark Brown,
Takashi Iwai
Cc: LKML, Dmitry Torokhov, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Sep 2024 10:30:10 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Use scope-based resource management
Improve a size determination
sound/soc/codecs/tas5805m.c | 33 ++++++++++++++++-----------------
1 file changed, 16 insertions(+), 17 deletions(-)
--
2.46.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] ASoC: tas5805m: Use scope-based resource management in tas5805m_i2c_probe()
2024-09-16 8:38 [PATCH 0/2] ASoC: tas5805m: Adjustments for tas5805m_i2c_probe() Markus Elfring
@ 2024-09-16 8:48 ` Markus Elfring
2024-09-16 8:50 ` [PATCH 2/2] ASoC: tas5805m: Improve a size determination " Markus Elfring
2024-09-30 21:26 ` (subset) [PATCH 0/2] ASoC: tas5805m: Adjustments for tas5805m_i2c_probe() Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2024-09-16 8:48 UTC (permalink / raw)
To: linux-sound, Daniel Beer, Jaroslav Kysela, Liam Girdwood,
Mark Brown, Takashi Iwai
Cc: LKML, Dmitry Torokhov, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Sep 2024 10:11:59 +0200
Scope-based resource management became supported also for another
programming interface by contributions of Dmitry Torokhov on 2024-01-17.
See also the commit 8dde8fa0cc3edce73c050b9882d06c1a575f6402
("firmware_loader: introduce __free() cleanup hanler").
* Thus use the attribute “__free(firmware)”.
* Reduce the scope for the local variable “fw”.
* Omit explicit release_firmware() calls accordingly.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/soc/codecs/tas5805m.c | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/sound/soc/codecs/tas5805m.c b/sound/soc/codecs/tas5805m.c
index 3b53eba38a0b..f37eec960364 100644
--- a/sound/soc/codecs/tas5805m.c
+++ b/sound/soc/codecs/tas5805m.c
@@ -464,7 +464,6 @@ static int tas5805m_i2c_probe(struct i2c_client *i2c)
struct tas5805m_priv *tas5805m;
char filename[128];
const char *config_name;
- const struct firmware *fw;
int ret;
regmap = devm_regmap_init_i2c(i2c, &tas5805m_regmap);
@@ -509,24 +508,24 @@ static int tas5805m_i2c_probe(struct i2c_client *i2c)
snprintf(filename, sizeof(filename), "tas5805m_dsp_%s.bin",
config_name);
- ret = request_firmware(&fw, filename, dev);
- if (ret)
- return ret;
- if ((fw->size < 2) || (fw->size & 1)) {
- dev_err(dev, "firmware is invalid\n");
- release_firmware(fw);
- return -EINVAL;
- }
+ {
+ struct firmware const *fw __free(firmware) = NULL;
- tas5805m->dsp_cfg_len = fw->size;
- tas5805m->dsp_cfg_data = devm_kmemdup(dev, fw->data, fw->size, GFP_KERNEL);
- if (!tas5805m->dsp_cfg_data) {
- release_firmware(fw);
- return -ENOMEM;
- }
+ ret = request_firmware(&fw, filename, dev);
+ if (ret)
+ return ret;
+
+ if ((fw->size < 2) || (fw->size & 1)) {
+ dev_err(dev, "firmware is invalid\n");
+ return -EINVAL;
+ }
- release_firmware(fw);
+ tas5805m->dsp_cfg_len = fw->size;
+ tas5805m->dsp_cfg_data = devm_kmemdup(dev, fw->data, fw->size, GFP_KERNEL);
+ if (!tas5805m->dsp_cfg_data)
+ return -ENOMEM;
+ }
/* Do the first part of the power-on here, while we can expect
* the I2S interface to be quiet. We must raise PDN# and then
--
2.46.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ASoC: tas5805m: Improve a size determination in tas5805m_i2c_probe()
2024-09-16 8:38 [PATCH 0/2] ASoC: tas5805m: Adjustments for tas5805m_i2c_probe() Markus Elfring
2024-09-16 8:48 ` [PATCH 1/2] ASoC: tas5805m: Use scope-based resource management in tas5805m_i2c_probe() Markus Elfring
@ 2024-09-16 8:50 ` Markus Elfring
2024-09-30 21:26 ` (subset) [PATCH 0/2] ASoC: tas5805m: Adjustments for tas5805m_i2c_probe() Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2024-09-16 8:50 UTC (permalink / raw)
To: linux-sound, Daniel Beer, Jaroslav Kysela, Liam Girdwood,
Mark Brown, Takashi Iwai
Cc: LKML, Dmitry Torokhov, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Sep 2024 10:20:12 +0200
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/soc/codecs/tas5805m.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/tas5805m.c b/sound/soc/codecs/tas5805m.c
index f37eec960364..d4f028451071 100644
--- a/sound/soc/codecs/tas5805m.c
+++ b/sound/soc/codecs/tas5805m.c
@@ -473,7 +473,7 @@ static int tas5805m_i2c_probe(struct i2c_client *i2c)
return ret;
}
- tas5805m = devm_kzalloc(dev, sizeof(struct tas5805m_priv), GFP_KERNEL);
+ tas5805m = devm_kzalloc(dev, sizeof(*tas5805m), GFP_KERNEL);
if (!tas5805m)
return -ENOMEM;
--
2.46.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: (subset) [PATCH 0/2] ASoC: tas5805m: Adjustments for tas5805m_i2c_probe()
2024-09-16 8:38 [PATCH 0/2] ASoC: tas5805m: Adjustments for tas5805m_i2c_probe() Markus Elfring
2024-09-16 8:48 ` [PATCH 1/2] ASoC: tas5805m: Use scope-based resource management in tas5805m_i2c_probe() Markus Elfring
2024-09-16 8:50 ` [PATCH 2/2] ASoC: tas5805m: Improve a size determination " Markus Elfring
@ 2024-09-30 21:26 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2024-09-30 21:26 UTC (permalink / raw)
To: linux-sound, Jaroslav Kysela, Liam Girdwood, Takashi Iwai,
Markus Elfring
Cc: LKML, Dmitry Torokhov, Julia Lawall
On Mon, 16 Sep 2024 10:38:09 +0200, Markus Elfring wrote:
> A few update suggestions were taken into account
> from static source code analysis.
>
> Markus Elfring (2):
> Use scope-based resource management
> Improve a size determination
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[2/2] ASoC: tas5805m: Improve a size determination in tas5805m_i2c_probe()
commit: 0e9f73f109025f0d5d16b104b6684e6c03aa0c83
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-30 21:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-16 8:38 [PATCH 0/2] ASoC: tas5805m: Adjustments for tas5805m_i2c_probe() Markus Elfring
2024-09-16 8:48 ` [PATCH 1/2] ASoC: tas5805m: Use scope-based resource management in tas5805m_i2c_probe() Markus Elfring
2024-09-16 8:50 ` [PATCH 2/2] ASoC: tas5805m: Improve a size determination " Markus Elfring
2024-09-30 21:26 ` (subset) [PATCH 0/2] ASoC: tas5805m: Adjustments for tas5805m_i2c_probe() Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox