diff options
| author | Dmitry Torokhov <[email protected]> | 2023-06-26 15:18:13 -0700 | 
|---|---|---|
| committer | Dmitry Torokhov <[email protected]> | 2023-06-26 15:18:13 -0700 | 
| commit | bf4ed21778f2920ca91a32fd3a1e1130e843e98f (patch) | |
| tree | efb126e6d74ff3ff83913406de136305050c8a80 /drivers/input/misc/pwm-vibra.c | |
| parent | feee70f4568650cf44c573488798ffc0a2faeea3 (diff) | |
| parent | 8c9cce9cb81b5fdc6e66bf3f129727b89e8daab7 (diff) | |
Merge branch 'next' into for-linus
Prepare input updates for 6.5 merge window.
Diffstat (limited to 'drivers/input/misc/pwm-vibra.c')
| -rw-r--r-- | drivers/input/misc/pwm-vibra.c | 36 | 
1 files changed, 26 insertions, 10 deletions
diff --git a/drivers/input/misc/pwm-vibra.c b/drivers/input/misc/pwm-vibra.c index d0e58a7cdfa3..2ba035299db8 100644 --- a/drivers/input/misc/pwm-vibra.c +++ b/drivers/input/misc/pwm-vibra.c @@ -11,6 +11,7 @@   *  Copyright (C) 2010, Lars-Peter Clausen <[email protected]>   */ +#include <linux/gpio/consumer.h>  #include <linux/input.h>  #include <linux/kernel.h>  #include <linux/module.h> @@ -23,6 +24,7 @@  struct pwm_vibrator {  	struct input_dev *input; +	struct gpio_desc *enable_gpio;  	struct pwm_device *pwm;  	struct pwm_device *pwm_dir;  	struct regulator *vcc; @@ -42,19 +44,21 @@ static int pwm_vibrator_start(struct pwm_vibrator *vibrator)  	if (!vibrator->vcc_on) {  		err = regulator_enable(vibrator->vcc);  		if (err) { -			dev_err(pdev, "failed to enable regulator: %d", err); +			dev_err(pdev, "failed to enable regulator: %d\n", err);  			return err;  		}  		vibrator->vcc_on = true;  	} +	gpiod_set_value_cansleep(vibrator->enable_gpio, 1); +  	pwm_get_state(vibrator->pwm, &state);  	pwm_set_relative_duty_cycle(&state, vibrator->level, 0xffff);  	state.enabled = true;  	err = pwm_apply_state(vibrator->pwm, &state);  	if (err) { -		dev_err(pdev, "failed to apply pwm state: %d", err); +		dev_err(pdev, "failed to apply pwm state: %d\n", err);  		return err;  	} @@ -65,7 +69,7 @@ static int pwm_vibrator_start(struct pwm_vibrator *vibrator)  		err = pwm_apply_state(vibrator->pwm_dir, &state);  		if (err) { -			dev_err(pdev, "failed to apply dir-pwm state: %d", err); +			dev_err(pdev, "failed to apply dir-pwm state: %d\n", err);  			pwm_disable(vibrator->pwm);  			return err;  		} @@ -80,6 +84,8 @@ static void pwm_vibrator_stop(struct pwm_vibrator *vibrator)  		pwm_disable(vibrator->pwm_dir);  	pwm_disable(vibrator->pwm); +	gpiod_set_value_cansleep(vibrator->enable_gpio, 0); +  	if (vibrator->vcc_on) {  		regulator_disable(vibrator->vcc);  		vibrator->vcc_on = false; @@ -137,7 +143,17 @@ static int pwm_vibrator_probe(struct platform_device *pdev)  	err = PTR_ERR_OR_ZERO(vibrator->vcc);  	if (err) {  		if (err != -EPROBE_DEFER) -			dev_err(&pdev->dev, "Failed to request regulator: %d", +			dev_err(&pdev->dev, "Failed to request regulator: %d\n", +				err); +		return err; +	} + +	vibrator->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", +							GPIOD_OUT_LOW); +	err = PTR_ERR_OR_ZERO(vibrator->enable_gpio); +	if (err) { +		if (err != -EPROBE_DEFER) +			dev_err(&pdev->dev, "Failed to request enable gpio: %d\n",  				err);  		return err;  	} @@ -146,7 +162,7 @@ static int pwm_vibrator_probe(struct platform_device *pdev)  	err = PTR_ERR_OR_ZERO(vibrator->pwm);  	if (err) {  		if (err != -EPROBE_DEFER) -			dev_err(&pdev->dev, "Failed to request main pwm: %d", +			dev_err(&pdev->dev, "Failed to request main pwm: %d\n",  				err);  		return err;  	} @@ -158,7 +174,7 @@ static int pwm_vibrator_probe(struct platform_device *pdev)  	state.enabled = false;  	err = pwm_apply_state(vibrator->pwm, &state);  	if (err) { -		dev_err(&pdev->dev, "failed to apply initial PWM state: %d", +		dev_err(&pdev->dev, "failed to apply initial PWM state: %d\n",  			err);  		return err;  	} @@ -172,7 +188,7 @@ static int pwm_vibrator_probe(struct platform_device *pdev)  		state.enabled = false;  		err = pwm_apply_state(vibrator->pwm_dir, &state);  		if (err) { -			dev_err(&pdev->dev, "failed to apply initial PWM state: %d", +			dev_err(&pdev->dev, "failed to apply initial PWM state: %d\n",  				err);  			return err;  		} @@ -189,7 +205,7 @@ static int pwm_vibrator_probe(struct platform_device *pdev)  		break;  	default: -		dev_err(&pdev->dev, "Failed to request direction pwm: %d", err); +		dev_err(&pdev->dev, "Failed to request direction pwm: %d\n", err);  		fallthrough;  	case -EPROBE_DEFER: @@ -207,13 +223,13 @@ static int pwm_vibrator_probe(struct platform_device *pdev)  	err = input_ff_create_memless(vibrator->input, NULL,  				      pwm_vibrator_play_effect);  	if (err) { -		dev_err(&pdev->dev, "Couldn't create FF dev: %d", err); +		dev_err(&pdev->dev, "Couldn't create FF dev: %d\n", err);  		return err;  	}  	err = input_register_device(vibrator->input);  	if (err) { -		dev_err(&pdev->dev, "Couldn't register input dev: %d", err); +		dev_err(&pdev->dev, "Couldn't register input dev: %d\n", err);  		return err;  	}  |