regulator: max77843: Reduce duplication of regulator_desc initializers
authorKrzysztof Kozlowski <k.kozlowski.k@gmail.com>
Sat, 18 Apr 2015 11:27:18 +0000 (20:27 +0900)
committerMark Brown <broonie@kernel.org>
Mon, 27 Apr 2015 17:58:52 +0000 (18:58 +0100)
Replace duplicated SAFEOUT regulators initializers in array of struct
'regulator_desc' arrays with macro. Generated object is the same but
SAFEOUT is described only once.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/max77843.c

index c132ef527cdddb307cfe9567d7eadb332739e62c..e4e7687ccd7e6bc0b2d9c6174bd51fda8fdc99ba 100644 (file)
@@ -112,37 +112,25 @@ static struct regulator_ops max77843_regulator_ops = {
        .set_voltage_sel        = regulator_set_voltage_sel_regmap,
 };
 
+#define        MAX77843_SAFEOUT(num)   { \
+       .name           = "SAFEOUT" # num, \
+       .id             = MAX77843_SAFEOUT ## num, \
+       .ops            = &max77843_regulator_ops, \
+       .of_match       = of_match_ptr("SAFEOUT" # num), \
+       .regulators_node = of_match_ptr("regulators"), \
+       .type           = REGULATOR_VOLTAGE, \
+       .owner          = THIS_MODULE, \
+       .n_voltages     = ARRAY_SIZE(max77843_safeout_voltage_table), \
+       .volt_table     = max77843_safeout_voltage_table, \
+       .enable_reg     = MAX77843_SYS_REG_SAFEOUTCTRL, \
+       .enable_mask    = MAX77843_REG_SAFEOUTCTRL_ENSAFEOUT ## num, \
+       .vsel_reg       = MAX77843_SYS_REG_SAFEOUTCTRL, \
+       .vsel_mask      = MAX77843_REG_SAFEOUTCTRL_SAFEOUT ## num ## _MASK, \
+}
+
 static const struct regulator_desc max77843_supported_regulators[] = {
-       [MAX77843_SAFEOUT1] = {
-               .name           = "SAFEOUT1",
-               .id             = MAX77843_SAFEOUT1,
-               .ops            = &max77843_regulator_ops,
-               .of_match       = of_match_ptr("SAFEOUT1"),
-               .regulators_node = of_match_ptr("regulators"),
-               .type           = REGULATOR_VOLTAGE,
-               .owner          = THIS_MODULE,
-               .n_voltages     = ARRAY_SIZE(max77843_safeout_voltage_table),
-               .volt_table     = max77843_safeout_voltage_table,
-               .enable_reg     = MAX77843_SYS_REG_SAFEOUTCTRL,
-               .enable_mask    = MAX77843_REG_SAFEOUTCTRL_ENSAFEOUT1,
-               .vsel_reg       = MAX77843_SYS_REG_SAFEOUTCTRL,
-               .vsel_mask      = MAX77843_REG_SAFEOUTCTRL_SAFEOUT1_MASK,
-       },
-       [MAX77843_SAFEOUT2] = {
-               .name           = "SAFEOUT2",
-               .id             = MAX77843_SAFEOUT2,
-               .ops            = &max77843_regulator_ops,
-               .of_match       = of_match_ptr("SAFEOUT2"),
-               .regulators_node = of_match_ptr("regulators"),
-               .type           = REGULATOR_VOLTAGE,
-               .owner          = THIS_MODULE,
-               .n_voltages     = ARRAY_SIZE(max77843_safeout_voltage_table),
-               .volt_table     = max77843_safeout_voltage_table,
-               .enable_reg     = MAX77843_SYS_REG_SAFEOUTCTRL,
-               .enable_mask    = MAX77843_REG_SAFEOUTCTRL_ENSAFEOUT2,
-               .vsel_reg       = MAX77843_SYS_REG_SAFEOUTCTRL,
-               .vsel_mask      = MAX77843_REG_SAFEOUTCTRL_SAFEOUT2_MASK,
-       },
+       [MAX77843_SAFEOUT1] = MAX77843_SAFEOUT(1),
+       [MAX77843_SAFEOUT2] = MAX77843_SAFEOUT(2),
        [MAX77843_CHARGER] = {
                .name           = "CHARGER",
                .id             = MAX77843_CHARGER,