From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Shenghao Ding <shenghao-ding@ti.com>, Kevin Lu <kevin-lu@ti.com>,
Baojun Xu <baojun.xu@ti.com>, Sen Wang <sen@ti.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/7] ASoC: tlv320aic32x4: move regmap_config into i2c and spi drivers
Date: Sat, 25 Jul 2026 18:05:14 -0700 [thread overview]
Message-ID: <20260726010519.117805-4-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20260726010519.117805-1-dmitry.torokhov@gmail.com>
Move regmap_config definitions to be static const structures in
tlv320aic32x4-i2c.c and tlv320aic32x4-spi.c instead of dynamically
modifying a shared base regmap_config at runtime during probe. Export
aic32x4_regmap_pages so both bus drivers can reference page ranges.
In addition, validate regmap initialization immediately upon creation in
both bus probe routines and remove the redundant error check from core
aic32x4_probe.
Assisted-by: Antigravity:gemini-3.5-flash
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
sound/soc/codecs/tlv320aic32x4-i2c.c | 16 +++++++++++-----
sound/soc/codecs/tlv320aic32x4-spi.c | 20 +++++++++++++-------
sound/soc/codecs/tlv320aic32x4.c | 13 ++-----------
sound/soc/codecs/tlv320aic32x4.h | 2 +-
4 files changed, 27 insertions(+), 24 deletions(-)
diff --git a/sound/soc/codecs/tlv320aic32x4-i2c.c b/sound/soc/codecs/tlv320aic32x4-i2c.c
index 449353d5f088..e031eaaa2f7f 100644
--- a/sound/soc/codecs/tlv320aic32x4-i2c.c
+++ b/sound/soc/codecs/tlv320aic32x4-i2c.c
@@ -16,17 +16,23 @@
#include "tlv320aic32x4.h"
+static const struct regmap_config aic32x4_i2c_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = AIC32X4_REFPOWERUP,
+ .ranges = aic32x4_regmap_pages,
+ .num_ranges = 1,
+};
+
static int aic32x4_i2c_probe(struct i2c_client *i2c)
{
struct regmap *regmap;
- struct regmap_config config;
enum aic32x4_type type;
- config = aic32x4_regmap_config;
- config.reg_bits = 8;
- config.val_bits = 8;
+ regmap = devm_regmap_init_i2c(i2c, &aic32x4_i2c_regmap_config);
+ if (IS_ERR(regmap))
+ return PTR_ERR(regmap);
- regmap = devm_regmap_init_i2c(i2c, &config);
type = (uintptr_t)i2c_get_match_data(i2c);
return aic32x4_probe(&i2c->dev, regmap, type);
diff --git a/sound/soc/codecs/tlv320aic32x4-spi.c b/sound/soc/codecs/tlv320aic32x4-spi.c
index 92246243ff94..4f842260e325 100644
--- a/sound/soc/codecs/tlv320aic32x4-spi.c
+++ b/sound/soc/codecs/tlv320aic32x4-spi.c
@@ -16,19 +16,25 @@
#include "tlv320aic32x4.h"
+static const struct regmap_config aic32x4_spi_regmap_config = {
+ .reg_bits = 7,
+ .pad_bits = 1,
+ .val_bits = 8,
+ .read_flag_mask = 0x01,
+ .max_register = AIC32X4_REFPOWERUP,
+ .ranges = aic32x4_regmap_pages,
+ .num_ranges = 1,
+};
+
static int aic32x4_spi_probe(struct spi_device *spi)
{
struct regmap *regmap;
- struct regmap_config config;
enum aic32x4_type type;
- config = aic32x4_regmap_config;
- config.reg_bits = 7;
- config.pad_bits = 1;
- config.val_bits = 8;
- config.read_flag_mask = 0x01;
+ regmap = devm_regmap_init_spi(spi, &aic32x4_spi_regmap_config);
+ if (IS_ERR(regmap))
+ return PTR_ERR(regmap);
- regmap = devm_regmap_init_spi(spi, &config);
type = (uintptr_t)spi_get_device_match_data(spi);
return aic32x4_probe(&spi->dev, regmap, type);
diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c
index 6b3ddb89f692..72be757f559c 100644
--- a/sound/soc/codecs/tlv320aic32x4.c
+++ b/sound/soc/codecs/tlv320aic32x4.c
@@ -581,7 +581,7 @@ static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = {
{"IN3_R to Left Mixer Negative Resistor", "40 kOhm", "IN3_R"},
};
-static const struct regmap_range_cfg aic32x4_regmap_pages[] = {
+const struct regmap_range_cfg aic32x4_regmap_pages[] = {
{
.selector_reg = 0,
.selector_mask = 0xff,
@@ -591,13 +591,7 @@ static const struct regmap_range_cfg aic32x4_regmap_pages[] = {
.range_max = AIC32X4_REFPOWERUP,
},
};
-
-const struct regmap_config aic32x4_regmap_config = {
- .max_register = AIC32X4_REFPOWERUP,
- .ranges = aic32x4_regmap_pages,
- .num_ranges = ARRAY_SIZE(aic32x4_regmap_pages),
-};
-EXPORT_SYMBOL(aic32x4_regmap_config);
+EXPORT_SYMBOL_GPL(aic32x4_regmap_pages);
static int aic32x4_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir)
@@ -1326,9 +1320,6 @@ int aic32x4_probe(struct device *dev, struct regmap *regmap,
struct device_node *np = dev->of_node;
int ret;
- if (IS_ERR(regmap))
- return PTR_ERR(regmap);
-
aic32x4 = devm_kzalloc(dev, sizeof(struct aic32x4_priv),
GFP_KERNEL);
if (aic32x4 == NULL)
diff --git a/sound/soc/codecs/tlv320aic32x4.h b/sound/soc/codecs/tlv320aic32x4.h
index 8eb9c6a4c99e..95d010af3d5a 100644
--- a/sound/soc/codecs/tlv320aic32x4.h
+++ b/sound/soc/codecs/tlv320aic32x4.h
@@ -16,7 +16,7 @@ enum aic32x4_type {
AIC32X4_TYPE_TAS2505,
};
-extern const struct regmap_config aic32x4_regmap_config;
+extern const struct regmap_range_cfg aic32x4_regmap_pages[];
int aic32x4_probe(struct device *dev, struct regmap *regmap,
enum aic32x4_type type);
void aic32x4_remove(struct device *dev);
--
2.55.0.229.g6434b31f56-goog
next prev parent reply other threads:[~2026-07-26 1:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-26 1:05 [PATCH 1/7] ASoC: tlv320aic32x4: remove global header with platform data Dmitry Torokhov
2026-07-26 1:05 ` [PATCH 2/7] ASoC: tlv320aic32x4: do not allocate gpio config separately Dmitry Torokhov
2026-07-26 1:05 ` [PATCH 3/7] ASoC: tlv320aic32x4: consolidate programming functions Dmitry Torokhov
2026-07-26 1:05 ` Dmitry Torokhov [this message]
2026-07-26 1:05 ` [PATCH 5/7] ASoC: tlv320aic32x4: do not make clocks bulk data static Dmitry Torokhov
2026-07-26 1:05 ` [PATCH 6/7] ASoC: tlv320aic32x4: factor out rate configuration helper Dmitry Torokhov
2026-07-26 1:05 ` [PATCH 7/7] ASoC: tlv320aic32x4: clean up driver code formatting and logging Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260726010519.117805-4-dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=baojun.xu@ti.com \
--cc=broonie@kernel.org \
--cc=kevin-lu@ti.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=sen@ti.com \
--cc=shenghao-ding@ti.com \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.