From: Conor Dooley <conor@kernel.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Conor Dooley <conor.dooley@microchip.com>,
Daire McNamara <daire.mcnamara@microchip.com>,
Thierry Reding <thierry.reding@gmail.com>,
linux-riscv@lists.infradead.org, linux-pwm@vger.kernel.org,
kernel@pengutronix.de
Subject: Re: [PATCH v3 070/108] pwm: microchip-core: Make use of devm_pwmchip_alloc() function
Date: Wed, 22 Nov 2023 11:14:21 +0000 [thread overview]
Message-ID: <20231122-endanger-extenuate-97ef77b117da@spud> (raw)
In-Reply-To: <20231121134901.208535-71-u.kleine-koenig@pengutronix.de>
[-- Attachment #1.1: Type: text/plain, Size: 3213 bytes --]
On Tue, Nov 21, 2023 at 02:50:12PM +0100, Uwe Kleine-König wrote:
> This prepares the pwm-microchip-core 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/pwm/pwm-microchip-core.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/pwm/pwm-microchip-core.c b/drivers/pwm/pwm-microchip-core.c
> index c0c53968f3e9..6e0c2cbfc120 100644
> --- a/drivers/pwm/pwm-microchip-core.c
> +++ b/drivers/pwm/pwm-microchip-core.c
> @@ -54,7 +54,6 @@
> #define MCHPCOREPWM_TIMEOUT_MS 100u
>
> struct mchp_core_pwm_chip {
> - struct pwm_chip chip;
> struct clk *clk;
> void __iomem *base;
> struct mutex lock; /* protects the shared period */
> @@ -65,7 +64,7 @@ struct mchp_core_pwm_chip {
>
> static inline struct mchp_core_pwm_chip *to_mchp_core_pwm(struct pwm_chip *chip)
> {
> - return container_of(chip, struct mchp_core_pwm_chip, chip);
> + return pwmchip_priv(chip);
> }
I know this is likely a coccinelle job, but can we now delete things
like to_mchp_core_pwm() if there's a standard helper for this now?
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Cheers,
Conor.
> static void mchp_core_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm,
> @@ -447,13 +446,15 @@ MODULE_DEVICE_TABLE(of, mchp_core_of_match);
>
> static int mchp_core_pwm_probe(struct platform_device *pdev)
> {
> + struct pwm_chip *chip;
> struct mchp_core_pwm_chip *mchp_core_pwm;
> struct resource *regs;
> int ret;
>
> - mchp_core_pwm = devm_kzalloc(&pdev->dev, sizeof(*mchp_core_pwm), GFP_KERNEL);
> - if (!mchp_core_pwm)
> - return -ENOMEM;
> + chip = devm_pwmchip_alloc(&pdev->dev, 16, sizeof(*mchp_core_pwm));
> + if (IS_ERR(chip))
> + return PTR_ERR(chip);
> + mchp_core_pwm = to_mchp_core_pwm(chip);
>
> mchp_core_pwm->base = devm_platform_get_and_ioremap_resource(pdev, 0, ®s);
> if (IS_ERR(mchp_core_pwm->base))
> @@ -470,9 +471,7 @@ static int mchp_core_pwm_probe(struct platform_device *pdev)
>
> mutex_init(&mchp_core_pwm->lock);
>
> - mchp_core_pwm->chip.dev = &pdev->dev;
> - mchp_core_pwm->chip.ops = &mchp_core_pwm_ops;
> - mchp_core_pwm->chip.npwm = 16;
> + chip->ops = &mchp_core_pwm_ops;
>
> mchp_core_pwm->channel_enabled = readb_relaxed(mchp_core_pwm->base + MCHPCOREPWM_EN(0));
> mchp_core_pwm->channel_enabled |=
> @@ -485,7 +484,7 @@ static int mchp_core_pwm_probe(struct platform_device *pdev)
> writel_relaxed(1U, mchp_core_pwm->base + MCHPCOREPWM_SYNC_UPD);
> mchp_core_pwm->update_timestamp = ktime_get();
>
> - ret = devm_pwmchip_add(&pdev->dev, &mchp_core_pwm->chip);
> + ret = devm_pwmchip_add(&pdev->dev, chip);
> if (ret)
> return dev_err_probe(&pdev->dev, ret, "Failed to add pwmchip\n");
>
> --
> 2.42.0
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 161 bytes --]
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2023-11-22 11:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-21 13:49 [PATCH v3 000/108] pwm: Fix lifetime issues for pwm_chips Uwe Kleine-König
2023-11-21 13:49 ` [PATCH v3 026/108] pwm: sifive: Make use of pwmchip_parent() macro Uwe Kleine-König
2023-11-21 13:50 ` [PATCH v3 070/108] pwm: microchip-core: Make use of devm_pwmchip_alloc() function Uwe Kleine-König
2023-11-22 11:14 ` Conor Dooley [this message]
2023-11-22 22:48 ` Uwe Kleine-König
2023-11-21 13:50 ` [PATCH v3 083/108] pwm: sifive: " 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=20231122-endanger-extenuate-97ef77b117da@spud \
--to=conor@kernel.org \
--cc=conor.dooley@microchip.com \
--cc=daire.mcnamara@microchip.com \
--cc=kernel@pengutronix.de \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-riscv@lists.infradead.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