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] [day] [month] [year] [list]
Message-ID: <20230103211449.GC212337@roeck-us.net>
Date:   Tue, 3 Jan 2023 13:14:49 -0800
From:   Guenter Roeck <linux@...ck-us.net>
To:     Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc:     Wim Van Sebroeck <wim@...ux-watchdog.org>,
        Michal Simek <michal.simek@...inx.com>,
        linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        linux-watchdog@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v2] watchdog: of_xilinx_wdt: Use devm_clk_get_enabled()
 helper

On Sat, Dec 31, 2022 at 01:57:49PM +0100, Christophe JAILLET wrote:
> The devm_clk_get_enabled() helper:
>    - calls devm_clk_get()
>    - calls clk_prepare_enable() and registers what is needed in order to
>      call clk_disable_unprepare() when needed, as a managed resource.
> 
> This simplifies the code and avoids the need of a dedicated function used
> with devm_add_action_or_reset().
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>

Reviewed-by: Guenter Roeck <linux@...ck-us.net>

> ---
> V2: remove xwdt_clk_disable_unprepare() as-well
> 
> Note that the order of operations is slightly modified by this patch. The
> clk is now prepare_enable()'ed before calling clk_get_rate().
> ---
>  drivers/watchdog/of_xilinx_wdt.c | 16 +---------------
>  1 file changed, 1 insertion(+), 15 deletions(-)
> 
> diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c
> index 3318544366b8..2a079ca04aa3 100644
> --- a/drivers/watchdog/of_xilinx_wdt.c
> +++ b/drivers/watchdog/of_xilinx_wdt.c
> @@ -154,11 +154,6 @@ static u32 xwdt_selftest(struct xwdt_device *xdev)
>  		return XWT_TIMER_FAILED;
>  }
>  
> -static void xwdt_clk_disable_unprepare(void *data)
> -{
> -	clk_disable_unprepare(data);
> -}
> -
>  static int xwdt_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
> @@ -193,7 +188,7 @@ static int xwdt_probe(struct platform_device *pdev)
>  
>  	watchdog_set_nowayout(xilinx_wdt_wdd, enable_once);
>  
> -	xdev->clk = devm_clk_get(dev, NULL);
> +	xdev->clk = devm_clk_get_enabled(dev, NULL);
>  	if (IS_ERR(xdev->clk)) {
>  		if (PTR_ERR(xdev->clk) != -ENOENT)
>  			return PTR_ERR(xdev->clk);
> @@ -211,15 +206,6 @@ static int xwdt_probe(struct platform_device *pdev)
>  				 "The watchdog clock freq cannot be obtained\n");
>  	} else {
>  		pfreq = clk_get_rate(xdev->clk);
> -		rc = clk_prepare_enable(xdev->clk);
> -		if (rc) {
> -			dev_err(dev, "unable to enable clock\n");
> -			return rc;
> -		}
> -		rc = devm_add_action_or_reset(dev, xwdt_clk_disable_unprepare,
> -					      xdev->clk);
> -		if (rc)
> -			return rc;
>  	}
>  
>  	/*
> -- 
> 2.34.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ