Skip to content

Commit 2da34b2

Browse files
rfvirgilbroonie
authored andcommitted
regulator: arizona-micsupp: Don't hardcode use of ARIZONA defines
When Madera support was added to this driver the code was left using ARIZONA_* defines. This wasn't causing any problem because those defines just happened to have the same value as the equivalent MADERA_* defines. But it is not ideal to assume this, and future devices that can share this driver do not have the same register map. Fix the code to refer to the register data in struct regulator_desc. Signed-off-by: Richard Fitzgerald <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent db6f6ba commit 2da34b2

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

drivers/regulator/arizona-micsupp.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct arizona_micsupp {
3434
struct regulator_dev *regulator;
3535
struct regmap *regmap;
3636
struct snd_soc_dapm_context **dapm;
37-
unsigned int enable_reg;
37+
const struct regulator_desc *desc;
3838
struct device *dev;
3939

4040
struct regulator_consumer_supply supply;
@@ -49,10 +49,11 @@ static void arizona_micsupp_check_cp(struct work_struct *work)
4949
container_of(work, struct arizona_micsupp, check_cp_work);
5050
struct snd_soc_dapm_context *dapm = *micsupp->dapm;
5151
struct snd_soc_component *component;
52+
const struct regulator_desc *desc = micsupp->desc;
5253
unsigned int val;
5354
int ret;
5455

55-
ret = regmap_read(micsupp->regmap, micsupp->enable_reg, &val);
56+
ret = regmap_read(micsupp->regmap, desc->enable_reg, &val);
5657
if (ret != 0) {
5758
dev_err(micsupp->dev,
5859
"Failed to read CP state: %d\n", ret);
@@ -62,8 +63,8 @@ static void arizona_micsupp_check_cp(struct work_struct *work)
6263
if (dapm) {
6364
component = snd_soc_dapm_to_component(dapm);
6465

65-
if ((val & (ARIZONA_CPMIC_ENA | ARIZONA_CPMIC_BYPASS)) ==
66-
ARIZONA_CPMIC_ENA)
66+
if ((val & (desc->enable_mask | desc->bypass_mask)) ==
67+
desc->enable_mask)
6768
snd_soc_component_force_enable_pin(component,
6869
"MICSUPP");
6970
else
@@ -209,7 +210,6 @@ static const struct regulator_desc madera_micsupp = {
209210
.type = REGULATOR_VOLTAGE,
210211
.n_voltages = 40,
211212
.ops = &arizona_micsupp_ops,
212-
213213
.vsel_reg = MADERA_LDO2_CONTROL_1,
214214
.vsel_mask = MADERA_LDO2_VSEL_MASK,
215215
.enable_reg = MADERA_MIC_CHARGE_PUMP_1,
@@ -264,7 +264,7 @@ static int arizona_micsupp_common_init(struct platform_device *pdev,
264264
micsupp->init_data.consumer_supplies = &micsupp->supply;
265265
micsupp->supply.supply = "MICVDD";
266266
micsupp->supply.dev_name = dev_name(micsupp->dev);
267-
micsupp->enable_reg = desc->enable_reg;
267+
micsupp->desc = desc;
268268

269269
config.dev = micsupp->dev;
270270
config.driver_data = micsupp;
@@ -285,8 +285,7 @@ static int arizona_micsupp_common_init(struct platform_device *pdev,
285285
config.init_data = &micsupp->init_data;
286286

287287
/* Default to regulated mode */
288-
regmap_update_bits(micsupp->regmap, micsupp->enable_reg,
289-
ARIZONA_CPMIC_BYPASS, 0);
288+
regmap_update_bits(micsupp->regmap, desc->enable_reg, desc->bypass_mask, 0);
290289

291290
micsupp->regulator = devm_regulator_register(&pdev->dev,
292291
desc,

0 commit comments

Comments
 (0)