Merge branch 'next' into for-linus
[sfrench/cifs-2.6.git] / drivers / input / misc / max8997_haptic.c
index 20ff087b8a44309801a05706048b926e961319f8..cd5e99ec1d3c882fa2b0279cedc479b994bc165a 100644 (file)
@@ -61,15 +61,10 @@ static int max8997_haptic_set_duty_cycle(struct max8997_haptic *chip)
                unsigned int duty = chip->pwm_period * chip->level / 100;
                ret = pwm_config(chip->pwm, duty, chip->pwm_period);
        } else {
-               int i;
                u8 duty_index = 0;
 
-               for (i = 0; i <= 64; i++) {
-                       if (chip->level <= i * 100 / 64) {
-                               duty_index = i;
-                               break;
-                       }
-               }
+               duty_index = DIV_ROUND_UP(chip->level * 64, 100);
+
                switch (chip->internal_mode_pattern) {
                case 0:
                        max8997_write_reg(chip->client,