All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: linuxppc-dev@ozlabs.org
Subject: [PATCH] [POWERPC] qe_lib: fix few fluffy negligences (was: Re: [PATCH 1/5] [POWERPC] qe_lib and users: get rid of most device_types and model)
Date: Mon, 4 Feb 2008 16:46:17 +0300	[thread overview]
Message-ID: <20080204134617.GA10377@localhost.localdomain> (raw)
In-Reply-To: <20080205001318.5fbc60fa.sfr@canb.auug.org.au>

On Tue, Feb 05, 2008 at 12:13:18AM +1100, Stephen Rothwell wrote:
> Hi Anton,
> 
> I know this is late, but a couple of comments anyway.
> 
> On Thu, 24 Jan 2008 18:39:59 +0300 Anton Vorontsov <avorontsov@ru.mvista.com> wrote:
> >
> > +++ b/arch/powerpc/sysdev/qe_lib/qe.c
> > @@ -65,17 +65,22 @@ static phys_addr_t qebase = -1;
> >  phys_addr_t get_qe_base(void)
> >  {
> >  	struct device_node *qe;
> > +	unsigned int size;
> > +	const void *prop;
> >  
> >  	if (qebase != -1)
> >  		return qebase;
> >  
> > -	qe = of_find_node_by_type(NULL, "qe");
> > -	if (qe) {
> > -		unsigned int size;
> > -		const void *prop = of_get_property(qe, "reg", &size);
> > -		qebase = of_translate_address(qe, prop);
> > -		of_node_put(qe);
> > -	};
> > +	qe = of_find_compatible_node(NULL, NULL, "fsl,qe");
> > +	if (!qe) {
> > +		qe = of_find_node_by_type(NULL, "qe");
> > +		if (!qe)
> > +			return qebase;
> > +	}
> > +
> > +	prop = of_get_property(qe, "reg", &size);
> > +	qebase = of_translate_address(qe, prop);
> 
> If you don't care about the returned length (argument three to
> of_get_property), you can just pass NULL (and dispense with "size").
> Also, what happens if prop is NULL?

All this was in the old code already, I just didn't fix that.

> > @@ -153,16 +158,26 @@ static unsigned int brg_clk = 0;
> >  unsigned int get_brg_clk(void)
> >  {
> >  	struct device_node *qe;
> > +	unsigned int size;
> > +	const u32 *prop;
> > +
> >  	if (brg_clk)
> >  		return brg_clk;
> >  
> > -	qe = of_find_node_by_type(NULL, "qe");
> > -	if (qe) {
> > -		unsigned int size;
> > -		const u32 *prop = of_get_property(qe, "brg-frequency", &size);
> > -		brg_clk = *prop;
> > -		of_node_put(qe);
> > -	};
> > +	qe = of_find_compatible_node(NULL, NULL, "fsl,qe");
> > +	if (!qe) {
> > +		qe = of_find_node_by_type(NULL, "qe");
> > +		if (!qe)
> > +			return brg_clk;
> > +	}
> > +
> > +	prop = of_get_property(qe, "brg-frequency", &size);
> > +	if (!prop || size != sizeof(*prop))
> > +		return brg_clk;
> 
> You need an of_node_put(qe) before the return ...

This is new. :-) Thanks.

- - - -
From: Anton Vorontsov <avorontsov@ru.mvista.com>
Subject: [POWERPC] qe_lib: fix few fluffy negligences

One is intoduced by me (of_node_put() absence) and another was
present already (not checking for NULL).

Found by Stephen Rothwell.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 arch/powerpc/sysdev/qe_lib/qe.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c
index 5ef844d..6efbd5e 100644
--- a/arch/powerpc/sysdev/qe_lib/qe.c
+++ b/arch/powerpc/sysdev/qe_lib/qe.c
@@ -66,7 +66,7 @@ phys_addr_t get_qe_base(void)
 {
 	struct device_node *qe;
 	unsigned int size;
-	const void *prop;
+	const u32 *prop;
 
 	if (qebase != -1)
 		return qebase;
@@ -79,7 +79,8 @@ phys_addr_t get_qe_base(void)
 	}
 
 	prop = of_get_property(qe, "reg", &size);
-	qebase = of_translate_address(qe, prop);
+	if (prop && size >= sizeof(*prop))
+		qebase = of_translate_address(qe, prop);
 	of_node_put(qe);
 
 	return qebase;
@@ -172,10 +173,9 @@ unsigned int get_brg_clk(void)
 	}
 
 	prop = of_get_property(qe, "brg-frequency", &size);
-	if (!prop || size != sizeof(*prop))
-		return brg_clk;
+	if (prop && size == sizeof(*prop))
+		brg_clk = *prop;
 
-	brg_clk = *prop;
 	of_node_put(qe);
 
 	return brg_clk;
-- 
1.5.2.2

  reply	other threads:[~2008-02-04 13:46 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-24 15:18 [PATCH v5 0/5] device_type/compatible cleanups Anton Vorontsov
2008-01-24 15:39 ` [PATCH 1/5] [POWERPC] qe_lib and users: get rid of most device_types and model Anton Vorontsov
2008-01-25 21:19   ` Kumar Gala
2008-02-04 13:13   ` Stephen Rothwell
2008-02-04 13:46     ` Anton Vorontsov [this message]
2008-02-04 14:48       ` [PATCH] [POWERPC] qe_lib: fix few fluffy negligences (was: Re: [PATCH 1/5] [POWERPC] qe_lib and users: get rid of most device_types and model) Stephen Rothwell
2008-02-06  6:04       ` Kumar Gala
2008-01-24 15:40 ` [PATCH 2/5] [POWERPC][NET] ucc_geth_mii and users: get rid of device_type Anton Vorontsov
2008-01-24 15:52   ` Kumar Gala
2008-01-24 16:11     ` Anton Vorontsov
2008-01-25 21:20   ` Kumar Gala
2008-01-24 15:40 ` [PATCH 3/5] [POWERPC][SPI] use brg-frequency for SPI in QE Anton Vorontsov
2008-01-25 21:20   ` Kumar Gala
2008-01-24 15:40 ` [PATCH 4/5] [POWERPC] fsl_spi_init and users: stop using device_type = "spi" Anton Vorontsov
2008-01-25 21:20   ` Kumar Gala
2008-01-24 15:40 ` [PATCH 5/5] [POWERPC] fsl_soc, legacy_serial: add support for "soc" compatible matching Anton Vorontsov
2008-01-25 16:35   ` Kumar Gala
2008-01-25 17:13     ` Anton Vorontsov
2008-01-25 17:26       ` Anton Vorontsov
2008-01-25 18:17       ` Scott Wood
2008-01-25 18:53         ` Anton Vorontsov
2008-01-25 19:03           ` Scott Wood
2008-01-25 19:18             ` Anton Vorontsov
2008-01-24 17:35 ` [PATCH v5 0/5] device_type/compatible cleanups Anton Vorontsov
2008-01-24 18:26   ` Jon Loeliger
2008-01-25 14:37 ` [PATCH 6/5] [POWERPC] get rid of `model = "UCC"' in the ucc nodes Anton Vorontsov
2008-01-25 16:33   ` Kumar Gala

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080204134617.GA10377@localhost.localdomain \
    --to=avorontsov@ru.mvista.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.