提交 cab344d3 编写于 作者: K Krzysztof Kozlowski 提交者: Mark Brown

regulator: max14577: Reduce duplication of regulator_desc initializers

Replace duplicated initializers in arrays of struct 'regulator_desc'
with macro. Generated object is the same but each type of regulator is
described only once.
Signed-off-by: NKrzysztof Kozlowski <k.kozlowski.k@gmail.com>
Signed-off-by: NMark Brown <broonie@kernel.org>
上级 b787f68c
...@@ -100,31 +100,34 @@ static struct regulator_ops max14577_charger_ops = { ...@@ -100,31 +100,34 @@ static struct regulator_ops max14577_charger_ops = {
.set_current_limit = max14577_reg_set_current_limit, .set_current_limit = max14577_reg_set_current_limit,
}; };
#define MAX14577_SAFEOUT_REG { \
.name = "SAFEOUT", \
.of_match = of_match_ptr("SAFEOUT"), \
.regulators_node = of_match_ptr("regulators"), \
.id = MAX14577_SAFEOUT, \
.ops = &max14577_safeout_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.n_voltages = 1, \
.min_uV = MAX14577_REGULATOR_SAFEOUT_VOLTAGE, \
.enable_reg = MAX14577_REG_CONTROL2, \
.enable_mask = CTRL2_SFOUTORD_MASK, \
}
#define MAX14577_CHARGER_REG { \
.name = "CHARGER", \
.of_match = of_match_ptr("CHARGER"), \
.regulators_node = of_match_ptr("regulators"), \
.id = MAX14577_CHARGER, \
.ops = &max14577_charger_ops, \
.type = REGULATOR_CURRENT, \
.owner = THIS_MODULE, \
.enable_reg = MAX14577_CHG_REG_CHG_CTRL2, \
.enable_mask = CHGCTRL2_MBCHOSTEN_MASK, \
}
static const struct regulator_desc max14577_supported_regulators[] = { static const struct regulator_desc max14577_supported_regulators[] = {
[MAX14577_SAFEOUT] = { [MAX14577_SAFEOUT] = MAX14577_SAFEOUT_REG,
.name = "SAFEOUT", [MAX14577_CHARGER] = MAX14577_CHARGER_REG,
.of_match = of_match_ptr("SAFEOUT"),
.regulators_node = of_match_ptr("regulators"),
.id = MAX14577_SAFEOUT,
.ops = &max14577_safeout_ops,
.type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE,
.n_voltages = 1,
.min_uV = MAX14577_REGULATOR_SAFEOUT_VOLTAGE,
.enable_reg = MAX14577_REG_CONTROL2,
.enable_mask = CTRL2_SFOUTORD_MASK,
},
[MAX14577_CHARGER] = {
.name = "CHARGER",
.of_match = of_match_ptr("CHARGER"),
.regulators_node = of_match_ptr("regulators"),
.id = MAX14577_CHARGER,
.ops = &max14577_charger_ops,
.type = REGULATOR_CURRENT,
.owner = THIS_MODULE,
.enable_reg = MAX14577_CHG_REG_CHG_CTRL2,
.enable_mask = CHGCTRL2_MBCHOSTEN_MASK,
},
}; };
static struct regulator_ops max77836_ldo_ops = { static struct regulator_ops max77836_ldo_ops = {
...@@ -138,63 +141,28 @@ static struct regulator_ops max77836_ldo_ops = { ...@@ -138,63 +141,28 @@ static struct regulator_ops max77836_ldo_ops = {
/* TODO: add .set_suspend_mode */ /* TODO: add .set_suspend_mode */
}; };
#define MAX77836_LDO_REG(num) { \
.name = "LDO" # num, \
.of_match = of_match_ptr("LDO" # num), \
.regulators_node = of_match_ptr("regulators"), \
.id = MAX77836_LDO ## num, \
.ops = &max77836_ldo_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.n_voltages = MAX77836_REGULATOR_LDO_VOLTAGE_STEPS_NUM, \
.min_uV = MAX77836_REGULATOR_LDO_VOLTAGE_MIN, \
.uV_step = MAX77836_REGULATOR_LDO_VOLTAGE_STEP, \
.enable_reg = MAX77836_LDO_REG_CNFG1_LDO ## num, \
.enable_mask = MAX77836_CNFG1_LDO_PWRMD_MASK, \
.vsel_reg = MAX77836_LDO_REG_CNFG1_LDO ## num, \
.vsel_mask = MAX77836_CNFG1_LDO_TV_MASK, \
}
static const struct regulator_desc max77836_supported_regulators[] = { static const struct regulator_desc max77836_supported_regulators[] = {
[MAX14577_SAFEOUT] = { [MAX14577_SAFEOUT] = MAX14577_SAFEOUT_REG,
.name = "SAFEOUT", [MAX14577_CHARGER] = MAX14577_CHARGER_REG,
.of_match = of_match_ptr("SAFEOUT"), [MAX77836_LDO1] = MAX77836_LDO_REG(1),
.regulators_node = of_match_ptr("regulators"), [MAX77836_LDO2] = MAX77836_LDO_REG(2),
.id = MAX14577_SAFEOUT,
.ops = &max14577_safeout_ops,
.type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE,
.n_voltages = 1,
.min_uV = MAX14577_REGULATOR_SAFEOUT_VOLTAGE,
.enable_reg = MAX14577_REG_CONTROL2,
.enable_mask = CTRL2_SFOUTORD_MASK,
},
[MAX14577_CHARGER] = {
.name = "CHARGER",
.of_match = of_match_ptr("CHARGER"),
.regulators_node = of_match_ptr("regulators"),
.id = MAX14577_CHARGER,
.ops = &max14577_charger_ops,
.type = REGULATOR_CURRENT,
.owner = THIS_MODULE,
.enable_reg = MAX14577_CHG_REG_CHG_CTRL2,
.enable_mask = CHGCTRL2_MBCHOSTEN_MASK,
},
[MAX77836_LDO1] = {
.name = "LDO1",
.of_match = of_match_ptr("LDO1"),
.regulators_node = of_match_ptr("regulators"),
.id = MAX77836_LDO1,
.ops = &max77836_ldo_ops,
.type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE,
.n_voltages = MAX77836_REGULATOR_LDO_VOLTAGE_STEPS_NUM,
.min_uV = MAX77836_REGULATOR_LDO_VOLTAGE_MIN,
.uV_step = MAX77836_REGULATOR_LDO_VOLTAGE_STEP,
.enable_reg = MAX77836_LDO_REG_CNFG1_LDO1,
.enable_mask = MAX77836_CNFG1_LDO_PWRMD_MASK,
.vsel_reg = MAX77836_LDO_REG_CNFG1_LDO1,
.vsel_mask = MAX77836_CNFG1_LDO_TV_MASK,
},
[MAX77836_LDO2] = {
.name = "LDO2",
.of_match = of_match_ptr("LDO2"),
.regulators_node = of_match_ptr("regulators"),
.id = MAX77836_LDO2,
.ops = &max77836_ldo_ops,
.type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE,
.n_voltages = MAX77836_REGULATOR_LDO_VOLTAGE_STEPS_NUM,
.min_uV = MAX77836_REGULATOR_LDO_VOLTAGE_MIN,
.uV_step = MAX77836_REGULATOR_LDO_VOLTAGE_STEP,
.enable_reg = MAX77836_LDO_REG_CNFG1_LDO2,
.enable_mask = MAX77836_CNFG1_LDO_PWRMD_MASK,
.vsel_reg = MAX77836_LDO_REG_CNFG1_LDO2,
.vsel_mask = MAX77836_CNFG1_LDO_TV_MASK,
},
}; };
#ifdef CONFIG_OF #ifdef CONFIG_OF
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册