linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michal Vokáč" <michal.vokac@ysoft.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Enric Balletbo i Serra" <enric.balletbo@collabora.com>,
	linux-pwm@vger.kernel.org
Subject: Re: [PATCH 1/4] pwm: Read initial hardware state at request time
Date: Mon, 21 Oct 2019 15:34:52 +0200	[thread overview]
Message-ID: <85480416-635e-3f88-d0d4-38bb0f1755da@ysoft.com> (raw)
In-Reply-To: <20191021105739.1357629-1-thierry.reding@gmail.com>

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.

I tried this on top of v5.4-rc3 on imx6dl-yapp4-draco with pwm-backlight
consumer and on imx6dl-yapp4-hydra with PWM from sysfs and I do not see
any obvious problems.

Tested-by: Michal Vokáč <michal.vokac@ysoft.com>

> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
> ---
>   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:34 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áč [this message]
2019-10-21 13:46 ` Enric Balletbo i Serra

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=85480416-635e-3f88-d0d4-38bb0f1755da@ysoft.com \
    --to=michal.vokac@ysoft.com \
    --cc=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;
as well as URLs for NNTP newsgroup(s).