Re: [PATCH] clk: Add (devm_)clk_get_optional() functions
From: Andy Shevchenko
Date: Tue Nov 20 2018 - 08:26:27 EST
On Tue, Nov 20, 2018 at 01:56:52PM +0100, Uwe Kleine-König wrote:
> 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;
So, it almost repeats the initial variant.
I'm fine with no 'else' in initial code, like
if (...)
return NULL;
return clk;
--
With Best Regards,
Andy Shevchenko