lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230429194729.xuw7ircyuyabv32w@mercury.elektranox.org>
Date:   Sat, 29 Apr 2023 21:47:29 +0200
From:   Sebastian Reichel <sre@...nel.org>
To:     Luca Weiss <luca@...tu.xyz>
Cc:     ~postmarketos/upstreaming@...ts.sr.ht, phone-devel@...r.kernel.org,
        Dmitry Torokhov <dmitry.torokhov@...il.com>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Andy Gross <agross@...nel.org>,
        Bjorn Andersson <andersson@...nel.org>,
        Konrad Dybcio <konrad.dybcio@...aro.org>,
        Brian Masney <masneyb@...tation.org>,
        linux-input@...r.kernel.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org
Subject: Re: [PATCH 3/4] Input: pwm-vibra - add support for enable GPIO

Hi,

On Thu, Apr 27, 2023 at 10:34:28PM +0200, Luca Weiss wrote:
> Some pwm vibrators have a dedicated enable GPIO that needs to be set
> high so that the vibrator works. Add support for that optionally.
> 
> Signed-off-by: Luca Weiss <luca@...tu.xyz>
> ---

Reviewed-by: Sebastian Reichel <sre@...nel.org>

-- Sebastian

>  drivers/input/misc/pwm-vibra.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/input/misc/pwm-vibra.c b/drivers/input/misc/pwm-vibra.c
> index c08971c97ad6..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 <lars@...afoo.de>
>   */
>  
> +#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;
> @@ -48,6 +50,8 @@ static int pwm_vibrator_start(struct pwm_vibrator *vibrator)
>  		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;
> @@ -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;
> @@ -142,6 +148,16 @@ static int pwm_vibrator_probe(struct platform_device *pdev)
>  		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;
> +	}
> +
>  	vibrator->pwm = devm_pwm_get(&pdev->dev, "enable");
>  	err = PTR_ERR_OR_ZERO(vibrator->pwm);
>  	if (err) {
> 
> -- 
> 2.40.0
> 

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ