linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 5/5] spi: fix return value check in hspi_probe().
       [not found] ` <1355271894-5284-1-git-send-email-tipecaml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2012-12-12  0:24   ` Cyril Roelandt
       [not found]     ` <1355271894-5284-6-git-send-email-tipecaml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Cyril Roelandt @ 2012-12-12  0:24 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Cyril Roelandt

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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/spi/spi-sh-hspi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-sh-hspi.c b/drivers/spi/spi-sh-hspi.c
index 32f7b55..60cfae5 100644
--- a/drivers/spi/spi-sh-hspi.c
+++ b/drivers/spi/spi-sh-hspi.c
@@ -290,7 +290,7 @@ static int hspi_probe(struct platform_device *pdev)
 	}
 
 	clk = clk_get(NULL, "shyway_clk");
-	if (!clk) {
+	if (IS_ERR(clk)) {
 		dev_err(&pdev->dev, "shyway_clk is required\n");
 		ret = -EINVAL;
 		goto error0;
-- 
1.7.10.4


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 5/5] spi: fix return value check in hspi_probe().
       [not found]     ` <1355271894-5284-6-git-send-email-tipecaml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2012-12-12  0:36       ` Kuninori Morimoto
       [not found]         ` <87txrsqf7f.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Kuninori Morimoto @ 2012-12-12  0:36 UTC (permalink / raw)
  To: Cyril Roelandt
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA


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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Acked-by: Kuninori Morimoto <kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>

> ---
>  drivers/spi/spi-sh-hspi.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-sh-hspi.c b/drivers/spi/spi-sh-hspi.c
> index 32f7b55..60cfae5 100644
> --- a/drivers/spi/spi-sh-hspi.c
> +++ b/drivers/spi/spi-sh-hspi.c
> @@ -290,7 +290,7 @@ static int hspi_probe(struct platform_device *pdev)
>  	}
>  
>  	clk = clk_get(NULL, "shyway_clk");
> -	if (!clk) {
> +	if (IS_ERR(clk)) {
>  		dev_err(&pdev->dev, "shyway_clk is required\n");
>  		ret = -EINVAL;
>  		goto error0;
> -- 
> 1.7.10.4
> 
> 
> ------------------------------------------------------------------------------
> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
> Remotely access PCs and mobile devices and provide instant support
> Improve your efficiency, and focus on delivering more value-add services
> Discover what IT Professionals Know. Rescue delivers
> http://p.sf.net/sfu/logmein_12329d2d
> _______________________________________________
> spi-devel-general mailing list
> spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Best regards
---
Kuninori Morimoto

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 5/5] spi: fix return value check in hspi_probe().
       [not found]         ` <87txrsqf7f.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
@ 2012-12-19 15:11           ` Grant Likely
  2012-12-19 16:39             ` Dan Carpenter
  0 siblings, 1 reply; 8+ messages in thread
From: Grant Likely @ 2012-12-19 15:11 UTC (permalink / raw)
  To: Kuninori Morimoto, Cyril Roelandt
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Tue, 11 Dec 2012 16:36:27 -0800 (PST), Kuninori Morimoto <kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org> 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> Acked-by: Kuninori Morimoto <kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>

Applied, thanks.

g.


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 5/5] spi: fix return value check in hspi_probe().
  2012-12-19 15:11           ` Grant Likely
@ 2012-12-19 16:39             ` Dan Carpenter
  2012-12-22  9:56               ` Grant Likely
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Carpenter @ 2012-12-19 16:39 UTC (permalink / raw)
  To: Grant Likely
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Cyril Roelandt,
	Kuninori Morimoto, linux-kernel-u79uwXL29TY76Z2rM5mHXA

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-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org> 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > 
> > Acked-by: Kuninori Morimoto <kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
> 
> 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.

regards,
dan carpenter


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 5/5] spi: fix return value check in hspi_probe().
  2012-12-19 16:39             ` Dan Carpenter
@ 2012-12-22  9:56               ` Grant Likely
  2013-01-03 16:04                 ` Dan Carpenter
  0 siblings, 1 reply; 8+ messages in thread
From: Grant Likely @ 2012-12-22  9:56 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Cyril Roelandt,
	Kuninori Morimoto, linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Wed, 19 Dec 2012 19:39:14 +0300, Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 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-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org> 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > > 
> > > Acked-by: Kuninori Morimoto <kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
> > 
> > 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?

/me stifles a rant about the PTR_ERR pattern

g.

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 5/5] spi: fix return value check in hspi_probe().
  2012-12-22  9:56               ` Grant Likely
@ 2013-01-03 16:04                 ` Dan Carpenter
  2013-01-11 15:02                   ` Grant Likely
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Carpenter @ 2013-01-03 16:04 UTC (permalink / raw)
  To: Grant Likely
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Cyril Roelandt,
	Kuninori Morimoto, linux-kernel-u79uwXL29TY76Z2rM5mHXA

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-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 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-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org> 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > > > 
> > > > Acked-by: Kuninori Morimoto <kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
> > > 
> > > 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.

regards,
dan carpenter


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 5/5] spi: fix return value check in hspi_probe().
  2013-01-03 16:04                 ` Dan Carpenter
@ 2013-01-11 15:02                   ` Grant Likely
  2013-01-12  0:01                     ` Dan Carpenter
  0 siblings, 1 reply; 8+ messages in thread
From: Grant Likely @ 2013-01-11 15:02 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Cyril Roelandt,
	Kuninori Morimoto, linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Thu, 3 Jan 2013 19:04:55 +0300, Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 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-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 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-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org> 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > > > > 
> > > > > Acked-by: Kuninori Morimoto <kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
> > > > 
> > > > 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.

------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 5/5] spi: fix return value check in hspi_probe().
  2013-01-11 15:02                   ` Grant Likely
@ 2013-01-12  0:01                     ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2013-01-12  0:01 UTC (permalink / raw)
  To: Grant Likely
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Cyril Roelandt,
	Kuninori Morimoto, linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Fri, Jan 11, 2013 at 03:02:02PM +0000, Grant Likely wrote:
> On Thu, 3 Jan 2013 19:04:55 +0300, Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 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-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 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-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org> 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > > > > > 
> > > > > > Acked-by: Kuninori Morimoto <kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
> > > > > 
> > > > > 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).
> 

We've spread this conversation out across several different threads.

http://lists.infradead.org/pipermail/linux-arm-kernel/2013-January/139186.html

Basically, drivers should use accessor functions which handle NULL
pointers instead of dereferencing the pointer directly.

regards,
dan carpenter


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122912

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-01-12  0:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1355271894-5284-1-git-send-email-tipecaml@gmail.com>
     [not found] ` <1355271894-5284-1-git-send-email-tipecaml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-12-12  0:24   ` [PATCH 5/5] spi: fix return value check in hspi_probe() Cyril Roelandt
     [not found]     ` <1355271894-5284-6-git-send-email-tipecaml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-12-12  0:36       ` Kuninori Morimoto
     [not found]         ` <87txrsqf7f.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2012-12-19 15:11           ` Grant Likely
2012-12-19 16:39             ` Dan Carpenter
2012-12-22  9:56               ` Grant Likely
2013-01-03 16:04                 ` Dan Carpenter
2013-01-11 15:02                   ` Grant Likely
2013-01-12  0:01                     ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).