Subject: Re: [PATCH try#2] Blackfin ethernet driver: on chip ethernet MAC controller driver

From: Michael Buesch <[email-masked]>
Date: Sun, 15 Jul 2007 14:17:10 +0200

On Sunday 15 July 2007 14:07:44 Bryan Wu wrote:
> @@ -483,9 +487,12 @@
>  
>  void setup_mac_addr(u8 * mac_addr)
>  {
> +	u32 addr_low = le32_to_cpu(*(u32 *) & mac_addr[0]);
> +	u16 addr_hi = le16_to_cpu(*(u16 *) & mac_addr[4]);
> +
>  	/* this depends on a little-endian machine */
> -	bfin_write_EMAC_ADDRLO(*(u32 *) & mac_addr[0]);
> -	bfin_write_EMAC_ADDRHI(*(u16 *) & mac_addr[4]);
> +	bfin_write_EMAC_ADDRLO(addr_low);
> +	bfin_write_EMAC_ADDRHI(addr_hi);
>  }
>  
>  static void adjust_tx_list(void)
> @@ -866,10 +873,10 @@
>  	int retval;
>  
>  	/* Grab the MAC address in the MAC */
> -	*(u32 *) (&(dev->dev_addr[0])) = bfin_read_EMAC_ADDRLO();
> -	*(u16 *) (&(dev->dev_addr[4])) = (u16) bfin_read_EMAC_ADDRHI();
> +	*(u32 *) (&(dev->dev_addr[0])) = cpu_to_le32(bfin_read_EMAC_ADDRLO());
> +	*(u16 *) (&(dev->dev_addr[4])) = cpu_to_le16((u16) bfin_read_EMAC_ADDRHI());

Try something like this:

@@ -483,9 +487,12 @@
 
 void setup_mac_addr(u8 * mac_addr)
 {
+       u32 addr_low = le32_to_cpu(*(__le32 *) & mac_addr[0]);
+       u16 addr_hi = le16_to_cpu(*(__le16 *) & mac_addr[4]);
+
-       /* this depends on a little-endian machine */
-       bfin_write_EMAC_ADDRLO(*(u32 *) & mac_addr[0]);
-       bfin_write_EMAC_ADDRHI(*(u16 *) & mac_addr[4]);
+       bfin_write_EMAC_ADDRLO(addr_low);
+       bfin_write_EMAC_ADDRHI(addr_hi);
 }
 
 static void adjust_tx_list(void)
@@ -866,10 +873,10 @@
        int retval;
 
        /* Grab the MAC address in the MAC */
-       *(u32 *) (&(dev->dev_addr[0])) = bfin_read_EMAC_ADDRLO();
-       *(u16 *) (&(dev->dev_addr[4])) = (u16) bfin_read_EMAC_ADDRHI();
+       *(__le32 *) (&(dev->dev_addr[0])) = cpu_to_le32(bfin_read_EMAC_ADDRLO());
+       *(__le16 *) (&(dev->dev_addr[4])) = cpu_to_le16((u16) bfin_read_EMAC_ADDRHI());

-- 
Greetings Michael.