-ENOENT (ie. "there is no clock") is fine to ignore for an optional
clock, other values are not supposed to be ignored and should be
escalated to the caller (e.g. -EPROBE_DEFER). Ignore -ENOENT by using
devm_clk_get_optional().
While touching this code also add an error message for the fatal errors.
Signed-off-by: Uwe Kleine-König <redacted>
---
drivers/char/hw_random/meson-rng.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
@@ -54,9 +54,15 @@ static int meson_rng_probe(struct platform_device *pdev)if(IS_ERR(data->base))returnPTR_ERR(data->base);-data->core_clk=devm_clk_get(dev,"core");-if(IS_ERR(data->core_clk))-data->core_clk=NULL;+data->core_clk=devm_clk_get_optional(dev,"core");+if(IS_ERR(data->core_clk)){+ret=PTR_ERR(data->core_clk);+if(ret!=-EPROBE_DEFER)+dev_err(dev,"Failed to get core clock: %pe\n",+data->core_clk);++returnret;+}if(data->core_clk){ret=clk_prepare_enable(data->core_clk);
--
2.30.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Neil Armstrong <hidden> Date: 2021-09-15 08:13:59
On 14/09/2021 16:24, Uwe Kleine-König wrote:
quoted hunk
-ENOENT (ie. "there is no clock") is fine to ignore for an optional
clock, other values are not supposed to be ignored and should be
escalated to the caller (e.g. -EPROBE_DEFER). Ignore -ENOENT by using
devm_clk_get_optional().
While touching this code also add an error message for the fatal errors.
Signed-off-by: Uwe Kleine-König <redacted>
---
drivers/char/hw_random/meson-rng.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
@@ -54,9 +54,15 @@ static int meson_rng_probe(struct platform_device *pdev)if(IS_ERR(data->base))returnPTR_ERR(data->base);-data->core_clk=devm_clk_get(dev,"core");-if(IS_ERR(data->core_clk))-data->core_clk=NULL;+data->core_clk=devm_clk_get_optional(dev,"core");+if(IS_ERR(data->core_clk)){+ret=PTR_ERR(data->core_clk);+if(ret!=-EPROBE_DEFER)+dev_err(dev,"Failed to get core clock: %pe\n",+data->core_clk);++returnret;+}if(data->core_clk){ret=clk_prepare_enable(data->core_clk);
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Date: 2021-09-19 20:07:32
Hi Uwe,
On Tue, Sep 14, 2021 at 4:24 PM Uwe Kleine-König
[off-list ref] wrote:
[...]
quoted hunk
- data->core_clk = devm_clk_get(dev, "core");- if (IS_ERR(data->core_clk))- data->core_clk = NULL;+ data->core_clk = devm_clk_get_optional(dev, "core");+ if (IS_ERR(data->core_clk)) {+ ret = PTR_ERR(data->core_clk);+ if (ret != -EPROBE_DEFER)+ dev_err(dev, "Failed to get core clock: %pe\n",+ data->core_clk);++ return ret;
I suggest simplifying this by using dev_err_probe as this:
- allows you to get rid of the if (ret != -EPROBE_DEFER)
- means that the message is shown in debugfs' "devices_deferred"
Best regards,
Martin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel