mirror of
https://github.com/torvalds/linux.git
synced 2026-09-28 12:02:03 +02:00
ASoC: tlv320aic32x4: move regmap_config into i2c and spi drivers
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> Link: https://patch.msgid.link/20260726010519.117805-4-dmitry.torokhov@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
4ef61518b0
commit
2ba6a4dba6
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user