drivers/leds/leds-lm3530.c: move the code setting gen_config to one place
authorAxel Lin <axel.lin@gmail.com>
Fri, 23 Mar 2012 22:02:13 +0000 (15:02 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 23 Mar 2012 23:58:35 +0000 (16:58 -0700)
Improve the readability by moving the code setting gen_config to one
place.

[akpm@linux-foundation.org: fix some patch skew]
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Cc: Shreshtha Kumar Sahu <shreshthakumar.sahu@stericsson.com>
Cc: "Milo(Woogyom) Kim" <milo.kim@ti.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/leds/leds-lm3530.c

index 9f49d9550e8876e23c1da0d52355e0ce4965c743..968fd5fef4fc5e2871dc7b5539f80b6b5328ea1b 100644 (file)
@@ -160,9 +160,16 @@ static int lm3530_init_registers(struct lm3530_data *drvdata)
        gen_config = (pdata->brt_ramp_law << LM3530_RAMP_LAW_SHIFT) |
                        ((pdata->max_current & 7) << LM3530_MAX_CURR_SHIFT);
 
-       if (drvdata->mode == LM3530_BL_MODE_MANUAL ||
-           drvdata->mode == LM3530_BL_MODE_ALS)
-               gen_config |= (LM3530_ENABLE_I2C);
+       switch (drvdata->mode) {
+       case LM3530_BL_MODE_MANUAL:
+       case LM3530_BL_MODE_ALS:
+               gen_config |= LM3530_ENABLE_I2C;
+               break;
+       case LM3530_BL_MODE_PWM:
+               gen_config |= LM3530_ENABLE_PWM | LM3530_ENABLE_PWM_SIMPLE |
+                             (pdata->pwm_pol_hi << LM3530_PWM_POL_SHIFT);
+               break;
+       }
 
        if (drvdata->mode == LM3530_BL_MODE_ALS) {
                if (pdata->als_vmax == 0) {
@@ -196,11 +203,6 @@ static int lm3530_init_registers(struct lm3530_data *drvdata)
 
        }
 
-       if (drvdata->mode == LM3530_BL_MODE_PWM)
-               gen_config |= (LM3530_ENABLE_PWM) |
-                               (pdata->pwm_pol_hi << LM3530_PWM_POL_SHIFT) |
-                               (LM3530_ENABLE_PWM_SIMPLE);
-
        brt_ramp = (pdata->brt_ramp_fall << LM3530_BRT_RAMP_FALL_SHIFT) |
                        (pdata->brt_ramp_rise << LM3530_BRT_RAMP_RISE_SHIFT);