lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 10 Nov 2022 16:35:11 +0100
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Ben Dooks <ben.dooks@...ive.com>
Cc:     linux-pwm@...r.kernel.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org, Lee Jones <lee.jones@...aro.org>,
        Thierry Reding <thierry.reding@...il.com>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Greentime Hu <greentime.hu@...ive.com>,
        jarkko.nikula@...ux.intel.com,
        William Salmon <william.salmon@...ive.com>,
        Jude Onyenegecha <jude.onyenegecha@...ive.com>
Subject: Re: [PATCH v6 04/10] pwm: dwc: move memory alloc to own function

Hello,

On Thu, Oct 20, 2022 at 04:16:04PM +0100, 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@...ive.com>
> ---
>  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);

This was a pci_set_drvdata before. While it's common knowledge (and
implicitly used in several code parts) that pci_set_drvdata(pdev, data)
is just the same as dev_set_drvdata(&pdev->dev, data), it would be nice
if the driver only used either dev_[sg]et_drvdata or pci_[sg]et_drvdata.

Using the former in dwc_pwm_resume and dwc_pwm_suspend is even a tad
shorter.

Best regards
Uwe

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

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ