diff options
Diffstat (limited to 'drivers/input/misc/pwm-vibra.c')
| -rw-r--r-- | drivers/input/misc/pwm-vibra.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/input/misc/pwm-vibra.c b/drivers/input/misc/pwm-vibra.c index 55da191ae550..dbb6d9e1b947 100644 --- a/drivers/input/misc/pwm-vibra.c +++ b/drivers/input/misc/pwm-vibra.c | |||
| @@ -34,6 +34,7 @@ struct pwm_vibrator { | |||
| 34 | struct work_struct play_work; | 34 | struct work_struct play_work; |
| 35 | u16 level; | 35 | u16 level; |
| 36 | u32 direction_duty_cycle; | 36 | u32 direction_duty_cycle; |
| 37 | bool vcc_on; | ||
| 37 | }; | 38 | }; |
| 38 | 39 | ||
| 39 | static int pwm_vibrator_start(struct pwm_vibrator *vibrator) | 40 | static int pwm_vibrator_start(struct pwm_vibrator *vibrator) |
| @@ -42,10 +43,13 @@ static int pwm_vibrator_start(struct pwm_vibrator *vibrator) | |||
| 42 | struct pwm_state state; | 43 | struct pwm_state state; |
| 43 | int err; | 44 | int err; |
| 44 | 45 | ||
| 45 | err = regulator_enable(vibrator->vcc); | 46 | if (!vibrator->vcc_on) { |
| 46 | if (err) { | 47 | err = regulator_enable(vibrator->vcc); |
| 47 | dev_err(pdev, "failed to enable regulator: %d", err); | 48 | if (err) { |
| 48 | return err; | 49 | dev_err(pdev, "failed to enable regulator: %d", err); |
| 50 | return err; | ||
| 51 | } | ||
| 52 | vibrator->vcc_on = true; | ||
| 49 | } | 53 | } |
| 50 | 54 | ||
| 51 | pwm_get_state(vibrator->pwm, &state); | 55 | pwm_get_state(vibrator->pwm, &state); |
| @@ -76,11 +80,14 @@ static int pwm_vibrator_start(struct pwm_vibrator *vibrator) | |||
| 76 | 80 | ||
| 77 | static void pwm_vibrator_stop(struct pwm_vibrator *vibrator) | 81 | static void pwm_vibrator_stop(struct pwm_vibrator *vibrator) |
| 78 | { | 82 | { |
| 79 | regulator_disable(vibrator->vcc); | ||
| 80 | |||
| 81 | if (vibrator->pwm_dir) | 83 | if (vibrator->pwm_dir) |
| 82 | pwm_disable(vibrator->pwm_dir); | 84 | pwm_disable(vibrator->pwm_dir); |
| 83 | pwm_disable(vibrator->pwm); | 85 | pwm_disable(vibrator->pwm); |
| 86 | |||
| 87 | if (vibrator->vcc_on) { | ||
| 88 | regulator_disable(vibrator->vcc); | ||
| 89 | vibrator->vcc_on = false; | ||
| 90 | } | ||
| 84 | } | 91 | } |
| 85 | 92 | ||
| 86 | static void pwm_vibrator_play_work(struct work_struct *work) | 93 | static void pwm_vibrator_play_work(struct work_struct *work) |
