Re: [PATCH v7 04/10] pwm: dwc: move memory alloc to own function

From: Uwe Kleine-König
Date: Thu Feb 16 2023 - 16:19:41 EST


On Fri, Dec 23, 2022 at 03:38:14PM +0000, Ben Dooks wrote:
> In preparation for adding other bus support, move the allocation
> of the pwm struct out of the main driver code.
>
> Signed-off-by: Ben Dooks <ben.dooks@xxxxxxxxxx>
> ---
> drivers/pwm/pwm-dwc.c | 24 +++++++++++++++++-------
> 1 file changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c
> index c706ef9a7ba1..61f11e0a9319 100644
> --- a/drivers/pwm/pwm-dwc.c
> +++ b/drivers/pwm/pwm-dwc.c
> @@ -196,13 +196,29 @@ static const struct pwm_ops dwc_pwm_ops = {
> .owner = THIS_MODULE,
> };
>
> +static struct dwc_pwm *dwc_pwm_alloc(struct device *dev)
> +{
> + struct dwc_pwm *dwc;
> +
> + dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL);
> + if (!dwc)
> + return NULL;
> +
> + dwc->chip.dev = dev;
> + dwc->chip.ops = &dwc_pwm_ops;
> + dwc->chip.npwm = DWC_TIMERS_TOTAL;
> +
> + dev_set_drvdata(dev, dwc);

I don't particularily like that this dev_set_drvdata is matched by
pci_get_drvdata in .remove(), but this isn't going to break I guess. So:

Acked-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |

Attachment: signature.asc
Description: PGP signature