From: Lee Jones <lee@kernel.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>,
kernel@pengutronix.de, Pavel Machek <pavel@ucw.cz>,
Conor Dooley <conor.dooley@microchip.com>,
Anjelique Melendez <quic_amelende@quicinc.com>,
Rob Herring <robh@kernel.org>,
Bjorn Andersson <quic_bjorande@quicinc.com>,
Kees Cook <keescook@chromium.org>, Luca Weiss <luca@z3ntu.xyz>,
linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org
Subject: Re: [PATCH v4 108/115] leds: qcom-lpg: Make use of devm_pwmchip_alloc() function
Date: Thu, 7 Dec 2023 17:05:09 +0000 [thread overview]
Message-ID: <20231207170509.GC111411@google.com> (raw)
In-Reply-To: <60605623e9e41d6f4b25e9c0eaf09d99bbc825f2.1701860672.git.u.kleine-koenig@pengutronix.de>
On Wed, 06 Dec 2023, Uwe Kleine-König wrote:
> This prepares the pwm sub-driver to further changes of the pwm core
> outlined in the commit introducing devm_pwmchip_alloc(). There is no
> intended semantical change and the driver should behave as before.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/leds/rgb/leds-qcom-lpg.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
Acked-by: Lee Jones <lee@kernel.org>
> diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
> index 156b73d1f4a2..0a7acf59a420 100644
> --- a/drivers/leds/rgb/leds-qcom-lpg.c
> +++ b/drivers/leds/rgb/leds-qcom-lpg.c
> @@ -77,7 +77,7 @@ struct lpg {
>
> struct mutex lock;
>
> - struct pwm_chip pwm;
> + struct pwm_chip *pwm;
>
> const struct lpg_data *data;
>
> @@ -978,7 +978,7 @@ static int lpg_pattern_mc_clear(struct led_classdev *cdev)
>
> static inline struct lpg *lpg_pwm_from_chip(struct pwm_chip *chip)
> {
> - return container_of(chip, struct lpg, pwm);
> + return pwmchip_get_drvdata(chip);
> }
>
> static int lpg_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
> @@ -1093,13 +1093,17 @@ static const struct pwm_ops lpg_pwm_ops = {
>
> static int lpg_add_pwm(struct lpg *lpg)
> {
> + struct pwm_chip *chip;
> int ret;
>
> - lpg->pwm.dev = lpg->dev;
> - lpg->pwm.npwm = lpg->num_channels;
> - lpg->pwm.ops = &lpg_pwm_ops;
> + lpg->pwm = chip = devm_pwmchip_alloc(lpg->dev, lpg->num_channels, 0);
> + if (IS_ERR(chip))
> + return PTR_ERR(chip);
>
> - ret = devm_pwmchip_add(lpg->dev, &lpg->pwm);
> + chip->ops = &lpg_pwm_ops;
> + pwmchip_set_drvdata(chip, lpg);
> +
> + ret = devm_pwmchip_add(lpg->dev, chip);
> if (ret)
> dev_err_probe(lpg->dev, ret, "failed to add PWM chip\n");
>
> --
> 2.42.0
>
--
Lee Jones [李琼斯]
next prev parent reply other threads:[~2023-12-07 17:05 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-06 11:43 [PATCH v4 000/115] pwm: Fix lifetime issues for pwm_chips Uwe Kleine-König
2023-12-06 11:43 ` [PATCH v4 003/115] leds: qcom-lpg: Use devm_pwmchip_add() simplifying driver removal Uwe Kleine-König
2023-12-07 17:06 ` Lee Jones
2023-12-07 17:58 ` Uwe Kleine-König
2023-12-13 15:48 ` Lee Jones
2023-12-13 15:51 ` (subset) " Lee Jones
2023-12-06 11:43 ` [PATCH v4 004/115] leds: qcom-lpg: Consistenly use dev_err_probe() in .probe()'s error path Uwe Kleine-König
2023-12-07 17:06 ` Lee Jones
2023-12-13 15:50 ` Lee Jones
2023-12-06 11:43 ` [PATCH v4 005/115] leds: qcom-lpg: Introduce a wrapper for getting driver data from a pwm chip Uwe Kleine-König
2023-12-07 17:05 ` Lee Jones
2023-12-13 15:51 ` (subset) " Lee Jones
2023-12-06 11:45 ` [PATCH v4 108/115] leds: qcom-lpg: Make use of devm_pwmchip_alloc() function Uwe Kleine-König
2023-12-07 17:05 ` Lee Jones [this message]
2023-12-08 15:41 ` [PATCH v4 000/115] pwm: Fix lifetime issues for pwm_chips Thierry Reding
2023-12-08 18:50 ` Uwe Kleine-König
2023-12-11 11:33 ` Thierry Reding
2023-12-11 12:18 ` Uwe Kleine-König
2023-12-12 21:05 ` Uwe Kleine-König
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=20231207170509.GC111411@google.com \
--to=lee@kernel.org \
--cc=conor.dooley@microchip.com \
--cc=keescook@chromium.org \
--cc=kernel@pengutronix.de \
--cc=linux-leds@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=luca@z3ntu.xyz \
--cc=pavel@ucw.cz \
--cc=quic_amelende@quicinc.com \
--cc=quic_bjorande@quicinc.com \
--cc=robh@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).