Re: [PATCH 2/3] regulator: s2mpa01: Optimize the regulator description macro
On Mon, Jul 14, 2014 at 2:19 PM, Krzysztof Kozlowski k.kozlow...@samsung.com wrote: On 08.07.2014 14:27, Amit Daniel Kachhap wrote: This patch makes the regulator description macro take minimum and steps voltage as parameter. In this way many repeated macros can be removed. Now these macros are repeated only if the the LDO/BUCK ctrl registers have non-linear positions. The good thing is these ctrl registers are mostly linear so they are not passed as parameters. This patch reduces the code size and also allow easy addition of more s2mpxxx PMIC drivers which differs a lot in minimum/step voltages. Signed-off-by: Amit Daniel Kachhap amit.dan...@samsung.com --- drivers/regulator/s2mpa01.c | 136 1 file changed, 37 insertions(+), 99 deletions(-) diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c index 962c5f1..8073466 100644 --- a/drivers/regulator/s2mpa01.c +++ b/drivers/regulator/s2mpa01.c @@ -235,28 +235,14 @@ static struct regulator_ops s2mpa01_buck_ops = { .set_ramp_delay = s2mpa01_set_ramp_delay, }; -#define regulator_desc_ldo1(num) { \ +#define regulator_desc_ldo(num, min, step) { \ Why adding parameter for the 'min' value? It is always the same for LDOs - 800 mV. The same applies for the s2mps11 regulator driver. Correct. min parameter can be removed. Thanks for the review. Best regards, Krzysztof .name = LDO#num,\ .id = S2MPA01_LDO##num, \ .ops= s2mpa01_ldo_ops, \ .type = REGULATOR_VOLTAGE,\ .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step= STEP_50_MV, \ - .n_voltages = S2MPA01_LDO_N_VOLTAGES, \ - .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \ - .vsel_mask = S2MPA01_LDO_VSEL_MASK,\ - .enable_reg = S2MPA01_REG_L1CTRL + num - 1, \ - .enable_mask= S2MPA01_ENABLE_MASK \ -} -#define regulator_desc_ldo2(num) { \ - .name = LDO#num,\ - .id = S2MPA01_LDO##num, \ - .ops= s2mpa01_ldo_ops, \ - .type = REGULATOR_VOLTAGE,\ - .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step= STEP_25_MV, \ + .min_uV = min, \ + .uV_step= step, \ .n_voltages = S2MPA01_LDO_N_VOLTAGES, \ .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \ .vsel_mask = S2MPA01_LDO_VSEL_MASK,\ @@ -296,14 +282,14 @@ static struct regulator_ops s2mpa01_buck_ops = { .enable_mask= S2MPA01_ENABLE_MASK \ } -#define regulator_desc_buck6_7(num){ \ +#define regulator_desc_buck6_10(num, min, step){ \ .name = BUCK#num, \ .id = S2MPA01_BUCK##num,\ .ops= s2mpa01_buck_ops,\ .type = REGULATOR_VOLTAGE,\ .owner = THIS_MODULE, \ - .min_uV = MIN_600_MV, \ - .uV_step= STEP_6_25_MV, \ + .min_uV = min, \ + .uV_step= step, \ .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ .ramp_delay = S2MPA01_RAMP_DELAY, \ .vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \ @@ -312,91 +298,43 @@ static struct regulator_ops s2mpa01_buck_ops = { .enable_mask= S2MPA01_ENABLE_MASK \ } -#define regulator_desc_buck8 { \ - .name = BUCK8, \ - .id = S2MPA01_BUCK8,\ - .ops= s2mpa01_buck_ops,\ - .type = REGULATOR_VOLTAGE,\ - .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step= STEP_12_5_MV, \ - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ - .ramp_delay = S2MPA01_RAMP_DELAY, \ - .vsel_reg = S2MPA01_REG_B8CTRL2, \ - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \ -
Re: [PATCH 2/3] regulator: s2mpa01: Optimize the regulator description macro
On 08.07.2014 14:27, Amit Daniel Kachhap wrote: This patch makes the regulator description macro take minimum and steps voltage as parameter. In this way many repeated macros can be removed. Now these macros are repeated only if the the LDO/BUCK ctrl registers have non-linear positions. The good thing is these ctrl registers are mostly linear so they are not passed as parameters. This patch reduces the code size and also allow easy addition of more s2mpxxx PMIC drivers which differs a lot in minimum/step voltages. Signed-off-by: Amit Daniel Kachhap amit.dan...@samsung.com --- drivers/regulator/s2mpa01.c | 136 1 file changed, 37 insertions(+), 99 deletions(-) diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c index 962c5f1..8073466 100644 --- a/drivers/regulator/s2mpa01.c +++ b/drivers/regulator/s2mpa01.c @@ -235,28 +235,14 @@ static struct regulator_ops s2mpa01_buck_ops = { .set_ramp_delay = s2mpa01_set_ramp_delay, }; -#define regulator_desc_ldo1(num) { \ +#define regulator_desc_ldo(num, min, step) { \ Why adding parameter for the 'min' value? It is always the same for LDOs - 800 mV. The same applies for the s2mps11 regulator driver. Best regards, Krzysztof .name = LDO#num, \ .id = S2MPA01_LDO##num, \ .ops= s2mpa01_ldo_ops, \ .type = REGULATOR_VOLTAGE,\ .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step= STEP_50_MV, \ - .n_voltages = S2MPA01_LDO_N_VOLTAGES, \ - .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \ - .vsel_mask = S2MPA01_LDO_VSEL_MASK,\ - .enable_reg = S2MPA01_REG_L1CTRL + num - 1, \ - .enable_mask= S2MPA01_ENABLE_MASK \ -} -#define regulator_desc_ldo2(num) { \ - .name = LDO#num, \ - .id = S2MPA01_LDO##num, \ - .ops= s2mpa01_ldo_ops, \ - .type = REGULATOR_VOLTAGE,\ - .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step= STEP_25_MV, \ + .min_uV = min, \ + .uV_step= step, \ .n_voltages = S2MPA01_LDO_N_VOLTAGES, \ .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \ .vsel_mask = S2MPA01_LDO_VSEL_MASK,\ @@ -296,14 +282,14 @@ static struct regulator_ops s2mpa01_buck_ops = { .enable_mask= S2MPA01_ENABLE_MASK \ } -#define regulator_desc_buck6_7(num){ \ +#define regulator_desc_buck6_10(num, min, step){ \ .name = BUCK#num, \ .id = S2MPA01_BUCK##num,\ .ops= s2mpa01_buck_ops,\ .type = REGULATOR_VOLTAGE,\ .owner = THIS_MODULE, \ - .min_uV = MIN_600_MV, \ - .uV_step= STEP_6_25_MV, \ + .min_uV = min, \ + .uV_step= step, \ .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ .ramp_delay = S2MPA01_RAMP_DELAY, \ .vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \ @@ -312,91 +298,43 @@ static struct regulator_ops s2mpa01_buck_ops = { .enable_mask= S2MPA01_ENABLE_MASK \ } -#define regulator_desc_buck8 { \ - .name = BUCK8,\ - .id = S2MPA01_BUCK8,\ - .ops= s2mpa01_buck_ops,\ - .type = REGULATOR_VOLTAGE,\ - .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step= STEP_12_5_MV, \ - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ - .ramp_delay = S2MPA01_RAMP_DELAY, \ - .vsel_reg = S2MPA01_REG_B8CTRL2, \ - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \ - .enable_reg = S2MPA01_REG_B8CTRL1, \ - .enable_mask= S2MPA01_ENABLE_MASK \ -} - -#define regulator_desc_buck9 { \ - .name = BUCK9,
Re: [PATCH 2/3] regulator: s2mpa01: Optimize the regulator description macro
On Thu, 10 Jul 2014, amit daniel kachhap wrote: Adding MFD maintainers. Why, what for? On Tue, Jul 8, 2014 at 5:57 PM, Amit Daniel Kachhap amit.dan...@samsung.com wrote: This patch makes the regulator description macro take minimum and steps voltage as parameter. In this way many repeated macros can be removed. Now these macros are repeated only if the the LDO/BUCK ctrl registers have non-linear positions. The good thing is these ctrl registers are mostly linear so they are not passed as parameters. This patch reduces the code size and also allow easy addition of more s2mpxxx PMIC drivers which differs a lot in minimum/step voltages. Signed-off-by: Amit Daniel Kachhap amit.dan...@samsung.com --- drivers/regulator/s2mpa01.c | 136 1 file changed, 37 insertions(+), 99 deletions(-) diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c index 962c5f1..8073466 100644 --- a/drivers/regulator/s2mpa01.c +++ b/drivers/regulator/s2mpa01.c @@ -235,28 +235,14 @@ static struct regulator_ops s2mpa01_buck_ops = { .set_ramp_delay = s2mpa01_set_ramp_delay, }; -#define regulator_desc_ldo1(num) { \ +#define regulator_desc_ldo(num, min, step) { \ .name = LDO#num,\ .id = S2MPA01_LDO##num, \ .ops= s2mpa01_ldo_ops, \ .type = REGULATOR_VOLTAGE,\ .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step= STEP_50_MV, \ - .n_voltages = S2MPA01_LDO_N_VOLTAGES, \ - .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \ - .vsel_mask = S2MPA01_LDO_VSEL_MASK,\ - .enable_reg = S2MPA01_REG_L1CTRL + num - 1, \ - .enable_mask= S2MPA01_ENABLE_MASK \ -} -#define regulator_desc_ldo2(num) { \ - .name = LDO#num,\ - .id = S2MPA01_LDO##num, \ - .ops= s2mpa01_ldo_ops, \ - .type = REGULATOR_VOLTAGE,\ - .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step= STEP_25_MV, \ + .min_uV = min, \ + .uV_step= step, \ .n_voltages = S2MPA01_LDO_N_VOLTAGES, \ .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \ .vsel_mask = S2MPA01_LDO_VSEL_MASK,\ @@ -296,14 +282,14 @@ static struct regulator_ops s2mpa01_buck_ops = { .enable_mask= S2MPA01_ENABLE_MASK \ } -#define regulator_desc_buck6_7(num){ \ +#define regulator_desc_buck6_10(num, min, step){ \ .name = BUCK#num, \ .id = S2MPA01_BUCK##num,\ .ops= s2mpa01_buck_ops,\ .type = REGULATOR_VOLTAGE,\ .owner = THIS_MODULE, \ - .min_uV = MIN_600_MV, \ - .uV_step= STEP_6_25_MV, \ + .min_uV = min, \ + .uV_step= step, \ .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ .ramp_delay = S2MPA01_RAMP_DELAY, \ .vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \ @@ -312,91 +298,43 @@ static struct regulator_ops s2mpa01_buck_ops = { .enable_mask= S2MPA01_ENABLE_MASK \ } -#define regulator_desc_buck8 { \ - .name = BUCK8, \ - .id = S2MPA01_BUCK8,\ - .ops= s2mpa01_buck_ops,\ - .type = REGULATOR_VOLTAGE,\ - .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step= STEP_12_5_MV, \ - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ - .ramp_delay = S2MPA01_RAMP_DELAY, \ - .vsel_reg = S2MPA01_REG_B8CTRL2, \ - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \ - .enable_reg = S2MPA01_REG_B8CTRL1, \ - .enable_mask= S2MPA01_ENABLE_MASK
Re: [PATCH 2/3] regulator: s2mpa01: Optimize the regulator description macro
On Thu, Jul 10, 2014 at 1:05 PM, Lee Jones lee.jo...@linaro.org wrote: On Thu, 10 Jul 2014, amit daniel kachhap wrote: Adding MFD maintainers. Why, what for? Sorry not needed for this patch. On Tue, Jul 8, 2014 at 5:57 PM, Amit Daniel Kachhap amit.dan...@samsung.com wrote: This patch makes the regulator description macro take minimum and steps voltage as parameter. In this way many repeated macros can be removed. Now these macros are repeated only if the the LDO/BUCK ctrl registers have non-linear positions. The good thing is these ctrl registers are mostly linear so they are not passed as parameters. This patch reduces the code size and also allow easy addition of more s2mpxxx PMIC drivers which differs a lot in minimum/step voltages. Signed-off-by: Amit Daniel Kachhap amit.dan...@samsung.com --- drivers/regulator/s2mpa01.c | 136 1 file changed, 37 insertions(+), 99 deletions(-) diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c index 962c5f1..8073466 100644 --- a/drivers/regulator/s2mpa01.c +++ b/drivers/regulator/s2mpa01.c @@ -235,28 +235,14 @@ static struct regulator_ops s2mpa01_buck_ops = { .set_ramp_delay = s2mpa01_set_ramp_delay, }; -#define regulator_desc_ldo1(num) { \ +#define regulator_desc_ldo(num, min, step) { \ .name = LDO#num,\ .id = S2MPA01_LDO##num, \ .ops= s2mpa01_ldo_ops, \ .type = REGULATOR_VOLTAGE,\ .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step= STEP_50_MV, \ - .n_voltages = S2MPA01_LDO_N_VOLTAGES, \ - .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \ - .vsel_mask = S2MPA01_LDO_VSEL_MASK,\ - .enable_reg = S2MPA01_REG_L1CTRL + num - 1, \ - .enable_mask= S2MPA01_ENABLE_MASK \ -} -#define regulator_desc_ldo2(num) { \ - .name = LDO#num,\ - .id = S2MPA01_LDO##num, \ - .ops= s2mpa01_ldo_ops, \ - .type = REGULATOR_VOLTAGE,\ - .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step= STEP_25_MV, \ + .min_uV = min, \ + .uV_step= step, \ .n_voltages = S2MPA01_LDO_N_VOLTAGES, \ .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \ .vsel_mask = S2MPA01_LDO_VSEL_MASK,\ @@ -296,14 +282,14 @@ static struct regulator_ops s2mpa01_buck_ops = { .enable_mask= S2MPA01_ENABLE_MASK \ } -#define regulator_desc_buck6_7(num){ \ +#define regulator_desc_buck6_10(num, min, step){ \ .name = BUCK#num, \ .id = S2MPA01_BUCK##num,\ .ops= s2mpa01_buck_ops,\ .type = REGULATOR_VOLTAGE,\ .owner = THIS_MODULE, \ - .min_uV = MIN_600_MV, \ - .uV_step= STEP_6_25_MV, \ + .min_uV = min, \ + .uV_step= step, \ .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ .ramp_delay = S2MPA01_RAMP_DELAY, \ .vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \ @@ -312,91 +298,43 @@ static struct regulator_ops s2mpa01_buck_ops = { .enable_mask= S2MPA01_ENABLE_MASK \ } -#define regulator_desc_buck8 { \ - .name = BUCK8, \ - .id = S2MPA01_BUCK8,\ - .ops= s2mpa01_buck_ops,\ - .type = REGULATOR_VOLTAGE,\ - .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step= STEP_12_5_MV, \ - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ - .ramp_delay = S2MPA01_RAMP_DELAY, \ - .vsel_reg = S2MPA01_REG_B8CTRL2, \ - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \ -
Re: [PATCH 2/3] regulator: s2mpa01: Optimize the regulator description macro
Adding MFD maintainers. On Tue, Jul 8, 2014 at 5:57 PM, Amit Daniel Kachhap amit.dan...@samsung.com wrote: This patch makes the regulator description macro take minimum and steps voltage as parameter. In this way many repeated macros can be removed. Now these macros are repeated only if the the LDO/BUCK ctrl registers have non-linear positions. The good thing is these ctrl registers are mostly linear so they are not passed as parameters. This patch reduces the code size and also allow easy addition of more s2mpxxx PMIC drivers which differs a lot in minimum/step voltages. Signed-off-by: Amit Daniel Kachhap amit.dan...@samsung.com --- drivers/regulator/s2mpa01.c | 136 1 file changed, 37 insertions(+), 99 deletions(-) diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c index 962c5f1..8073466 100644 --- a/drivers/regulator/s2mpa01.c +++ b/drivers/regulator/s2mpa01.c @@ -235,28 +235,14 @@ static struct regulator_ops s2mpa01_buck_ops = { .set_ramp_delay = s2mpa01_set_ramp_delay, }; -#define regulator_desc_ldo1(num) { \ +#define regulator_desc_ldo(num, min, step) { \ .name = LDO#num,\ .id = S2MPA01_LDO##num, \ .ops= s2mpa01_ldo_ops, \ .type = REGULATOR_VOLTAGE,\ .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step= STEP_50_MV, \ - .n_voltages = S2MPA01_LDO_N_VOLTAGES, \ - .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \ - .vsel_mask = S2MPA01_LDO_VSEL_MASK,\ - .enable_reg = S2MPA01_REG_L1CTRL + num - 1, \ - .enable_mask= S2MPA01_ENABLE_MASK \ -} -#define regulator_desc_ldo2(num) { \ - .name = LDO#num,\ - .id = S2MPA01_LDO##num, \ - .ops= s2mpa01_ldo_ops, \ - .type = REGULATOR_VOLTAGE,\ - .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step= STEP_25_MV, \ + .min_uV = min, \ + .uV_step= step, \ .n_voltages = S2MPA01_LDO_N_VOLTAGES, \ .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \ .vsel_mask = S2MPA01_LDO_VSEL_MASK,\ @@ -296,14 +282,14 @@ static struct regulator_ops s2mpa01_buck_ops = { .enable_mask= S2MPA01_ENABLE_MASK \ } -#define regulator_desc_buck6_7(num){ \ +#define regulator_desc_buck6_10(num, min, step){ \ .name = BUCK#num, \ .id = S2MPA01_BUCK##num,\ .ops= s2mpa01_buck_ops,\ .type = REGULATOR_VOLTAGE,\ .owner = THIS_MODULE, \ - .min_uV = MIN_600_MV, \ - .uV_step= STEP_6_25_MV, \ + .min_uV = min, \ + .uV_step= step, \ .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ .ramp_delay = S2MPA01_RAMP_DELAY, \ .vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \ @@ -312,91 +298,43 @@ static struct regulator_ops s2mpa01_buck_ops = { .enable_mask= S2MPA01_ENABLE_MASK \ } -#define regulator_desc_buck8 { \ - .name = BUCK8, \ - .id = S2MPA01_BUCK8,\ - .ops= s2mpa01_buck_ops,\ - .type = REGULATOR_VOLTAGE,\ - .owner = THIS_MODULE, \ - .min_uV = MIN_800_MV, \ - .uV_step= STEP_12_5_MV, \ - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ - .ramp_delay = S2MPA01_RAMP_DELAY, \ - .vsel_reg = S2MPA01_REG_B8CTRL2, \ - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \ - .enable_reg = S2MPA01_REG_B8CTRL1, \ - .enable_mask= S2MPA01_ENABLE_MASK \ -} - -#define regulator_desc_buck9 { \ - .name = BUCK9, \ -