Re: [PATCH] clk: Add (devm_)clk_get_optional() functions

From: Uwe Kleine-König
Date: Tue Nov 20 2018 - 07:57:07 EST


Hello,

On Tue, Nov 20, 2018 at 12:38:33PM +0200, Andy Shevchenko wrote:
> On Mon, Nov 19, 2018 at 02:12:59PM +0000, Phil Edworthy wrote:
> > + if (clk == ERR_PTR(-ENOENT))
> > + return NULL;
> > + else
> > + return clk;
>
> return clk == ERR_PTR(-ENOENT) ? NULL : clk;
>
> ?

Not sure this adds to the readability of the expression. Personally I
prefer the explicit if. Maybe even:

clk = clk_get(...);

if (clk == ERR_PTR(-ENOENT))
clk = NULL;

return clk;

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |