[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240628-b4-qcom-audio-lpass-codec-cleanups-v2-2-e9741143e485@linaro.org>
Date: Fri, 28 Jun 2024 12:10:56 +0200
From: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
To: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
Banajit Goswami <bgoswami@...cinc.com>, Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>, Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>
Cc: alsa-devel@...a-project.org, linux-arm-msm@...r.kernel.org,
linux-sound@...r.kernel.org, linux-kernel@...r.kernel.org,
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
Subject: [PATCH v2 2/5] ASoC: codecs: lpass-rx-macro: Keep static
regmap_config as const
The driver has static 'struct regmap_config', which is then customized
depending on device version. This works fine, because there should not
be two devices in a system simultaneously and even less likely that such
two devices would have different versions, thus different regmap config.
However code is cleaner and more obvious when static data in the driver
is also const - it serves as a template.
Mark the 'struct regmap_config' as const and duplicate it in the probe()
with kmemdup to allow customizing per detected device variant.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
---
Not adding Dmitry's Rb tag, because of major change devm->cleanup.h.
---
sound/soc/codecs/lpass-rx-macro.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index 4cf030760d74..1d2dce1f600c 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -1663,7 +1663,7 @@ static bool rx_is_readable_register(struct device *dev, unsigned int reg)
return rx_is_rw_register(dev, reg);
}
-static struct regmap_config rx_regmap_config = {
+static const struct regmap_config rx_regmap_config = {
.name = "rx_macro",
.reg_bits = 16,
.val_bits = 32, /* 8 but with 32 bit read/write */
@@ -3849,10 +3849,18 @@ static int rx_macro_probe(struct platform_device *pdev)
goto err;
}
- rx_regmap_config.reg_defaults = reg_defaults;
- rx_regmap_config.num_reg_defaults = def_count;
+ struct regmap_config *reg_config __free(kfree) = kmemdup(&rx_regmap_config,
+ sizeof(*reg_config),
+ GFP_KERNEL);
+ if (!reg_config) {
+ ret = -ENOMEM;
+ goto err;
+ }
- rx->regmap = devm_regmap_init_mmio(dev, base, &rx_regmap_config);
+ reg_config->reg_defaults = reg_defaults;
+ reg_config->num_reg_defaults = def_count;
+
+ rx->regmap = devm_regmap_init_mmio(dev, base, reg_config);
if (IS_ERR(rx->regmap)) {
ret = PTR_ERR(rx->regmap);
goto err;
--
2.43.0
Powered by blists - more mailing lists