mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Poonam_Aggrwal-b10812 <b10812@freescale.com>
Cc: rubini@vision.unipv.it, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, kumar.gala@freescale.com,
	linuxppc-dev@ozlabs.org, michael.barkowski@freescale.com,
	rich.cutler@freescale.com, ashish.kalra@freescale.com
Subject: Re: [PATCH 2/3] arch/ : Platform changes for UCC TDM driver for MPC8323ERDB.Also includes related QE changes.
Date: Tue, 11 Dec 2007 11:18:55 +1100	[thread overview]
Message-ID: <20071211111855.dc5276a2.sfr@canb.auug.org.au> (raw)
In-Reply-To: <Pine.LNX.4.64.0712101734490.29623@linux121>

[-- Attachment #1: Type: text/plain, Size: 2543 bytes --]

On Mon, 10 Dec 2007 17:39:22 +0530 (IST) Poonam_Aggrwal-b10812 <b10812@freescale.com> wrote:
>
> +++ b/arch/powerpc/sysdev/qe_lib/qe.c
> @@ -149,22 +149,116 @@ EXPORT_SYMBOL(qe_issue_cmd);
>   */
>  static unsigned int brg_clk = 0;
>  
> -unsigned int get_brg_clk(void)
> +u32 get_brg_clk(enum qe_clock brgclk, enum qe_clock *brg_source)
>  {
> -	struct device_node *qe;
> -	if (brg_clk)
> -		return brg_clk;
> +	struct device_node *qe, *brg, *clocks;
> +	enum qe_clock brg_src;
> +	u32 brg_input_freq = 0;
> +	u32 brg_num;
> +	const unsigned int *prop;
>  
> -	qe = of_find_node_by_type(NULL, "qe");
> -	if (qe) {
> +	*brg_source = 0;
> +
> +	brg_num = brgclk - QE_BRG1;
> +	brg = of_find_compatible_node(NULL, NULL, "fsl,cpm-brg");
> +	if (brg) {
>  		unsigned int size;
> -		const u32 *prop = of_get_property(qe, "brg-frequency", &size);
> -		brg_clk = *prop;
> -		of_node_put(qe);
> -	};
> +		prop = of_get_property(brg,
> +					"fsl,brg-sources", &size);
> +
> +		brg_src = *(prop + brg_num);

You should probably sanity check that prop is not NULL and points to
something large enough.

You don't use brg after here, so the "of_node_put(brg)" could go here to
save putting it in multiple places later.  Also, currently there are
paths through the following code that do not do the of_node_put(brg).

> +		if (brg_src == 0) {
> +			*brg_source = 0;
> +			if (brg_clk > 0) {
> +				of_node_put(brg);
> +				return brg_clk;
> +			}
> +			qe = of_find_node_by_type(NULL, "qe");
> +			if (qe) {
> +				unsigned int size;
> +				prop = of_get_property
> +						(qe, "brg-frequency", &size);
> +				of_node_put(qe);
> +				of_node_put(brg);
> +				return *prop;

NULL check here (yes, I know that the old code didn't check).

> +			}
> +		} else {
> +			*brg_source = brg_src + QE_CLK1 - 1;
> +			clocks = of_find_compatible_node(NULL, NULL,
> +							"fsl,cpm-clocks");
> +			prop = of_get_property(clocks,
> +						"#clock-cells", &size);
> +			/*
> +			 * clock-cells = 1 only supported right now.
> +			 */
> +			if (*prop != 1)

Again check for NULL (and possibly size).

> +				return 0;
> +			prop = of_get_property(clocks,
> +						"clock-frequency", &size);
> +
> +			brg_input_freq = *(prop+(brg_src - 1));

And again.

> +			of_node_put(clocks);
> +			of_node_put(brg);
> +			return brg_input_freq;
> +		}
> +	}
>  	return brg_clk;
>  }
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2007-12-11  0:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-10 12:09 Poonam_Aggrwal-b10812
2007-12-11  0:18 ` Stephen Rothwell [this message]
2007-12-17  5:54   ` Aggrwal Poonam

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=20071211111855.dc5276a2.sfr@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=ashish.kalra@freescale.com \
    --cc=b10812@freescale.com \
    --cc=kumar.gala@freescale.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=michael.barkowski@freescale.com \
    --cc=netdev@vger.kernel.org \
    --cc=rich.cutler@freescale.com \
    --cc=rubini@vision.unipv.it \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®