ASoC: Use named initializers for platform_device_id arrays
Subsystems (13)
cover ASoC: Use named initializers for platform_device_id arrays
Hello,
this series targets to use named initializers for platform_device_id arrays. In general these are better readable for humans and more robust to changes in the respective struct definition.
This robustness is needed as I want to do
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -610,4 +610,7 @@ struct dmi_system_id {
struct platform_device_id {
char name[PLATFORM_NAME_SIZE];
- kernel_ulong_t driver_data;
+ union {
+ kernel_ulong_t driver_data;
+ const void *driver_data_ptr;
+ };
};which allows dropping several casts and eases porting CHERI to mainline linux. When adapting e.g. sound/soc/amd/acp/acp-legacy-mach.c to that and make use of driver_data_ptr, the added const makes it obvious that acp_asoc_probe() modifies the structs linked in the id_table resulting in issues if more than one device is probed using the same platform id. sound/soc/amd/acp/acp-sof-mach.c has the same issue.
If you consider the last patch mostly churn, just drop it.
Best regards
Uwe
Uwe Kleine-König (The Capable Hub) (4):
ASoC: codecs: mt6357: Drop unused assignment of platform_device_id
driver data
ASoC: renesas: fsi: Simplify driver_data handling
ASoC: Use named initializers for platform_device_id arrays
ASOC: Unify code style for platform_device_id arrays
sound/soc/amd/acp/acp-sdw-legacy-mach.c | 4 ++-- sound/soc/amd/acp/acp-sdw-sof-mach.c | 4 ++-- sound/soc/amd/acp/acp-sof-mach.c | 14 +++++++------- sound/soc/codecs/adau7118-hw.c | 2 +- sound/soc/codecs/bt-sco.c | 10 +++------- sound/soc/codecs/cs40l50-codec.c | 4 ++-- sound/soc/codecs/cs42l43.c | 4 ++-- sound/soc/codecs/mt6357.c | 4 ++-- sound/soc/codecs/wcd934x.c | 6 ++---- sound/soc/fsl/imx-pcm-rpmsg.c | 6 +++--- sound/soc/intel/avs/boards/da7219.c | 6 ++---- sound/soc/intel/avs/boards/dmic.c | 6 ++---- sound/soc/intel/avs/boards/es8336.c | 6 ++---- sound/soc/intel/avs/boards/hdaudio.c | 6 ++---- sound/soc/intel/avs/boards/i2s_test.c | 6 ++---- sound/soc/intel/avs/boards/max98357a.c | 6 ++---- sound/soc/intel/avs/boards/max98373.c | 6 ++---- sound/soc/intel/avs/boards/max98927.c | 6 ++---- sound/soc/intel/avs/boards/nau8825.c | 6 ++---- sound/soc/intel/avs/boards/pcm3168a.c | 6 ++---- sound/soc/intel/boards/sof_sdw.c | 4 ++-- sound/soc/renesas/fsi.c | 8 +++----- 22 files changed, 51 insertions(+), 79 deletions(-)
base-commit: e7d700e14934e68f86338c5610cf2ae76798b663
Signature · 1 line
2.47.3
PATCH 1/4 ASoC: codecs: mt6357: Drop unused assignment of platform_device_id driver data
The driver explicitly set the .driver_data member of struct platform_device_id to zero without relying on that value. Drop this unused assignments.
While touching this array unify spacing, use a named initializer for .name and drop a trailing comma after the list terminator.
--- sound/soc/codecs/mt6357.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/mt6357.c +2 -2
@@ -1834,8 +1834,8 @@ static int mt6357_platform_driver_probe(struct platform_device *pdev) }static const struct platform_device_id mt6357_platform_ids[] = { - {"mt6357-sound" ,0 }, - {/* sentinel */ }, + { .name ="mt6357-sound" }, + {/* sentinel */ } };MODULE_DEVICE_TABLE (platform, mt6357_platform_ids);
Signature · 1 line
2.47.3
PATCH 2/4 ASoC: renesas: fsi: Simplify driver_data handling
In reply to Uwe Kleine-König (The Capable Hub)Instead of hiding the fsi_core struct for the only supported (non-of) device behind an abstraction for multi-device support, hardcode the used pointer which gets rid of (open-coded) platform_get_device_id() and two casts.
--- sound/soc/renesas/fsi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
sound/soc/renesas/fsi.c +3 -5
@@ -1905,8 +1905,8 @@ static const struct of_device_id fsi_of_match[] = {MODULE_DEVICE_TABLE (of, fsi_of_match);static const struct platform_device_id fsi_id_table[] = { - {"sh_fsi" , (kernel_ulong_t)&fsi1_core }, - {}, + { .name ="sh_fsi" }, + { } };MODULE_DEVICE_TABLE (platform, fsi_id_table);
@@ -1929,9 +1929,7 @@ static int fsi_probe(struct platform_device *pdev)fsi_of_parse ("fsia" , np, &info.port_a, &pdev->dev);fsi_of_parse ("fsib" , np, &info.port_b, &pdev->dev); }else { -const struct platform_device_id *id_entry = pdev->id_entry; -if (id_entry) - core = (struct fsi_core *)id_entry->driver_data; + core = &fsi1_core;if (pdev->dev.platform_data)memcpy (&info, pdev->dev.platform_data,sizeof (info));
Signature · 1 line
2.47.3
Re: [PATCH v1 2/4] ASoC: renesas: fsi: Simplify driver_data handling
Hi
Quoted 7 lines
Instead of hiding the
fsi_corestruct for the only supported (non-of) device behind an abstraction for multi-device support, hardcode the used pointer which gets rid of (open-coded)platform_get_device_id()and two casts.Signed-off-by Uwe Kleine-König (The Capable Hub) <[email protected]>---
Thank you for your help !!
Best regards
---
Kuninori Morimoto
Re: [PATCH v1 2/4] ASoC: renesas: fsi: Simplify driver_data handling
In reply to Uwe Kleine-König (The Capable Hub)Quoted 26 lines · Uwe Kleine-König (The Capable Hub)
Instead of hiding the
fsi_corestruct for the only supported (non-of) device behind an abstraction for multi-device support, hardcode the used pointer which gets rid of (open-coded)platform_get_device_id()and two casts.Signed-off-by Uwe Kleine-König (The Capable Hub) <[email protected]>--- sound/soc/renesas/fsi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)sound/soc/renesas/fsi.c +2
-2@@ -1905,8 +1905,8 @@ static const struct of_device_id fsi_of_match[] = {MODULE_DEVICE_TABLE (of, fsi_of_match);static const struct platform_device_id fsi_id_table[] = { - {"sh_fsi" , (kernel_ulong_t)&fsi1_core }, - {}, + { .name ="sh_fsi" }, + { } };MODULE_DEVICE_TABLE (platform, fsi_id_table);
sound/soc/renesas/fsi.c static int fsi_probe(struct platform_device *pdev) · line 1935
Quoted 10 lines
sound/soc/renesas/fsi.c +1
-3@@ -1929,9 +1929,7 @@ static int fsi_probe(struct platform_device *pdev)fsi_of_parse ("fsia" , np, &info.port_a, &pdev->dev);fsi_of_parse ("fsib" , np, &info.port_b, &pdev->dev); }else { -const struct platform_device_id *id_entry = pdev->id_entry; -if (id_entry) - core = (struct fsi_core *)id_entry->driver_data; + core = &fsi1_core;if (pdev->dev.platform_data)memcpy (&info, pdev->dev.platform_data,sizeof (info));
With commit 38d3273075d6 ("ASoC: renesas: fsi: remove platform data style support") this patch doesn't apply any more. I will wait till after the upcoming merge window and then respin this series. (But if you take the other patches until then, I won't be angry :-)
Best regards
Uwe
PATCH 3/4 ASoC: Use named initializers for platform_device_id arrays
In reply to Uwe Kleine-König (The Capable Hub)Named initializers are better readable and more robust to changes of the struct definition. This robustness is relevant for a planned change to struct platform_device_id replacing .driver_data by an anonymous union.
While touching these arrays unify spacing and usage of commas.
--- sound/soc/amd/acp/acp-sdw-legacy-mach.c | 4 ++-- sound/soc/amd/acp/acp-sdw-sof-mach.c | 4 ++-- sound/soc/codecs/cs40l50-codec.c | 4 ++-- sound/soc/codecs/cs42l43.c | 4 ++-- sound/soc/intel/boards/sof_sdw.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-)
sound/soc/amd/acp/acp-sdw-legacy-mach.c +2 -2
@@ -579,8 +579,8 @@ static void mc_remove(struct platform_device *pdev) }static const struct platform_device_id mc_id_table[] = { - {"amd_sdw" , }, - {} + { .name ="amd_sdw" }, + { } };MODULE_DEVICE_TABLE (platform, mc_id_table);
sound/soc/amd/acp/acp-sdw-sof-mach.c +2 -2
@@ -437,8 +437,8 @@ static void mc_remove(struct platform_device *pdev) }static const struct platform_device_id mc_id_table[] = { - {"amd_sof_sdw" , }, - {} + { .name ="amd_sof_sdw" }, + { } };MODULE_DEVICE_TABLE (platform, mc_id_table);
sound/soc/codecs/cs40l50-codec.c +2 -2
@@ -288,8 +288,8 @@ static int cs40l50_codec_driver_probe(struct platform_device *pdev) }static const struct platform_device_id cs40l50_id[] = { - {"cs40l50-codec" , }, - {} + { .name ="cs40l50-codec" }, + { } };MODULE_DEVICE_TABLE (platform, cs40l50_id);
sound/soc/codecs/cs42l43.c +2 -2
@@ -2942,8 +2942,8 @@ static const struct dev_pm_ops cs42l43_codec_pm_ops = { };static const struct platform_device_id cs42l43_codec_id_table[] = { - {"cs42l43-codec" , }, - {} + { .name ="cs42l43-codec" }, + { } };MODULE_DEVICE_TABLE (platform, cs42l43_codec_id_table);
sound/soc/intel/boards/sof_sdw.c +2 -2
@@ -1539,8 +1539,8 @@ static void mc_remove(struct platform_device *pdev) }static const struct platform_device_id mc_id_table[] = { - {"sof_sdw" , }, - {} + { .name ="sof_sdw" }, + { } };MODULE_DEVICE_TABLE (platform, mc_id_table);
Signature · 1 line
2.47.3
Mukunda,Vijendar
maintainerQuoted 7 lines · Uwe Kleine-König (The Capable Hub)
[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
Named initializers are better readable and more robust to changes of the struct definition. This robustness is relevant for a planned change to struct
platform_device_idreplacing .driver_data by an anonymous union.While touching these arrays unify spacing and usage of commas.
Split AMD patches and use ASoC: amd: acp: as prefix in commit title.
Quoted 88 lines
Signed-off-by Uwe Kleine-König (The Capable Hub) <[email protected]>--- sound/soc/amd/acp/acp-sdw-legacy-mach.c | 4 ++-- sound/soc/amd/acp/acp-sdw-sof-mach.c | 4 ++-- sound/soc/codecs/cs40l50-codec.c | 4 ++-- sound/soc/codecs/cs42l43.c | 4 ++-- sound/soc/intel/boards/sof_sdw.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-)sound/soc/amd/acp/acp-sdw-legacy-mach.c +2
-2@@ -579,8 +579,8 @@ static void mc_remove(struct platform_device *pdev) }static const struct platform_device_id mc_id_table[] = { - {"amd_sdw" , }, - {} + { .name ="amd_sdw" }, + { } };MODULE_DEVICE_TABLE (platform, mc_id_table);sound/soc/amd/acp/acp-sdw-sof-mach.c +2
-2@@ -437,8 +437,8 @@ static void mc_remove(struct platform_device *pdev) }static const struct platform_device_id mc_id_table[] = { - {"amd_sof_sdw" , }, - {} + { .name ="amd_sof_sdw" }, + { } };MODULE_DEVICE_TABLE (platform, mc_id_table);sound/soc/codecs/cs40l50-codec.c +2
-2@@ -288,8 +288,8 @@ static int cs40l50_codec_driver_probe(struct platform_device *pdev) }static const struct platform_device_id cs40l50_id[] = { - {"cs40l50-codec" , }, - {} + { .name ="cs40l50-codec" }, + { } };MODULE_DEVICE_TABLE (platform, cs40l50_id);sound/soc/codecs/cs42l43.c +2
-2@@ -2942,8 +2942,8 @@ static const struct dev_pm_ops cs42l43_codec_pm_ops = { };static const struct platform_device_id cs42l43_codec_id_table[] = { - {"cs42l43-codec" , }, - {} + { .name ="cs42l43-codec" }, + { } };MODULE_DEVICE_TABLE (platform, cs42l43_codec_id_table);sound/soc/intel/boards/sof_sdw.c +2
-3@@ -1539,8 +1539,8 @@ static void mc_remove(struct platform_device *pdev) }static const struct platform_device_id mc_id_table[] = { - {"sof_sdw" , }, - {} + { .name ="sof_sdw" }, + { } };MODULE_DEVICE_TABLE (platform, mc_id_table); --2.47.3
PATCH 4/4 ASOC: Unify code style for platform_device_id arrays
In reply to Uwe Kleine-König (The Capable Hub) - Add a trailing comma for initializers unless the closing brace is on the same line and for the list terminator;
- Use a single space in the list terminator;
- Use compact one-line style for small entries;
- s/\t=/ =/ were the tab is only one char wide anyhow;
--- sound/soc/amd/acp/acp-sof-mach.c | 14 +++++++------- sound/soc/codecs/adau7118-hw.c | 2 +- sound/soc/codecs/bt-sco.c | 10 +++------- sound/soc/codecs/wcd934x.c | 6 ++---- sound/soc/fsl/imx-pcm-rpmsg.c | 6 +++--- sound/soc/intel/avs/boards/da7219.c | 6 ++---- sound/soc/intel/avs/boards/dmic.c | 6 ++---- sound/soc/intel/avs/boards/es8336.c | 6 ++---- sound/soc/intel/avs/boards/hdaudio.c | 6 ++---- sound/soc/intel/avs/boards/i2s_test.c | 6 ++---- sound/soc/intel/avs/boards/max98357a.c | 6 ++---- sound/soc/intel/avs/boards/max98373.c | 6 ++---- sound/soc/intel/avs/boards/max98927.c | 6 ++---- sound/soc/intel/avs/boards/nau8825.c | 6 ++---- sound/soc/intel/avs/boards/pcm3168a.c | 6 ++---- 15 files changed, 36 insertions(+), 62 deletions(-)
sound/soc/amd/acp/acp-sof-mach.c +7 -7
@@ -128,31 +128,31 @@ static int acp_sof_probe(struct platform_device *pdev)static const struct platform_device_id board_ids[] = { { .name ="rt5682-rt1019" , - .driver_data = (kernel_ulong_t)&sof_rt5682_rt1019_data + .driver_data = (kernel_ulong_t)&sof_rt5682_rt1019_data, }, { .name ="rt5682-max" , - .driver_data = (kernel_ulong_t)&sof_rt5682_max_data + .driver_data = (kernel_ulong_t)&sof_rt5682_max_data, }, { .name ="rt5682s-max" , - .driver_data = (kernel_ulong_t)&sof_rt5682s_max_data + .driver_data = (kernel_ulong_t)&sof_rt5682s_max_data, }, { .name ="rt5682s-rt1019" , - .driver_data = (kernel_ulong_t)&sof_rt5682s_rt1019_data + .driver_data = (kernel_ulong_t)&sof_rt5682s_rt1019_data, }, { .name ="nau8825-max" , - .driver_data = (kernel_ulong_t)&sof_nau8825_data + .driver_data = (kernel_ulong_t)&sof_nau8825_data, }, { .name ="rt5682s-hs-rt1019" , - .driver_data = (kernel_ulong_t)&sof_rt5682s_hs_rt1019_data + .driver_data = (kernel_ulong_t)&sof_rt5682s_hs_rt1019_data, }, { .name ="nau8821-max" , - .driver_data = (kernel_ulong_t)&sof_nau8821_max98388_data + .driver_data = (kernel_ulong_t)&sof_nau8821_max98388_data, }, { } };
sound/soc/codecs/adau7118-hw.c +1 -1
@@ -23,7 +23,7 @@ static const struct of_device_id adau7118_of_match[] = {MODULE_DEVICE_TABLE (of, adau7118_of_match);static const struct platform_device_id adau7118_id[] = { - { .name ="adau7118" }, + { .name ="adau7118" }, { } };MODULE_DEVICE_TABLE (platform, adau7118_id);
sound/soc/codecs/bt-sco.c +3 -7
@@ -79,13 +79,9 @@ static int bt_sco_probe(struct platform_device *pdev) }static const struct platform_device_id bt_sco_driver_ids[] = { - { - .name ="dfbmcs320" , - }, - { - .name ="bt-sco" , - }, - {}, + { .name ="dfbmcs320" }, + { .name ="bt-sco" }, + { } };MODULE_DEVICE_TABLE (platform, bt_sco_driver_ids);
sound/soc/codecs/wcd934x.c +2 -4
@@ -5899,10 +5899,8 @@ static int wcd934x_codec_probe(struct platform_device *pdev) }static const struct platform_device_id wcd934x_driver_id[] = { - { - .name ="wcd934x-codec" , - }, - {}, + { .name ="wcd934x-codec" }, + { } };MODULE_DEVICE_TABLE (platform, wcd934x_driver_id);
sound/soc/fsl/imx-pcm-rpmsg.c +3 -3
@@ -829,9 +829,9 @@ static const struct dev_pm_ops imx_rpmsg_pcm_pm_ops = { };static const struct platform_device_id imx_rpmsg_pcm_id_table[] = { - { .name ="rpmsg-audio-channel" }, - { .name ="rpmsg-micfil-channel" }, - { }, + { .name ="rpmsg-audio-channel" }, + { .name ="rpmsg-micfil-channel" }, + { } };MODULE_DEVICE_TABLE (platform, imx_rpmsg_pcm_id_table);
sound/soc/intel/avs/boards/da7219.c +2 -4
@@ -259,10 +259,8 @@ static int avs_da7219_probe(struct platform_device *pdev) }static const struct platform_device_id avs_da7219_driver_ids[] = { - { - .name ="avs_da7219" , - }, - {}, + { .name ="avs_da7219" }, + { } };MODULE_DEVICE_TABLE (platform, avs_da7219_driver_ids);
sound/soc/intel/avs/boards/dmic.c +2 -4
@@ -104,10 +104,8 @@ static int avs_dmic_probe(struct platform_device *pdev) }static const struct platform_device_id avs_dmic_driver_ids[] = { - { - .name ="avs_dmic" , - }, - {}, + { .name ="avs_dmic" }, + { } };MODULE_DEVICE_TABLE (platform, avs_dmic_driver_ids);
sound/soc/intel/avs/boards/es8336.c +2 -4
@@ -309,10 +309,8 @@ static int avs_es8336_probe(struct platform_device *pdev) }static const struct platform_device_id avs_es8336_driver_ids[] = { - { - .name ="avs_es8336" , - }, - {}, + { .name ="avs_es8336" }, + { } };MODULE_DEVICE_TABLE (platform, avs_es8336_driver_ids);
sound/soc/intel/avs/boards/hdaudio.c +2 -4
@@ -231,10 +231,8 @@ static int avs_hdaudio_probe(struct platform_device *pdev) }static const struct platform_device_id avs_hdaudio_driver_ids[] = { - { - .name ="avs_hdaudio" , - }, - {}, + { .name ="avs_hdaudio" }, + { } };MODULE_DEVICE_TABLE (platform, avs_hdaudio_driver_ids);
sound/soc/intel/avs/boards/i2s_test.c +2 -4
@@ -107,10 +107,8 @@ static int avs_i2s_test_probe(struct platform_device *pdev) }static const struct platform_device_id avs_i2s_test_driver_ids[] = { - { - .name ="avs_i2s_test" , - }, - {}, + { .name ="avs_i2s_test" }, + { } };MODULE_DEVICE_TABLE (platform, avs_i2s_test_driver_ids);
sound/soc/intel/avs/boards/max98357a.c +2 -4
@@ -136,10 +136,8 @@ static int avs_max98357a_probe(struct platform_device *pdev) }static const struct platform_device_id avs_max98357a_driver_ids[] = { - { - .name ="avs_max98357a" , - }, - {}, + { .name ="avs_max98357a" }, + { } };MODULE_DEVICE_TABLE (platform, avs_max98357a_driver_ids);
sound/soc/intel/avs/boards/max98373.c +2 -4
@@ -191,10 +191,8 @@ static int avs_max98373_probe(struct platform_device *pdev) }static const struct platform_device_id avs_max98373_driver_ids[] = { - { - .name ="avs_max98373" , - }, - {}, + { .name ="avs_max98373" }, + { } };MODULE_DEVICE_TABLE (platform, avs_max98373_driver_ids);
sound/soc/intel/avs/boards/max98927.c +2 -4
@@ -188,10 +188,8 @@ static int avs_max98927_probe(struct platform_device *pdev) }static const struct platform_device_id avs_max98927_driver_ids[] = { - { - .name ="avs_max98927" , - }, - {}, + { .name ="avs_max98927" }, + { } };MODULE_DEVICE_TABLE (platform, avs_max98927_driver_ids);
sound/soc/intel/avs/boards/nau8825.c +2 -4
@@ -293,10 +293,8 @@ static int avs_nau8825_probe(struct platform_device *pdev) }static const struct platform_device_id avs_nau8825_driver_ids[] = { - { - .name ="avs_nau8825" , - }, - {}, + { .name ="avs_nau8825" }, + { } };MODULE_DEVICE_TABLE (platform, avs_nau8825_driver_ids);
sound/soc/intel/avs/boards/pcm3168a.c +2 -4
@@ -132,10 +132,8 @@ static int avs_pcm3168a_probe(struct platform_device *pdev) }static const struct platform_device_id avs_pcm3168a_driver_ids[] = { - { - .name ="avs_pcm3168a" , - }, - {}, + { .name ="avs_pcm3168a" }, + { } };MODULE_DEVICE_TABLE (platform, avs_pcm3168a_driver_ids);
Signature · 1 line
2.47.3
Re: [PATCH v1 4/4] ASOC: Unify code style for platform_device_id arrays
Quoted 13 lines · Uwe Kleine-König (The Capable Hub)
- Add a trailing comma for initializers unless the closing brace is on
the same line and for the list terminator;- Use a single space in the list terminator;
- Use compact one-line style for small entries;
- s/\t=/ =/ were the tab is only one char wide anyhow;Signed-off-by Uwe Kleine-König (The Capable Hub) <[email protected]>--- sound/soc/amd/acp/acp-sof-mach.c | 14 +++++++------- sound/soc/codecs/adau7118-hw.c | 2 +- sound/soc/codecs/bt-sco.c | 10 +++------- sound/soc/codecs/wcd934x.c | 6 ++---- sound/soc/fsl/imx-pcm-rpmsg.c | 6 +++---
...
Quoted 10 lines
sound/soc/intel/avs/boards/da7219.c | 6 ++---- sound/soc/intel/avs/boards/dmic.c | 6 ++---- sound/soc/intel/avs/boards/es8336.c | 6 ++---- sound/soc/intel/avs/boards/hdaudio.c | 6 ++---- sound/soc/intel/avs/boards/i2s_test.c | 6 ++---- sound/soc/intel/avs/boards/max98357a.c | 6 ++---- sound/soc/intel/avs/boards/max98373.c | 6 ++---- sound/soc/intel/avs/boards/max98927.c | 6 ++---- sound/soc/intel/avs/boards/nau8825.c | 6 ++---- sound/soc/intel/avs/boards/pcm3168a.c | 6 ++----
Please separate all the avs-driver changes into a separate patch with the following prefix for the title: "ASoC: Intel: avs:".
The code itself looks good. Provided the separation is done, feel free to add my tag: