diff mbox series

Input: max77693 - Simplify suspend/resume handling

Message ID 20250623110016.1370622-2-u.kleine-koenig@baylibre.com
State New
Headers show
Series Input: max77693 - Simplify suspend/resume handling | expand

Commit Message

Uwe Kleine-König June 23, 2025, 11 a.m. UTC
max77693_haptic_disable() is a noop if !haptic->enabled, so it can be
called unconditionally in max77693_haptic_suspend().

haptic->suspend_state can only be true in max77693_haptic_resume() if
haptic->enabled is also true. In this case max77693_haptic_enable() is
a noop and the call can be dropped.

After these simplifications haptic->suspend_state is essentially a
write-only variable and so can be dropped, too.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
Hello,

found that simplification while trying to understand the driver enough
to improve the PWM handling. Not sure that the result is what is
intended, but if you think the new behaviour is bogus then so is the
status quo, just better hidden.

Best regards
Uwe

 drivers/input/misc/max77693-haptic.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)


base-commit: f817b6dd2b62d921a6cdc0a3ac599cd1851f343c
diff mbox series

Patch

diff --git a/drivers/input/misc/max77693-haptic.c b/drivers/input/misc/max77693-haptic.c
index 1dfd7b95a4ce..abbc47a0d73c 100644
--- a/drivers/input/misc/max77693-haptic.c
+++ b/drivers/input/misc/max77693-haptic.c
@@ -57,7 +57,6 @@  struct max77693_haptic {
 	struct regulator *motor_reg;
 
 	bool enabled;
-	bool suspend_state;
 	unsigned int magnitude;
 	unsigned int pwm_duty;
 	enum max77693_haptic_motor_type type;
@@ -313,7 +312,6 @@  static int max77693_haptic_probe(struct platform_device *pdev)
 	haptic->dev = &pdev->dev;
 	haptic->type = MAX77693_HAPTIC_LRA;
 	haptic->mode = MAX77693_HAPTIC_EXTERNAL_MODE;
-	haptic->suspend_state = false;
 
 	/* Variant-specific init */
 	haptic->dev_type = max77693->type;
@@ -390,23 +388,7 @@  static int max77693_haptic_suspend(struct device *dev)
 	struct platform_device *pdev = to_platform_device(dev);
 	struct max77693_haptic *haptic = platform_get_drvdata(pdev);
 
-	if (haptic->enabled) {
-		max77693_haptic_disable(haptic);
-		haptic->suspend_state = true;
-	}
-
-	return 0;
-}
-
-static int max77693_haptic_resume(struct device *dev)
-{
-	struct platform_device *pdev = to_platform_device(dev);
-	struct max77693_haptic *haptic = platform_get_drvdata(pdev);
-
-	if (haptic->suspend_state) {
-		max77693_haptic_enable(haptic);
-		haptic->suspend_state = false;
-	}
+	max77693_haptic_disable(haptic);
 
 	return 0;
 }