ASoC: rt*: Constify static structs
Subsystems (3)
cover ASoC: rt*: Constify static structs
Constify a number of static structs that are never modified in RealTek codecs. The most important patches are the first two, which constifies snd_soc_dai_ops and sdw_slave_ops, both which contain function pointers. The other two patches are for good measure, since I was already touching the code there.
When doing this, I discovered sound/soc/codecs/rt1016.c is not in a Makefile, so there is not really any way to build it (I added locally to the Makefile to compile-test my changes). Is this expected or an oversight?
Rikard Falkeborn (4):
ASoC: rt*: Constify static struct sdw_slave_ops
ASoC: rt*: Constify static struct snd_soc_dai_ops
ASoC: rt*: Constify static struct acpi_device_id
ASoc: rt5631: Constify static struct coeff_clk_div
sound/soc/codecs/rt1011.c | 2 +- sound/soc/codecs/rt1015.c | 4 ++-- sound/soc/codecs/rt1016.c | 4 ++-- sound/soc/codecs/rt1305.c | 2 +- sound/soc/codecs/rt1308-sdw.c | 2 +- sound/soc/codecs/rt1308.c | 2 +- sound/soc/codecs/rt5631.c | 2 +- sound/soc/codecs/rt5682-sdw.c | 4 ++-- sound/soc/codecs/rt700-sdw.c | 2 +- sound/soc/codecs/rt700.c | 2 +- sound/soc/codecs/rt711-sdw.c | 2 +- sound/soc/codecs/rt711.c | 2 +- sound/soc/codecs/rt715-sdw.c | 2 +- sound/soc/codecs/rt715.c | 2 +- 14 files changed, 17 insertions(+), 17 deletions(-)
Signature · 1 line
2.30.1
PATCH 1/4 ASoC: rt*: Constify static struct sdw_slave_ops
The only usage of these is to assign their address to the ops field in the sdw_driver struct, which is a pointer to const. Make them const to allow the compiler to put them in read-only memory.
--- sound/soc/codecs/rt1308-sdw.c | 2 +- sound/soc/codecs/rt5682-sdw.c | 2 +- sound/soc/codecs/rt700-sdw.c | 2 +- sound/soc/codecs/rt711-sdw.c | 2 +- sound/soc/codecs/rt715-sdw.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
sound/soc/codecs/rt1308-sdw.c +1 -1
@@ -594,7 +594,7 @@ static int rt1308_sdw_pcm_hw_free(struct snd_pcm_substream *substream,* slave_ops: callbacks for get_clock_stop_mode, clock_stop and * port_prep are not defined for now */ -static struct sdw_slave_ops rt1308_slave_ops = { +static const struct sdw_slave_ops rt1308_slave_ops = { .read_prop = rt1308_read_prop, .interrupt_callback = rt1308_interrupt_callback, .update_status = rt1308_update_status,
sound/soc/codecs/rt5682-sdw.c +1 -1
@@ -683,7 +683,7 @@ static int rt5682_interrupt_callback(struct sdw_slave *slave,return 0 ; } -static struct sdw_slave_ops rt5682_slave_ops = { +static const struct sdw_slave_ops rt5682_slave_ops = { .read_prop = rt5682_read_prop, .interrupt_callback = rt5682_interrupt_callback, .update_status = rt5682_update_status,
sound/soc/codecs/rt700-sdw.c +1 -1
@@ -430,7 +430,7 @@ static int rt700_interrupt_callback(struct sdw_slave *slave,* slave_ops: callbacks for get_clock_stop_mode, clock_stop and * port_prep are not defined for now */ -static struct sdw_slave_ops rt700_slave_ops = { +static const struct sdw_slave_ops rt700_slave_ops = { .read_prop = rt700_read_prop, .interrupt_callback = rt700_interrupt_callback, .update_status = rt700_update_status,
sound/soc/codecs/rt711-sdw.c +1 -1
@@ -431,7 +431,7 @@ static int rt711_interrupt_callback(struct sdw_slave *slave,return 0 ; } -static struct sdw_slave_ops rt711_slave_ops = { +static const struct sdw_slave_ops rt711_slave_ops = { .read_prop = rt711_read_prop, .interrupt_callback = rt711_interrupt_callback, .update_status = rt711_update_status,
sound/soc/codecs/rt715-sdw.c +1 -1
@@ -488,7 +488,7 @@ static int rt715_bus_config(struct sdw_slave *slave,return 0 ; } -static struct sdw_slave_ops rt715_slave_ops = { +static const struct sdw_slave_ops rt715_slave_ops = { .read_prop = rt715_read_prop, .update_status = rt715_update_status, .bus_config = rt715_bus_config,
Signature · 1 line
2.30.1
PATCH 2/4 ASoC: rt*: Constify static struct snd_soc_dai_ops
In reply to Rikard FalkebornThe only usage of them is to assign their address to the ops field in the snd_soc_dai_driver struct, which is a pointer to const. Make them const to allow the compiler to put them in read-only memory.
--- sound/soc/codecs/rt1015.c | 2 +- sound/soc/codecs/rt1016.c | 2 +- sound/soc/codecs/rt5682-sdw.c | 2 +- sound/soc/codecs/rt700.c | 2 +- sound/soc/codecs/rt711.c | 2 +- sound/soc/codecs/rt715.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)
sound/soc/codecs/rt1015.c +1 -1
@@ -1028,7 +1028,7 @@ static void rt1015_remove(struct snd_soc_component *component)#define RT1015_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) -static struct snd_soc_dai_ops rt1015_aif_dai_ops = { +static const struct snd_soc_dai_ops rt1015_aif_dai_ops = { .hw_params = rt1015_hw_params, .set_fmt = rt1015_set_dai_fmt, .set_tdm_slot = rt1015_set_tdm_slot,
sound/soc/codecs/rt1016.c +1 -1
@@ -534,7 +534,7 @@ static void rt1016_remove(struct snd_soc_component *component)#define RT1016_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) -static struct snd_soc_dai_ops rt1016_aif_dai_ops = { +static const struct snd_soc_dai_ops rt1016_aif_dai_ops = { .hw_params = rt1016_hw_params, .set_fmt = rt1016_set_dai_fmt, };
sound/soc/codecs/rt5682-sdw.c +1 -1
@@ -269,7 +269,7 @@ static int rt5682_sdw_hw_free(struct snd_pcm_substream *substream,return 0 ; } -static struct snd_soc_dai_ops rt5682_sdw_ops = { +static const struct snd_soc_dai_ops rt5682_sdw_ops = { .hw_params = rt5682_sdw_hw_params, .hw_free = rt5682_sdw_hw_free, .set_sdw_stream = rt5682_set_sdw_stream,
sound/soc/codecs/rt700.c +1 -1
@@ -1002,7 +1002,7 @@ static int rt700_pcm_hw_free(struct snd_pcm_substream *substream,#define RT700_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) -static struct snd_soc_dai_ops rt700_ops = { +static const struct snd_soc_dai_ops rt700_ops = { .hw_params = rt700_pcm_hw_params, .hw_free = rt700_pcm_hw_free, .set_sdw_stream = rt700_set_sdw_stream,
sound/soc/codecs/rt711.c +1 -1
@@ -1048,7 +1048,7 @@ static int rt711_pcm_hw_free(struct snd_pcm_substream *substream,#define RT711_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) -static struct snd_soc_dai_ops rt711_ops = { +static const struct snd_soc_dai_ops rt711_ops = { .hw_params = rt711_pcm_hw_params, .hw_free = rt711_pcm_hw_free, .set_sdw_stream = rt711_set_sdw_stream,
sound/soc/codecs/rt715.c +1 -1
@@ -683,7 +683,7 @@ static int rt715_pcm_hw_free(struct snd_pcm_substream *substream,#define RT715_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) -static struct snd_soc_dai_ops rt715_ops = { +static const struct snd_soc_dai_ops rt715_ops = { .hw_params = rt715_pcm_hw_params, .hw_free = rt715_pcm_hw_free, .set_sdw_stream = rt715_set_sdw_stream,
Signature · 1 line
2.30.1
PATCH 3/4 ASoC: rt*: Constify static struct acpi_device_id
In reply to Rikard FalkebornThese are never modified, so make them const to allow the compiler to put them in read-only memory.
--- sound/soc/codecs/rt1011.c | 2 +- sound/soc/codecs/rt1015.c | 2 +- sound/soc/codecs/rt1016.c | 2 +- sound/soc/codecs/rt1305.c | 2 +- sound/soc/codecs/rt1308.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
sound/soc/codecs/rt1011.c +1 -1
@@ -2151,7 +2151,7 @@ MODULE_DEVICE_TABLE(of, rt1011_of_match);#endif #ifdef CONFIG_ACPI -static struct acpi_device_id rt1011_acpi_match[] = { +static const struct acpi_device_id rt1011_acpi_match[] = { {"10EC1011" ,0 ,}, {}, };
sound/soc/codecs/rt1015.c +1 -1
@@ -1121,7 +1121,7 @@ MODULE_DEVICE_TABLE(of, rt1015_of_match);#endif #ifdef CONFIG_ACPI -static struct acpi_device_id rt1015_acpi_match[] = { +static const struct acpi_device_id rt1015_acpi_match[] = { {"10EC1015" ,0 ,}, {}, };
sound/soc/codecs/rt1016.c +1 -1
@@ -623,7 +623,7 @@ MODULE_DEVICE_TABLE(of, rt1016_of_match);#endif #ifdef CONFIG_ACPI -static struct acpi_device_id rt1016_acpi_match[] = { +static const struct acpi_device_id rt1016_acpi_match[] = { {"10EC1016" ,0 ,}, {}, };
sound/soc/codecs/rt1305.c +1 -1
@@ -975,7 +975,7 @@ MODULE_DEVICE_TABLE(of, rt1305_of_match);#endif #ifdef CONFIG_ACPI -static struct acpi_device_id rt1305_acpi_match[] = { +static const struct acpi_device_id rt1305_acpi_match[] = { {"10EC1305" ,0 ,}, {"10EC1306" ,0 ,}, {},
sound/soc/codecs/rt1308.c +1 -1
@@ -790,7 +790,7 @@ MODULE_DEVICE_TABLE(of, rt1308_of_match);#endif #ifdef CONFIG_ACPI -static struct acpi_device_id rt1308_acpi_match[] = { +static const struct acpi_device_id rt1308_acpi_match[] = { {"10EC1308" ,0 , }, { }, };
Signature · 1 line
2.30.1
PATCH 4/4 ASoc: rt5631: Constify static struct coeff_clk_div
In reply to Rikard Falkeborncoeff_div is only read from, so make it const to show the intent.
--- sound/soc/codecs/rt5631.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/rt5631.c +1 -1
@@ -1283,7 +1283,7 @@ static const struct pll_div codec_slave_pll_div[] = { {3072000, 12288000, 0x0a90}, }; -static struct coeff_clk_div coeff_div[] = { +static const struct coeff_clk_div coeff_div[] = {/* sysclk is 256fs */ {2048000 ,8000 *32 ,8000 ,0x1000 }, {2048000, 8000 * 64, 8000, 0x0000},
Signature · 1 line
2.30.1
Mark Brown
maintainerQuoted 11 lines · Rikard Falkeborn
Constify a number of static structs that are never modified in RealTek codecs. The most important patches are the first two, which constifies
snd_soc_dai_opsandsdw_slave_ops, both which contain function pointers. The other two patches are for good measure, since I was already touching the code there.When doing this, I discovered
sound/soc/codecs/rt1016.cis not in aMakefile, so there is not really any way to build it (I added locally to theMakefileto compile-test my changes). Is this expected or an oversight?[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/4] ASoC: rt*: Constify static struct sdw_slave_ops
commit: 3ebb1b951880d3152547ac4018bfcce0fd7810bd
[2/4] ASoC: rt*: Constify static struct snd_soc_dai_ops
commit: 84732dd4ff3ad28cc65eedfa3061fe3808e8469b
[3/4] ASoC: rt*: Constify static struct acpi_device_id
commit: c85ca92c716bd04981ebcd2c67cd03f96748859e
[4/4] ASoc: rt5631: Constify static struct coeff_clk_div
commit: 39f9eb61307061eed197eae651ef56cb3544f9b2All 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