public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Grant Likely <grant.likely@linaro.org>,
	Rob Herring <rob.herring@calxeda.com>,
	"David S. Miller" <davem@davemloft.net>,
	Fabio Estevam <fabio.estevam@freescale.com>,
	Frank Li <Frank.Li@freescale.com>,
	Jim Baxter <jim_baxter@mentor.com>,
	Fugang Duan <B38611@freescale.com>,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch] net/fec: "u32" is more explicit than "unsigned long"
Date: Fri, 23 Aug 2013 12:44:29 +0000	[thread overview]
Message-ID: <1377261869.3364.3.camel@bwh-desktop.uk.level5networks.com> (raw)
In-Reply-To: <20130823094920.GP31293@elgon.mountain>

On Fri, 2013-08-23 at 12:49 +0300, Dan Carpenter wrote:
> tmpaddr[] is a six byte array.  We want to set the first four bytes on
> the first line and the remaining two on the next line.  The code assumes
> that "unsigned long" is 32 bits and obviously that's not true on 64 bit
> arches.  It's better to just use u32 instead.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> This is a static checker thing and I can't compile this file.
> 
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index fdf9307..422b125 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1100,9 +1100,9 @@ static void fec_get_mac(struct net_device *ndev)
>  	 * 4) FEC mac registers set by bootloader
>  	 */
>  	if (!is_valid_ether_addr(iap)) {
> -		*((unsigned long *) &tmpaddr[0]) > +		*((u32 *) &tmpaddr[0]) >  			be32_to_cpu(readl(fep->hwp + FEC_ADDR_LOW));
> -		*((unsigned short *) &tmpaddr[4]) > +		*((u16 *) &tmpaddr[4]) >  			be16_to_cpu(readl(fep->hwp + FEC_ADDR_HIGH) >> 16);
>  		iap = &tmpaddr[0];
>  	}

This code also seems to have CPU vs big-endian byte order the wrong way
round.  readl() returns bytes in native order whereas we always store
MAC addresses in network (big-endian) order.  So I think it should be
doing:

		*((__be32 *) &tmpaddr[0]) 			cpu_to_be32(readl(fep->hwp + FEC_ADDR_LOW));
		*((__be16 *) &tmpaddr[4]) 			cpu_to_be16(readl(fep->hwp + FEC_ADDR_HIGH) >> 16);

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


  reply	other threads:[~2013-08-23 12:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-23  9:49 [patch] net/fec: "u32" is more explicit than "unsigned long" Dan Carpenter
2013-08-23 12:44 ` Ben Hutchings [this message]
2013-08-27 18:51   ` David Miller
2013-08-27 18:59     ` Dan Carpenter
2013-08-29  8:25   ` [patch v2] net/fec: cleanup types in fec_get_mac() Dan Carpenter
2013-08-29 18:48     ` Ben Hutchings
2013-08-30  2:02       ` Duan Fugang-B38611
2013-08-30  9:00         ` Dan Carpenter
2013-08-30 21:54     ` David Miller

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=1377261869.3364.3.camel@bwh-desktop.uk.level5networks.com \
    --to=bhutchings@solarflare.com \
    --cc=B38611@freescale.com \
    --cc=Frank.Li@freescale.com \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=fabio.estevam@freescale.com \
    --cc=grant.likely@linaro.org \
    --cc=jim_baxter@mentor.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rob.herring@calxeda.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