regulator: Simplify MAX8997_REG_BUCK1DVS/MAX8997_REG_BUCK2DVS/MAX8997_REG_BUCK5DVS macros
PATCH 1/1 regulator: Simplify MAX8997_REG_BUCK1DVS/MAX8997_REG_BUCK2DVS/MAX8997_REG_BUCK5DVS macros
Looks like the original macro implementation assumes the caller pass the parameter starting from 1.
Since now we have +1 operation from all the caller, it would be easier to assume the caller pass the parameter starting from 0.
Then we can simplify the +1 operation from the caller and then -1 operation in the macro implementation.
I think this change also improves readability.
Signed-off-by Axel Lin <[email protected]>
--- drivers/regulator/max8997.c | 12 ++++++------ include/linux/mfd/max8997-private.h | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/regulator/max8997.c +6 -6
@@ -1032,11 +1032,11 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)/* For the safety, set max voltage before setting up */ for (i =0 ; i <8 ; i++) { -max8997_update_reg (i2c,MAX8997_REG_BUCK1DVS (i +1 ), +max8997_update_reg (i2c,MAX8997_REG_BUCK1DVS (i), max_buck1,0x3f ); -max8997_update_reg (i2c,MAX8997_REG_BUCK2DVS (i +1 ), +max8997_update_reg (i2c,MAX8997_REG_BUCK2DVS (i), max_buck2,0x3f ); -max8997_update_reg (i2c,MAX8997_REG_BUCK5DVS (i +1 ), +max8997_update_reg (i2c,MAX8997_REG_BUCK5DVS (i), max_buck5,0x3f ); }
@@ -1113,13 +1113,13 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)/* Initialize all the DVS related BUCK registers */ for (i =0 ; i <8 ; i++) { -max8997_update_reg (i2c,MAX8997_REG_BUCK1DVS (i +1 ), +max8997_update_reg (i2c,MAX8997_REG_BUCK1DVS (i), max8997->buck1_vol[i],0x3f ); -max8997_update_reg (i2c,MAX8997_REG_BUCK2DVS (i +1 ), +max8997_update_reg (i2c,MAX8997_REG_BUCK2DVS (i), max8997->buck2_vol[i],0x3f ); -max8997_update_reg (i2c,MAX8997_REG_BUCK5DVS (i +1 ), +max8997_update_reg (i2c,MAX8997_REG_BUCK5DVS (i), max8997->buck5_vol[i],0x3f ); }
include/linux/mfd/max8997-private.h +3 -3
@@ -311,9 +311,9 @@ enum max8997_irq { MAX8997_IRQ_NR, }; -#define MAX8997_REG_BUCK1DVS (x) (MAX8997_REG_BUCK1DVS1 + (x) - 1) -#define MAX8997_REG_BUCK2DVS (x) (MAX8997_REG_BUCK2DVS1 + (x) - 1) -#define MAX8997_REG_BUCK5DVS (x) (MAX8997_REG_BUCK5DVS1 + (x) - 1) +#define MAX8997_REG_BUCK1DVS (x) (MAX8997_REG_BUCK1DVS1 + (x)) +#define MAX8997_REG_BUCK2DVS (x) (MAX8997_REG_BUCK2DVS1 + (x)) +#define MAX8997_REG_BUCK5DVS (x) (MAX8997_REG_BUCK5DVS1 + (x))#define MAX8997_NUM_GPIO 12struct max8997_dev {
Signature · 1 line
1.7.1