summaryrefslogtreecommitdiff
path: root/drivers/input/misc
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2015-01-10 04:43:06 +0300
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-01-12 02:52:59 +0300
commit3cb6dcfa44e883412f8df2f2b1917b0d359f3ec4 (patch)
tree5752ccd4871f825d4f89acaa3d26a9c3a74875ec /drivers/input/misc
parentf17effbe891624fe1ec2dcfa68625ed1c98ebe3a (diff)
downloadlinux-3cb6dcfa44e883412f8df2f2b1917b0d359f3ec4.tar.xz
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.c23
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,
return error;
}
+ regulator_haptic_toggle(haptic, !!magnitude);
+
return 0;
}
@@ -83,23 +85,12 @@ static void regulator_haptic_work(struct work_struct *work)
{
struct regulator_haptic *haptic = container_of(work,
struct regulator_haptic, work);
- unsigned int magnitude;
- int error;
mutex_lock(&haptic->mutex);
- if (haptic->suspended)
- goto out;
-
- magnitude = ACCESS_ONCE(haptic->magnitude);
+ if (!haptic->suspended)
+ regulator_haptic_set_voltage(haptic, haptic->magnitude);
- error = regulator_haptic_set_voltage(haptic, magnitude);
- if (error)
- goto out;
-
- regulator_haptic_toggle(haptic, magnitude != 0);
-
-out:
mutex_unlock(&haptic->mutex);
}
@@ -123,7 +114,6 @@ static void regulator_haptic_close(struct input_dev *input)
cancel_work_sync(&haptic->work);
regulator_haptic_set_voltage(haptic, 0);
- regulator_haptic_toggle(haptic, false);
}
static int __maybe_unused
@@ -225,7 +215,6 @@ static int __maybe_unused regulator_haptic_suspend(struct device *dev)
return error;
regulator_haptic_set_voltage(haptic, 0);
- regulator_haptic_toggle(haptic, false);
haptic->suspended = true;
@@ -245,10 +234,8 @@ static int __maybe_unused regulator_haptic_resume(struct device *dev)
haptic->suspended = false;
magnitude = ACCESS_ONCE(haptic->magnitude);
- if (magnitude) {
+ if (magnitude)
regulator_haptic_set_voltage(haptic, magnitude);
- regulator_haptic_toggle(haptic, true);
- }
mutex_unlock(&haptic->mutex);