Skip to content

Commit f6003f9

Browse files
Uwe Kleine-Königthierryreding
authored andcommitted
pwm: sun4i: Narrow scope of local variable
The variable pval is only used in a single block in the function sun4i_pwm_calculate(). So declare it in a more local scope to simplify the function for humans and compilers. While at it also simplify assignment to pval. While the diffstat for this patch is negative for this patch I still thing the advantage of having a narrower scope is beneficial. In my compiler / .config setup (gcc 8.2.1, arm/imx_v6_v7_defconfig + COMPILE_TEST + PWM_SUN4I) this change doesn't result in any binary changes. Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent fdf47ff commit f6003f9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/pwm/pwm-sun4i.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4i_pwm,
172172
bool *bypass)
173173
{
174174
u64 clk_rate, div = 0;
175-
unsigned int pval, prescaler = 0;
175+
unsigned int prescaler = 0;
176176

177177
clk_rate = clk_get_rate(sun4i_pwm->clk);
178178

@@ -203,9 +203,11 @@ static int sun4i_pwm_calculate(struct sun4i_pwm_chip *sun4i_pwm,
203203
if (prescaler == 0) {
204204
/* Go up from the first divider */
205205
for (prescaler = 0; prescaler < PWM_PRESCAL_MASK; prescaler++) {
206-
if (!prescaler_table[prescaler])
206+
unsigned int pval = prescaler_table[prescaler];
207+
208+
if (!pval)
207209
continue;
208-
pval = prescaler_table[prescaler];
210+
209211
div = clk_rate;
210212
do_div(div, pval);
211213
div = div * state->period;

0 commit comments

Comments
 (0)