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]
Date:   Fri, 3 Mar 2023 22:17:25 +0100
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Lorenz Brun <lorenz@...n.one>
Cc:     Thierry Reding <thierry.reding@...il.com>,
        Matthias Brugger <matthias.bgg@...il.com>,
        AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>,
        linux-pwm@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org
Subject: Re: [PATCH] pwm: mediatek: support inverted polarity

On Fri, Mar 03, 2023 at 09:58:21PM +0100, Lorenz Brun wrote:
> According to the MT7986 Reference Manual the Mediatek  PWM controller
> doesn't appear to have support for inverted polarity.
> 
> This implements the same solution as in pwm-meson and just inverts the
> duty cycle instead, which results in the same outcome.

This idea is broken. This was recently discussed on the linux-pwm list
and I hope will be fixed soon. See
https://lore.kernel.org/linux-pwm/20230228093911.bh2sbp4tyfir2z5g@pengutronix.de/T/#meda75ffbd4ef2048991ea2cd091c0c14b1bb09c2

So this patch won't be accepted, still pointing out a style problem
below.

> Signed-off-by: Lorenz Brun <lorenz@...n.one>
> ---
>  drivers/pwm/pwm-mediatek.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c
> index 5b5eeaff35da..6f4a54c8299f 100644
> --- a/drivers/pwm/pwm-mediatek.c
> +++ b/drivers/pwm/pwm-mediatek.c
> @@ -202,9 +202,7 @@ static int pwm_mediatek_apply(struct pwm_chip *chip, struct pwm_device *pwm,
>  			      const struct pwm_state *state)
>  {
>  	int err;
> -
> -	if (state->polarity != PWM_POLARITY_NORMAL)
> -		return -EINVAL;
> +	u64 duty_cycle;
>  
>  	if (!state->enabled) {
>  		if (pwm->state.enabled)
> @@ -213,7 +211,14 @@ static int pwm_mediatek_apply(struct pwm_chip *chip, struct pwm_device *pwm,
>  		return 0;
>  	}
>  
> -	err = pwm_mediatek_config(pwm->chip, pwm, state->duty_cycle, state->period);
> +	// According to the MT7986 Reference Manual the peripheral does not
> +	// appear to have the capability to invert the output. Instead just
> +	// invert the duty cycle.

Wrong commenting style, please stick to C-style comments (/* ... */)

> +	duty_cycle = state->duty_cycle;
> +	if (state->polarity == PWM_POLARITY_INVERSED)
> +		duty_cycle = state->period - state->duty_cycle;
> +
> +	err = pwm_mediatek_config(pwm->chip, pwm, duty_cycle, state->period);
>  	if (err)
>  		return err;

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ