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: Mon, 18 Dec 2023 10:31:36 +0100
From: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To: Sean Young <sean@...s.org>
Cc: linux-media@...r.kernel.org, linux-pwm@...r.kernel.org, 
	Ivaylo Dimitrov <ivo.g.dimitrov.75@...il.com>, Thierry Reding <thierry.reding@...il.com>, 
	Florian Fainelli <florian.fainelli@...adcom.com>, Ray Jui <rjui@...adcom.com>, 
	Scott Branden <sbranden@...adcom.com>, 
	Broadcom internal kernel review list <bcm-kernel-feedback-list@...adcom.com>, linux-rpi-kernel@...ts.infradead.org, 
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v9 5/6] pwm: bcm2835: Allow PWM driver to be used in
 atomic context

Hello Sean,

On Mon, Dec 18, 2023 at 09:06:46AM +0000, Sean Young wrote:
> @@ -151,16 +146,40 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
>  		return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk),
>  				     "clock not found\n");
>  
> +	ret = clk_rate_exclusive_get(pc->clk);
> +	if (ret)
> +		return dev_err_probe(&pdev->dev, ret,
> +				     "fail to get exclusive rate\n");

If Maxime didn't object to my series at
https://lore.kernel.org/linux-clk/cover.1702400947.git.u.kleine-koenig@pengutronix.de/,
I'd ask you to not do error checking here. With the objection I hesitate
to ask for that and just mention it.

> +	pc->rate = clk_get_rate(pc->clk);
> +	if (!pc->rate) {
> +		clk_rate_exclusive_put(pc->clk);
> +		return dev_err_probe(&pdev->dev, -EINVAL,
> +				     "failed to get clock rate\n");
> +	}
> +
>  	pc->chip.dev = &pdev->dev;
>  	pc->chip.ops = &bcm2835_pwm_ops;
> +	pc->chip.atomic = true;
>  	pc->chip.npwm = 2;
>  
>  	platform_set_drvdata(pdev, pc);
>  
>  	ret = devm_pwmchip_add(&pdev->dev, &pc->chip);
> -	if (ret < 0)
> +	if (ret < 0) {
> +		clk_rate_exclusive_put(pc->clk);
>  		return dev_err_probe(&pdev->dev, ret,
>  				     "failed to add pwmchip\n");
> +	}
> +
> +	return 0;
> +}
> +
> +static int bcm2835_pwm_remove(struct platform_device *pdev)
> +{
> +	struct bcm2835_pwm *pc = platform_get_drvdata(pdev);
> +
> +	clk_rate_exclusive_put(pc->clk);

The ugly thing here is that now clk_rate_exclusive_put() happens before
pwmchip_remove(). Maybe register a devm cleanup which also gets rid of
the two clk_rate_exclusive_put() in probe's error path?

>  	return 0;
>  }
> @@ -197,6 +216,7 @@ static struct platform_driver bcm2835_pwm_driver = {
>  		.pm = pm_ptr(&bcm2835_pwm_pm_ops),
>  	},
>  	.probe = bcm2835_pwm_probe,
> +	.remove = bcm2835_pwm_remove,

Please use .remove_new

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