diff options
| author | Axel Lin <axel.lin@ingics.com> | 2015-01-09 20:43:06 -0500 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2015-01-11 18:52:59 -0500 |
| commit | 3cb6dcfa44e883412f8df2f2b1917b0d359f3ec4 (patch) | |
| tree | 5752ccd4871f825d4f89acaa3d26a9c3a74875ec /drivers/input/misc | |
| parent | f17effbe891624fe1ec2dcfa68625ed1c98ebe3a (diff) | |
Input: regulator-haptic - simplify code
All the use cases in this driver has a regulator_haptic_toggle() call after
regulator_haptic_set_voltage(). So make regulator_haptic_set_voltage() call
regulator_haptic_toggle() to simplify the code.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/misc')
| -rw-r--r-- | drivers/input/misc/regulator-haptic.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/drivers/input/misc/regulator-haptic.c b/drivers/input/misc/regulator-haptic.c index 942622189bee..132eb914ea3e 100644 --- a/drivers/input/misc/regulator-haptic.c +++ b/drivers/input/misc/regulator-haptic.c | |||
| @@ -76,6 +76,8 @@ static int regulator_haptic_set_voltage(struct regulator_haptic *haptic, | |||
| 76 | return error; | 76 | return error; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | regulator_haptic_toggle(haptic, !!magnitude); | ||
| 80 | |||
| 79 | return 0; | 81 | return 0; |
| 80 | } | 82 | } |
| 81 | 83 | ||
| @@ -83,23 +85,12 @@ static void regulator_haptic_work(struct work_struct *work) | |||
| 83 | { | 85 | { |
| 84 | struct regulator_haptic *haptic = container_of(work, | 86 | struct regulator_haptic *haptic = container_of(work, |
| 85 | struct regulator_haptic, work); | 87 | struct regulator_haptic, work); |
| 86 | unsigned int magnitude; | ||
| 87 | int error; | ||
| 88 | 88 | ||
| 89 | mutex_lock(&haptic->mutex); | 89 | mutex_lock(&haptic->mutex); |
| 90 | 90 | ||
| 91 | if (haptic->suspended) | 91 | if (!haptic->suspended) |
| 92 | goto out; | 92 | regulator_haptic_set_voltage(haptic, haptic->magnitude); |
| 93 | |||
| 94 | magnitude = ACCESS_ONCE(haptic->magnitude); | ||
| 95 | 93 | ||
| 96 | error = regulator_haptic_set_voltage(haptic, magnitude); | ||
| 97 | if (error) | ||
| 98 | goto out; | ||
| 99 | |||
| 100 | regulator_haptic_toggle(haptic, magnitude != 0); | ||
| 101 | |||
| 102 | out: | ||
| 103 | mutex_unlock(&haptic->mutex); | 94 | mutex_unlock(&haptic->mutex); |
| 104 | } | 95 | } |
| 105 | 96 | ||
| @@ -123,7 +114,6 @@ static void regulator_haptic_close(struct input_dev *input) | |||
| 123 | 114 | ||
| 124 | cancel_work_sync(&haptic->work); | 115 | cancel_work_sync(&haptic->work); |
| 125 | regulator_haptic_set_voltage(haptic, 0); | 116 | regulator_haptic_set_voltage(haptic, 0); |
| 126 | regulator_haptic_toggle(haptic, false); | ||
| 127 | } | 117 | } |
| 128 | 118 | ||
| 129 | static int __maybe_unused | 119 | static int __maybe_unused |
| @@ -225,7 +215,6 @@ static int __maybe_unused regulator_haptic_suspend(struct device *dev) | |||
| 225 | return error; | 215 | return error; |
| 226 | 216 | ||
| 227 | regulator_haptic_set_voltage(haptic, 0); | 217 | regulator_haptic_set_voltage(haptic, 0); |
| 228 | regulator_haptic_toggle(haptic, false); | ||
| 229 | 218 | ||
| 230 | haptic->suspended = true; | 219 | haptic->suspended = true; |
| 231 | 220 | ||
| @@ -245,10 +234,8 @@ static int __maybe_unused regulator_haptic_resume(struct device *dev) | |||
| 245 | haptic->suspended = false; | 234 | haptic->suspended = false; |
| 246 | 235 | ||
| 247 | magnitude = ACCESS_ONCE(haptic->magnitude); | 236 | magnitude = ACCESS_ONCE(haptic->magnitude); |
| 248 | if (magnitude) { | 237 | if (magnitude) |
| 249 | regulator_haptic_set_voltage(haptic, magnitude); | 238 | regulator_haptic_set_voltage(haptic, magnitude); |
| 250 | regulator_haptic_toggle(haptic, true); | ||
| 251 | } | ||
| 252 | 239 | ||
| 253 | mutex_unlock(&haptic->mutex); | 240 | mutex_unlock(&haptic->mutex); |
| 254 | 241 | ||
