[PATCH 00/10] Use const where applicable
Use devm_kstrdup_const in few places to possibly save a bit of memory. Mark some of the structs as const, as they are not modified and used as is.
Amadeusz Sławiński (10): ASoC: Intel: avs: hdaudio: Use devm_kstrdup_const ASoC: Intel: avs: Use devm_kstrdup_const ASoC: Intel: avs: hdaudio: Constify probing_link ASoC: Intel: avs: es8336: Constify card_headset_pins ASoC: Intel: avs: nau8825: Constify card_headset_pins ASoC: Intel: avs: rt274: Constify card_headset_pins ASoC: Intel: avs: rt286: Constify card_headset_pins ASoC: Intel: avs: rt298: Constify card_headset_pins ASoC: Intel: avs: rt5663: Constify card_headset_pins ASoC: Intel: avs: rt5682: Constify card_headset_pins
sound/soc/intel/avs/avs.h | 2 +- sound/soc/intel/avs/boards/es8336.c | 2 +- sound/soc/intel/avs/boards/hdaudio.c | 6 +++--- sound/soc/intel/avs/boards/nau8825.c | 2 +- sound/soc/intel/avs/boards/rt274.c | 2 +- sound/soc/intel/avs/boards/rt286.c | 2 +- sound/soc/intel/avs/boards/rt298.c | 2 +- sound/soc/intel/avs/boards/rt5663.c | 2 +- sound/soc/intel/avs/boards/rt5682.c | 2 +- sound/soc/intel/avs/utils.c | 8 ++++---- 10 files changed, 15 insertions(+), 15 deletions(-)
base-commit: 36d464cba8bdfd268282a97e9fdc701aca2ed8cb
HDA codec name is constant and we just duplicate it, use const variant of devm_kstrdup to possibly save a bit of memory.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/hdaudio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/intel/avs/boards/hdaudio.c b/sound/soc/intel/avs/boards/hdaudio.c index 79b4aca413338..2de703b909c30 100644 --- a/sound/soc/intel/avs/boards/hdaudio.c +++ b/sound/soc/intel/avs/boards/hdaudio.c @@ -54,7 +54,7 @@ static int avs_create_dai_links(struct device *dev, struct hda_codec *codec, int if (!dl[i].cpus->dai_name) return -ENOMEM;
- dl[i].codecs->name = devm_kstrdup(dev, cname, GFP_KERNEL); + dl[i].codecs->name = devm_kstrdup_const(dev, cname, GFP_KERNEL); if (!dl[i].codecs->name) return -ENOMEM;
@@ -191,7 +191,7 @@ static int avs_hdaudio_probe(struct platform_device *pdev) if (!binder->platforms || !binder->codecs) return -ENOMEM;
- binder->codecs->name = devm_kstrdup(dev, dev_name(&codec->core.dev), GFP_KERNEL); + binder->codecs->name = devm_kstrdup_const(dev, dev_name(&codec->core.dev), GFP_KERNEL); if (!binder->codecs->name) return -ENOMEM;
FW name is constant and we just duplicate it, use const variant of devm_kstrdup to possibly save a bit of memory.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/avs.h | 2 +- sound/soc/intel/avs/utils.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/sound/soc/intel/avs/avs.h b/sound/soc/intel/avs/avs.h index f80f79415344a..9a02e2b528bc5 100644 --- a/sound/soc/intel/avs/avs.h +++ b/sound/soc/intel/avs/avs.h @@ -107,7 +107,7 @@ struct avs_spec { };
struct avs_fw_entry { - char *name; + const char *name; const struct firmware *fw;
struct list_head node; diff --git a/sound/soc/intel/avs/utils.c b/sound/soc/intel/avs/utils.c index 82416b86662d8..8100c2fa0a7ed 100644 --- a/sound/soc/intel/avs/utils.c +++ b/sound/soc/intel/avs/utils.c @@ -250,7 +250,7 @@ int avs_request_firmware(struct avs_dev *adev, const struct firmware **fw_p, con if (!entry) return -ENOMEM;
- entry->name = kstrdup(name, GFP_KERNEL); + entry->name = kstrdup_const(name, GFP_KERNEL); if (!entry->name) { kfree(entry); return -ENOMEM; @@ -258,7 +258,7 @@ int avs_request_firmware(struct avs_dev *adev, const struct firmware **fw_p, con
ret = request_firmware(&entry->fw, name, adev->dev); if (ret < 0) { - kfree(entry->name); + kfree_const(entry->name); kfree(entry); return ret; } @@ -282,7 +282,7 @@ void avs_release_last_firmware(struct avs_dev *adev)
list_del(&entry->node); release_firmware(entry->fw); - kfree(entry->name); + kfree_const(entry->name); kfree(entry); }
@@ -296,7 +296,7 @@ void avs_release_firmwares(struct avs_dev *adev) list_for_each_entry_safe(entry, tmp, &adev->fw_list, node) { list_del(&entry->node); release_firmware(entry->fw); - kfree(entry->name); + kfree_const(entry->name); kfree(entry); } }
probing_link is passed to devm_kmemdup, and is never modified, may as well mark it const.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/hdaudio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/intel/avs/boards/hdaudio.c b/sound/soc/intel/avs/boards/hdaudio.c index 2de703b909c30..4433175814f80 100644 --- a/sound/soc/intel/avs/boards/hdaudio.c +++ b/sound/soc/intel/avs/boards/hdaudio.c @@ -155,7 +155,7 @@ static int avs_probing_link_init(struct snd_soc_pcm_runtime *rtm) return 0; }
-static struct snd_soc_dai_link probing_link = { +static const struct snd_soc_dai_link probing_link = { .name = "probing-LINK", .id = -1, .nonatomic = 1,
card_headset_pins is never modified, mark it const.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/es8336.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/intel/avs/boards/es8336.c b/sound/soc/intel/avs/boards/es8336.c index 5c90a60075773..ff3bd15132694 100644 --- a/sound/soc/intel/avs/boards/es8336.c +++ b/sound/soc/intel/avs/boards/es8336.c @@ -85,7 +85,7 @@ static const struct snd_kcontrol_new card_controls[] = { SOC_DAPM_PIN_SWITCH("Internal Mic"), };
-static struct snd_soc_jack_pin card_headset_pins[] = { +static const struct snd_soc_jack_pin card_headset_pins[] = { { .pin = "Headphone", .mask = SND_JACK_HEADPHONE,
card_headset_pins is never modified, mark it const.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/nau8825.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/intel/avs/boards/nau8825.c b/sound/soc/intel/avs/boards/nau8825.c index 55db75efae414..3164745b15167 100644 --- a/sound/soc/intel/avs/boards/nau8825.c +++ b/sound/soc/intel/avs/boards/nau8825.c @@ -67,7 +67,7 @@ static const struct snd_soc_dapm_route card_base_routes[] = { { "Headset Mic", NULL, "Platform Clock" }, };
-static struct snd_soc_jack_pin card_headset_pins[] = { +static const struct snd_soc_jack_pin card_headset_pins[] = { { .pin = "Headphone Jack", .mask = SND_JACK_HEADPHONE,
card_headset_pins is never modified, mark it const.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/rt274.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/intel/avs/boards/rt274.c b/sound/soc/intel/avs/boards/rt274.c index 1cf5242160875..e3aa28780df5a 100644 --- a/sound/soc/intel/avs/boards/rt274.c +++ b/sound/soc/intel/avs/boards/rt274.c @@ -75,7 +75,7 @@ static const struct snd_soc_dapm_route card_base_routes[] = { {"MIC", NULL, "Platform Clock"}, };
-static struct snd_soc_jack_pin card_headset_pins[] = { +static const struct snd_soc_jack_pin card_headset_pins[] = { { .pin = "Headphone Jack", .mask = SND_JACK_HEADPHONE,
card_headset_pins is never modified, mark it const.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/rt286.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/intel/avs/boards/rt286.c b/sound/soc/intel/avs/boards/rt286.c index 4740bba105703..d24316fc4db9c 100644 --- a/sound/soc/intel/avs/boards/rt286.c +++ b/sound/soc/intel/avs/boards/rt286.c @@ -38,7 +38,7 @@ static const struct snd_soc_dapm_route card_base_routes[] = { {"Speaker", NULL, "SPOL"}, };
-static struct snd_soc_jack_pin card_headset_pins[] = { +static const struct snd_soc_jack_pin card_headset_pins[] = { { .pin = "Headphone Jack", .mask = SND_JACK_HEADPHONE,
card_headset_pins is never modified, mark it const.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/rt298.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/intel/avs/boards/rt298.c b/sound/soc/intel/avs/boards/rt298.c index 6e409e29f6974..7fd28544f7869 100644 --- a/sound/soc/intel/avs/boards/rt298.c +++ b/sound/soc/intel/avs/boards/rt298.c @@ -49,7 +49,7 @@ static const struct snd_soc_dapm_route card_base_routes[] = { {"Speaker", NULL, "SPOL"}, };
-static struct snd_soc_jack_pin card_headset_pins[] = { +static const struct snd_soc_jack_pin card_headset_pins[] = { { .pin = "Headphone Jack", .mask = SND_JACK_HEADPHONE,
card_headset_pins is never modified, mark it const.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/rt5663.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/intel/avs/boards/rt5663.c b/sound/soc/intel/avs/boards/rt5663.c index 1880c315cc4d1..ba8c42d026da2 100644 --- a/sound/soc/intel/avs/boards/rt5663.c +++ b/sound/soc/intel/avs/boards/rt5663.c @@ -43,7 +43,7 @@ static const struct snd_soc_dapm_route card_routes[] = { { "IN1N", NULL, "Headset Mic" }, };
-static struct snd_soc_jack_pin card_headset_pins[] = { +static const struct snd_soc_jack_pin card_headset_pins[] = { { .pin = "Headphone Jack", .mask = SND_JACK_HEADPHONE,
card_headset_pins is never modified, mark it const.
Reviewed-by: Cezary Rojewski cezary.rojewski@intel.com Signed-off-by: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com --- sound/soc/intel/avs/boards/rt5682.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/intel/avs/boards/rt5682.c b/sound/soc/intel/avs/boards/rt5682.c index 594a971ded9eb..823f04dba2f76 100644 --- a/sound/soc/intel/avs/boards/rt5682.c +++ b/sound/soc/intel/avs/boards/rt5682.c @@ -80,7 +80,7 @@ static const struct snd_soc_dapm_route card_base_routes[] = { { "IN1P", NULL, "Headset Mic" }, };
-static struct snd_soc_jack_pin card_jack_pins[] = { +static const struct snd_soc_jack_pin card_jack_pins[] = { { .pin = "Headphone Jack", .mask = SND_JACK_HEADPHONE,
On Wed, 03 Apr 2024 11:31:35 +0200, Amadeusz Sławiński wrote:
Use devm_kstrdup_const in few places to possibly save a bit of memory. Mark some of the structs as const, as they are not modified and used as is.
Amadeusz Sławiński (10): ASoC: Intel: avs: hdaudio: Use devm_kstrdup_const ASoC: Intel: avs: Use devm_kstrdup_const ASoC: Intel: avs: hdaudio: Constify probing_link ASoC: Intel: avs: es8336: Constify card_headset_pins ASoC: Intel: avs: nau8825: Constify card_headset_pins ASoC: Intel: avs: rt274: Constify card_headset_pins ASoC: Intel: avs: rt286: Constify card_headset_pins ASoC: Intel: avs: rt298: Constify card_headset_pins ASoC: Intel: avs: rt5663: Constify card_headset_pins ASoC: Intel: avs: rt5682: Constify card_headset_pins
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/10] ASoC: Intel: avs: hdaudio: Use devm_kstrdup_const commit: 27aa58180473f81990f35238dc8aec40d34c778d [02/10] ASoC: Intel: avs: Use devm_kstrdup_const commit: 68a71af3aee2b776a0030e1393864c9501997cbb [03/10] ASoC: Intel: avs: hdaudio: Constify probing_link commit: a3c95efc432ddd18882cfab420cbea14937fb950 [04/10] ASoC: Intel: avs: es8336: Constify card_headset_pins commit: 2dbe7c809841e645a6b9d6d51801d3c594739d93 [05/10] ASoC: Intel: avs: nau8825: Constify card_headset_pins commit: bf400f16a03788ccdb1de1d9bfe9458082f24ef7 [06/10] ASoC: Intel: avs: rt274: Constify card_headset_pins commit: 130c953a75cc62dd5c73c295bae14197dce46b85 [07/10] ASoC: Intel: avs: rt286: Constify card_headset_pins commit: 682bedc8b0bae52fc5fc95cb3dba6e3d590da653 [08/10] ASoC: Intel: avs: rt298: Constify card_headset_pins commit: 33a886eee711298e799f1f52432e2f5e234cd015 [09/10] ASoC: Intel: avs: rt5663: Constify card_headset_pins commit: a055674868fa9d36f290dba906a76dd45801a37e [10/10] ASoC: Intel: avs: rt5682: Constify card_headset_pins commit: 5faf65b5d1e36ec0a1eb3ba8ba2a8b7a779575ce
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
participants (2)
-
Amadeusz Sławiński
-
Mark Brown