lkml.org 
[lkml]   [2018]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3 7/8] net: phy: Add support to configure clock in Broadcom iProc mdio mux
From
Date
Hi Andrew,

On 18-08-01 02:55 PM, Andrew Lunn wrote:
>> md->core_clk = devm_clk_get(&pdev->dev, NULL);
>> if (md->core_clk == ERR_PTR(-ENOENT) || md->core_clk == ERR_PTR(-EINVAL)) {
>> /* clock is optional, without it the default
>> * rate divider register values will be used
>> */
>> md->core_clk = NULL;
>> } else if (IS_ERR(md->core_clk)) {
>> return PTR_ERR(md->core_clk);
>> } else {
>> rc = clk_prepare_enable(md->core_clk);
>> ...
>> }
>
> As Florian pointed out, the clk_ API is happy to take a NULL pointer
> for a clock. So you don't need this last else.
>
> Andrew
>
I do return with an error from the probe if the clk_prepare_enable() fails,
so I was calling the prepare with a valid clock.

In the other places where I used the clock, the return values were being
ignored.

The 'else' part should have been, I apologize for the confusion.

if (md->core_clk == ERR_PTR(-ENOENT) || md->core_clk == ERR_PTR(-EINVAL)) {
/* clock is optional, without it the default
* rate divider register values will be used
*/
md->core_clk = NULL;
} else if (IS_ERR(md->core_clk)) {
return PTR_ERR(md->core_clk);
} else {
rc = clk_prepare_enable(md->core_clk);
if (rc) {
dev_err(&pdev->dev, "failed to enable core clk\n");
return rc;
}
}


Thanks
Arun

\
 
 \ /
  Last update: 2018-08-02 00:11    [W:0.154 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site