Re: [PATCH 5/5] spi: fix return value check in hspi_probe().

Grant Likely
2013-01-11T15:02:02Z

On Thu, 3 Jan 2013 19:04:55 +0300, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Sat, Dec 22, 2012 at 09:56:20AM +0000, Grant Likely wrote:
> > On Wed, 19 Dec 2012 19:39:14 +0300, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > > On Wed, Dec 19, 2012 at 03:11:54PM +0000, Grant Likely wrote:
> > > > On Tue, 11 Dec 2012 16:36:27 -0800 (PST), Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> wrote:
> > > > >
> > > > > Hi
> > > > >
> > > > > > According to its documentation, clk_get() returns a "valid IS_ERR() condition
> > > > > > containing errno", so we should call IS_ERR() rather than a NULL check.
> > > > > >
> > > > > > Signed-off-by: Cyril Roelandt <tipecaml@gmail.com>
> > > > >
> > > > > Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > > >
> > > > Applied, thanks.
> > >
> > > In another thread, we were just talking about who clk_get() can
> > > return a NULL if !CONFIG_HAVE_CLK. That might change to match the
> > > documentation later... Not sure.
> >
> > So what is the solution here? Will the dummy clk_get() be changed, or is
> > there more work needed on the drivers?
> >
>
> This driver can't function without a clk. It should select that at
> build time instead of testing for it at probe. Just checking for
> IS_ERR() will NOT cause a NULL dereference so the patch is ok in
> that respect. I'm not sure if this can be build without
> CONFIG_HAVE_CLK.

Your suggestion is to make this driver depend on CONFIG_HAVE_CLK? I'm
fine with that, but it doesn't sort out the core infrastructure question
about whether it is valid for the empty clk_get() to return NULL. Nor is
it a particularly sustainable solution (ie. if a large number of drivers
want to do the same thing).

g.