From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Message-ID: Subject: Re: [PATCH v2 1/2] clk: Add of_clk_get_by_name_optional() function From: Andy Shevchenko To: Geert Uytterhoeven , Phil Edworthy Cc: Michael Turquette , Stephen Boyd , Russell King , Simon Horman , linux-clk , Linux Kernel Mailing List , Linux ARM Date: Mon, 30 Jul 2018 13:57:07 +0300 In-Reply-To: References: <1532939768-7018-1-git-send-email-phil.edworthy@renesas.com> <1532939768-7018-2-git-send-email-phil.edworthy@renesas.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 List-ID: On Mon, 2018-07-30 at 10:55 +0200, Geert Uytterhoeven wrote: > On Mon, Jul 30, 2018 at 10:36 AM Phil Edworthy > wrote: > > +struct clk *of_clk_get_by_name_optional(struct device_node *np, > > + const char *name) > > +{ > > + if (!np) > > + return ERR_PTR(-ENOENT); > > Shouldn't this return NULL? > Or let __of_clk_get_by_name() handle that (cfr. above)? > > Hmm, of_clk_get_by_name() has a similar check, while the current > __of_clk_get_by_name() already handle np == NULL, too. This check is needed to prevent NULL pointer dereference below. And I agree that absence of device node should be considered as okay case for optional clock (!CONFIG_OF case, for example). > > + > > + return __of_clk_get_by_name(np, np->full_name, name, true); > > +} -- Andy Shevchenko Intel Finland Oy