[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <431a8ae1-54a7-e71a-484d-cab618a2a1c4@roeck-us.net>
Date: Sat, 4 Mar 2023 14:10:47 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Christophe JAILLET <christophe.jaillet@...adoo.fr>,
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
Cc: Alim Akhtar <alim.akhtar@...sung.com>,
Wim Van Sebroeck <wim@...ux-watchdog.org>,
linux-arm-kernel@...ts.infradead.org,
linux-samsung-soc@...r.kernel.org, linux-watchdog@...r.kernel.org,
linux-kernel@...r.kernel.org,
Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
Subject: Re: [PATCH 1/2] watchdog: s3c2410_wdt: Use Use
devm_clk_get[_optional]_enabled() helpers
On 3/4/23 13:46, Christophe JAILLET wrote:
> Le 04/03/2023 à 17:56, Guenter Roeck a écrit :
>> The devm_clk_get[_optional]_enabled() helpers:
>> - call devm_clk_get[_optional]()
>> - call clk_prepare_enable() and register what is needed in order to
>> call clk_disable_unprepare() when needed, as a managed resource.
>>
>> This simplifies the code and avoids the calls to clk_disable_unprepare().
>>
>> While at it, use dev_err_probe consistently, and use its return value
>> to return the error code.
>>
>> Cc: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
>> Signed-off-by: Guenter Roeck <linux@...ck-us.net>
>> ---
>> drivers/watchdog/s3c2410_wdt.c | 45 +++++++---------------------------
>> 1 file changed, 9 insertions(+), 36 deletions(-)
>>
>> diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
>> index 200ba236a72e..a1fcb79b0b7c 100644
>> --- a/drivers/watchdog/s3c2410_wdt.c
>> +++ b/drivers/watchdog/s3c2410_wdt.c
>> @@ -661,35 +661,17 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
>> if (IS_ERR(wdt->reg_base))
>> return PTR_ERR(wdt->reg_base);
>> - wdt->bus_clk = devm_clk_get(dev, "watchdog");
>> - if (IS_ERR(wdt->bus_clk)) {
>> - dev_err(dev, "failed to find bus clock\n");
>> - return PTR_ERR(wdt->bus_clk);
>> - }
>> -
>> - ret = clk_prepare_enable(wdt->bus_clk);
>> - if (ret < 0) {
>> - dev_err(dev, "failed to enable bus clock\n");
>> - return ret;
>> - }
>> + wdt->bus_clk = devm_clk_get_enabled(dev, "watchdog");
>> + if (IS_ERR(wdt->bus_clk))
>> + return dev_err_probe(dev, PTR_ERR(wdt->bus_clk), "failed to get bus clock\n");
>> /*
>> * "watchdog_src" clock is optional; if it's not present -- just skip it
>> * and use "watchdog" clock as both bus and source clock.
>> */
>> - wdt->src_clk = devm_clk_get_optional(dev, "watchdog_src");
>> - if (IS_ERR(wdt->src_clk)) {
>> - dev_err_probe(dev, PTR_ERR(wdt->src_clk),
>> - "failed to get source clock\n");
>> - ret = PTR_ERR(wdt->src_clk);
>> - goto err_bus_clk;
>> - }
>> -
>> - ret = clk_prepare_enable(wdt->src_clk);
>> - if (ret) {
>> - dev_err(dev, "failed to enable source clock\n");
>> - goto err_bus_clk;
>> - }
>> + wdt->src_clk = devm_clk_get_optional_enabled(dev, "watchdog_src");
>> + if (IS_ERR(wdt->src_clk))
>> + return dev_err_probe(dev, PTR_ERR(wdt->src_clk), "failed to get source clock\n");
>> wdt->wdt_device.min_timeout = 1;
>> wdt->wdt_device.max_timeout = s3c2410wdt_max_timeout(wdt);
>> @@ -710,7 +692,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
>> S3C2410_WATCHDOG_DEFAULT_TIME);
>> } else {
>> dev_err(dev, "failed to use default timeout\n");
>> - goto err_src_clk;
>> + return ret;
>
> Hi,
>
> Nit: this also could be "return dev_err_probe()"
>
>> }
>> }
>> @@ -718,7 +700,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
>> pdev->name, pdev);
>> if (ret != 0) {
>> dev_err(dev, "failed to install irq (%d)\n", ret);
>> - goto err_src_clk;
>> + return ret;
>
> Nit: this also could be "return dev_err_probe()"
>
The primary reason to call dev_err_probe() is that the error may be
-EPROBE_DEFER, in which case the error message is suppressed.
That is not the case for those two functions; they never return
-EPROBE_DEFER. Calling dev_err_probe() would give the false impression
that the functions _might_ return -EPROBE_DEFER.
Thanks,
Guenter
Powered by blists - more mailing lists