mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Michael Hennerich" <michael.hennerich@analog.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Trevor Gamblin" <tgamblin@baylibre.com>
Cc: linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pwm: axi-pwmgen: Create a dedicated function for getting driver data from a chip
Date: Tue, 24 Sep 2024 09:07:34 +0200	[thread overview]
Message-ID: <2bf20010512ce94c117cb0e58313e72c7772d3c5.camel@gmail.com> (raw)
In-Reply-To: <20240923125418.16558-2-u.kleine-koenig@baylibre.com>

On Mon, 2024-09-23 at 14:54 +0200, Uwe Kleine-König wrote:
> Compared to direct calls to pwmchip_get_drvdata() a dedicated function
> has two upsides: A better name and the right type. So the code becomes
> easier to read and the new function is harder to use wrongly.
> 
> Another side effect (which is the secret motivation for this patch, but
> shhh) is that the driver becomes a bit easier to backport to kernel
> versions that don't have devm_pwmchip_alloc() yet.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> ---

Reviewed-by: Nuno Sa <nuno.sa@analog.com>

>  drivers/pwm/pwm-axi-pwmgen.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-axi-pwmgen.c b/drivers/pwm/pwm-axi-pwmgen.c
> index b5477659ba18..e5162f3e511e 100644
> --- a/drivers/pwm/pwm-axi-pwmgen.c
> +++ b/drivers/pwm/pwm-axi-pwmgen.c
> @@ -53,10 +53,15 @@ static const struct regmap_config axi_pwmgen_regmap_config = {
>  	.max_register = 0xFC,
>  };
>  
> +static struct axi_pwmgen_ddata axi_pwmgen_ddata_from_chip(struct pwm_chip *chip)
> +{
> +	return pwmchip_get_drvdata(chip);
> +}
> +
>  static int axi_pwmgen_apply(struct pwm_chip *chip, struct pwm_device *pwm,
>  			    const struct pwm_state *state)
>  {
> -	struct axi_pwmgen_ddata *ddata = pwmchip_get_drvdata(chip);
> +	struct axi_pwmgen_ddata *ddata = axi_pwmgen_ddata_from_chip(chip);
>  	unsigned int ch = pwm->hwpwm;
>  	struct regmap *regmap = ddata->regmap;
>  	u64 period_cnt, duty_cnt;
> @@ -100,7 +105,7 @@ static int axi_pwmgen_apply(struct pwm_chip *chip, struct
> pwm_device *pwm,
>  static int axi_pwmgen_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
>  				struct pwm_state *state)
>  {
> -	struct axi_pwmgen_ddata *ddata = pwmchip_get_drvdata(chip);
> +	struct axi_pwmgen_ddata *ddata = axi_pwmgen_ddata_from_chip(chip);
>  	struct regmap *regmap = ddata->regmap;
>  	unsigned int ch = pwm->hwpwm;
>  	u32 cnt;
> 
> base-commit: 62f92d634458a1e308bb699986b9147a6d670457


  parent reply	other threads:[~2024-09-24  7:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-23 12:54 Uwe Kleine-König
2024-09-23 12:56 ` Trevor Gamblin
2024-09-24  7:07 ` Nuno Sá [this message]
2024-09-25 12:41 ` kernel test robot
2024-09-25 15:00   ` Uwe Kleine-König
2024-09-25 15:24 ` Uwe Kleine-König
2024-09-25 15:47 ` kernel test robot

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=2bf20010512ce94c117cb0e58313e72c7772d3c5.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    --cc=nuno.sa@analog.com \
    --cc=tgamblin@baylibre.com \
    --cc=u.kleine-koenig@baylibre.com \
    /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

all inboxes | Powered by JetHome®