Re: [PATCH 1/1] clk: Document of_clk_get_by_name() return values

From: Dan Carpenter

Date: Tue Sep 15 2026 - 13:59:22 EST


On Tue, Sep 15, 2026 at 08:53:48PM +0300, Dan Carpenter wrote:
> On Tue, Sep 15, 2026 at 07:38:23PM +0300, Dan Carpenter wrote:
> > Callers should test the return from of_clk_get_by_name() with IS_ERR().
> > The function returns a valid clock on success and an error pointer on
> > failure; NULL is not a valid return value.
> >
> > Document this explicitly to prevent callers from treating NULL as a
> > separate failure case.
> >
> > Assisted-by: ChatGPT:gpt-5
> > Signed-off-by: Dan Carpenter <error27@xxxxxxxxx>
> > ---
> > There are a few other functions which look like they return NULL but
> > never actually do. This is one which has caused some confusion in
> > the past.
>
> Sashiko says that it looks like it can return NULL.
> https://lore.kernel.org/all/20260915164913.597D51F000FF@xxxxxxxxxxxxxxx/
> It does *look* that way, which is why I'm adding the documentation
> to say that looks are confusing.
>
> It's pretty normal for these types of functions to return an error pointer
> for errors and NULL for not found, but the of_clk_get_by_name() returns
> -ENOENT on error. https://lkml.iu.edu/1810.1/06936.html

Doh. I meant -ENOENT on not found. Error pointers for errros and also
for not found.

regards,
dan carpenter