Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1460089

Re: [PATCH] clk: prevent __of_clk_get_hw_from_provider() from returning NULL

From Stephen Boyd <sboyd@codeaurora.org>
Newsgroups linux.kernel
Subject Re: [PATCH] clk: prevent __of_clk_get_hw_from_provider() from returning NULL
Date 2016-08-11 01:30 +0200
Message-ID <s4L6F-3kO-3@gated-at.bofh.it> (permalink)
References <rWzcl-27O-17@gated-at.bofh.it> <s2xUd-6f1-7@gated-at.bofh.it> <s4G70-8uN-53@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 08/10, Masahiro Yamada wrote:
> 2016-08-05 5:57 GMT+09:00 Stephen Boyd <sboyd@codeaurora.org>:
> > On 07/19, Masahiro Yamada wrote:
> >> The .get(_hw) callback of an OF clock provider can return a NULL
> >> pointer in some cases.
> >>
> >> For example, of_clk_src_onecell_get() returns NULL for index 1 of a
> >> sparse array of clocks like follows:
> >>
> >>   clk_num == 3
> >>   idx 0: UART clk
> >>   idx 1: NULL (no clk is allocated)
> >>   idx 2: I2C clk
> >>
> >> In such cases, clk_get() successfully returns NULL.
> >>
> >> A problem is that most drivers only check IS_ERR(), like follows:
> >>
> >>   clk = devm_clk_get(dev, NULL);
> >>   if (IS_ERR(clk))
> >>           return PTR_ERR(clk);
> >>
> >> It carries on moving forward and will probably be hit by a different
> >> error check with a different error message.
> >
> > NULL is a valid clk pointer, so we can't really do anything here
> > besides rely on driver authors to do the right thing.
> 
> 
> I still do not understand this.
> 
> 
> I think clk_get() should return > 0 pointer on success,
> error-pointer on failure.

Russell King has repeatedly stated that NULL is a valid return
value from clk_get(). I'm sure we can find numerous such
statements on the arm mailing list.

> 
> I have no idea when NULL is useful as a return value of clk_get().
> 

Perhaps the provider wants to avoid allocating anything for some
clk id and have the clk consumer API do nothing in this case?
Consumers can be unaware of this fact by having the provider
return NULL so things like clk_prepare/enable become nops. Of
course, we can't make things like clk_get_rate() useful in this
case, but at least we can have on/off simplified.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH] clk: prevent __of_clk_get_hw_from_provider() from  returning NULL Stephen Boyd <sboyd@codeaurora.org> - 2016-08-04 23:00 +0200
  Re: [PATCH] clk: prevent __of_clk_get_hw_from_provider() from  returning NULL Sylwester Nawrocki <s.nawrocki@samsung.com> - 2016-08-05 10:40 +0200
  Re: [PATCH] clk: prevent __of_clk_get_hw_from_provider() from  returning NULL Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-08-07 19:10 +0200
  Re: [PATCH] clk: prevent __of_clk_get_hw_from_provider() from  returning NULL Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-08-10 20:10 +0200
    Re: [PATCH] clk: prevent __of_clk_get_hw_from_provider() from  returning NULL Stephen Boyd <sboyd@codeaurora.org> - 2016-08-11 01:30 +0200
      Re: [PATCH] clk: prevent __of_clk_get_hw_from_provider() from  returning NULL Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-08-12 09:10 +0200
        Re: [PATCH] clk: prevent __of_clk_get_hw_from_provider() from  returning NULL Russell King - ARM Linux <linux@armlinux.org.uk> - 2016-08-13 09:40 +0200

csiph-web