devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: bhutchings@solarflare.com
Cc: dan.carpenter@oracle.com, grant.likely@linaro.org,
	rob.herring@calxeda.com, fabio.estevam@freescale.com,
	Frank.Li@freescale.com, jim_baxter@mentor.com,
	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: Tue, 27 Aug 2013 14:51:44 -0400 (EDT)	[thread overview]
Message-ID: <20130827.145144.478588680902912563.davem@davemloft.net> (raw)
In-Reply-To: <1377261869.3364.3.camel@bwh-desktop.uk.level5networks.com>

From: Ben Hutchings <bhutchings@solarflare.com>
Date: Fri, 23 Aug 2013 13:44:29 +0100

> 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);

Dan please resubmit with Ben's suggested changes, thanks.

  reply	other threads:[~2013-08-27 18:51 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
2013-08-27 18:51   ` David Miller [this message]
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=20130827.145144.478588680902912563.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=B38611@freescale.com \
    --cc=Frank.Li@freescale.com \
    --cc=bhutchings@solarflare.com \
    --cc=dan.carpenter@oracle.com \
    --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;
as well as URLs for NNTP newsgroup(s).