Linux PWM subsystem development
 help / color / mirror / Atom feed
From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	linux-pwm@vger.kernel.org
Subject: Re: [PATCH 1/4] pwm: Read initial hardware state at request time
Date: Mon, 21 Oct 2019 15:46:22 +0200	[thread overview]
Message-ID: <121ab7d5-831c-5298-c747-b231e1e361ba@collabora.com> (raw)
In-Reply-To: <20191021105739.1357629-1-thierry.reding@gmail.com>

Hi,

On 21/10/19 12:57, Thierry Reding wrote:
> The PWM core doesn't need to know about the hardware state of a PWM
> unless there is a user for it. Defer initial hardware readout until
> a PWM is requested.
> 
> As a side-effect, this allows the ->get_state() callback to rely on
> per-PWM data.
> 
> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>

Tested on top of 5.4.0-rc4 with 2/4 applied this patch fixes the NULL pointer
dereference as expected. So,

Tested-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>

Thanks,
 Enric

> ---
>  drivers/pwm/core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index f877e77d9184..e067873c6cc5 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -114,6 +114,9 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label)
>  		}
>  	}
>  
> +	if (pwm->chip->ops->get_state)
> +		pwm->chip->ops->get_state(pwm->chip, pwm, &pwm->state);
> +
>  	set_bit(PWMF_REQUESTED, &pwm->flags);
>  	pwm->label = label;
>  
> @@ -283,9 +286,6 @@ int pwmchip_add_with_polarity(struct pwm_chip *chip,
>  		pwm->hwpwm = i;
>  		pwm->state.polarity = polarity;
>  
> -		if (chip->ops->get_state)
> -			chip->ops->get_state(chip, pwm, &pwm->state);
> -
>  		radix_tree_insert(&pwm_tree, pwm->pwm, pwm);
>  	}
>  
> 

      parent reply	other threads:[~2019-10-21 13:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-21 10:57 [PATCH 1/4] pwm: Read initial hardware state at request time Thierry Reding
2019-10-21 10:57 ` [PATCH 2/4] pwm: cros-ec: Cache duty cycle value Thierry Reding
2019-10-21 13:48   ` Enric Balletbo i Serra
2019-12-05  7:12     ` Uwe Kleine-König
2019-10-21 10:57 ` [PATCH 3/4] pwm: imx27: Cache duty cycle register value Thierry Reding
2019-10-21 13:46   ` Michal Vokáč
2019-10-21 14:21     ` Adam Ford
2019-10-21 10:57 ` [PATCH 4/4] pwm: imx27: Unconditionally write state to hardware Thierry Reding
2019-10-21 13:49   ` Michal Vokáč
2019-10-21 14:21     ` Adam Ford
2019-10-21 11:11 ` [PATCH 1/4] pwm: Read initial hardware state at request time Uwe Kleine-König
2019-10-21 14:27   ` Thierry Reding
2019-10-21 13:34 ` Michal Vokáč
2019-10-21 13:46 ` Enric Balletbo i Serra [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=121ab7d5-831c-5298-c747-b231e1e361ba@collabora.com \
    --to=enric.balletbo@collabora.com \
    --cc=linux-pwm@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox