netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Liu Yu <yu.liu@freescale.com>
Cc: galak@kernel.crashing.org, davem@davemloft.net,
	netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode
Date: Mon, 1 Feb 2010 14:57:31 -0700	[thread overview]
Message-ID: <fa686aa41002011357pb24d8a6k640ab5ae13f8fbbc@mail.gmail.com> (raw)
In-Reply-To: <1263456799-3306-2-git-send-email-yu.liu@freescale.com>

On Thu, Jan 14, 2010 at 1:13 AM, Liu Yu <yu.liu@freescale.com> wrote:
> Signed-off-by: Liu Yu <yu.liu@freescale.com>
> ---
>  arch/powerpc/platforms/85xx/mpc85xx_mds.c |   24 ++++++++++++++++++++++++
>  1 files changed, 24 insertions(+), 0 deletions(-)
>
> diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> index c5028a2..0872e4a 100644
> --- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> +++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> @@ -237,6 +237,8 @@ static void __init mpc85xx_mds_setup_arch(void)
>                } else if (machine_is(mpc8569_mds)) {
>  #define BCSR7_UCC12_GETHnRST   (0x1 << 2)
>  #define BCSR8_UEM_MARVELL_RST  (0x1 << 1)
> +#define BCSR_UCC_RGMII         (0x1 << 6)
> +#define BCSR_UCC_RTBI          (0x1 << 5)
>                        /*
>                         * U-Boot mangles interrupt polarity for Marvell PHYs,
>                         * so reset built-in and UEM Marvell PHYs, this puts
> @@ -247,6 +249,28 @@ static void __init mpc85xx_mds_setup_arch(void)
>
>                        setbits8(&bcsr_regs[7], BCSR7_UCC12_GETHnRST);
>                        clrbits8(&bcsr_regs[8], BCSR8_UEM_MARVELL_RST);
> +
> +                       for (np = NULL; (np = of_find_compatible_node(np,
> +                                                       "network",

Don't match on the 'type' field.  Replace "network" with NULL and just
rely on "ucc_geth" for matching.

> +                                                       "ucc_geth")) != NULL;) {
> +                               const unsigned int *prop;

u32 please.

Also, rather than reusing 'prop' for both char* and u32 values, which
forces you to use ugly casts, use 2 local variables here.

> +                               int ucc_num;
> +
> +                               prop = of_get_property(np, "cell-index", NULL);
> +                               if (prop == NULL)
> +                                       continue;
> +
> +                               ucc_num = *prop - 1;

Ugh.  No bounds checking...

> +
> +                               prop = of_get_property(np, "phy-connection-type", NULL);
> +                               if (prop == NULL)
> +                                       continue;
> +
> +                               if (strcmp("rtbi", (const char *)prop) == 0)

(This is the ugly cast I was talking about.)

> +                                       clrsetbits_8(&bcsr_regs[7 + ucc_num],

...not having bounds checking could result in badness in this array index.

This patch is dangerous as written.

Finally, while using cell-index seems convenient, I think it would be
better to have a lookup table of the index into the BCSR register
block from the UCC base address, which also gives you implicit bounds
checking.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

  parent reply	other threads:[~2010-02-01 21:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-14  8:13 [PATCH 1/4] dts/mpc8569mds: Cleanup tbi phy to support rtbi Liu Yu
2010-01-14  8:13 ` [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode Liu Yu
2010-01-14  8:13   ` [PATCH 3/4] ucc_geth: update the tbi-phy setting Liu Yu
2010-01-14  8:13     ` [PATCH 4/4] phy: add RTBI mode for m88e1111 Liu Yu
2010-01-14 16:20       ` Kumar Gala
2010-01-15  2:49         ` Liu Yu-B13201
2010-01-21  9:18           ` David Miller
2010-02-01 22:00     ` [PATCH 3/4] ucc_geth: update the tbi-phy setting Grant Likely
2010-02-01 21:57   ` Grant Likely [this message]
2010-02-02  5:57     ` [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode Liu Yu-B13201
2010-02-01 21:46 ` [PATCH 1/4] dts/mpc8569mds: Cleanup tbi phy to support rtbi Grant Likely

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=fa686aa41002011357pb24d8a6k640ab5ae13f8fbbc@mail.gmail.com \
    --to=grant.likely@secretlab.ca \
    --cc=davem@davemloft.net \
    --cc=galak@kernel.crashing.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=yu.liu@freescale.com \
    /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;
as well as URLs for NNTP newsgroup(s).