wl18xx: alloc conf.phy memory to ensure alignemnt
authorArik Nemtsov <arik@wizery.com>
Thu, 5 Jul 2012 14:30:58 +0000 (17:30 +0300)
committerLuciano Coelho <coelho@ti.com>
Wed, 18 Jul 2012 12:08:21 +0000 (15:08 +0300)
We get DMA alignment trouble if the beginning of the conf.phy struct is
not aligned to 4 bytes. Use kmemdup to ensure alignment.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
drivers/net/wireless/ti/wl18xx/main.c

index b378b34c4a6acfb296a393aac7217e2f8f804552..8bb21b6458b88449bfe55f34c98dfe5b6e35441c 100644 (file)
@@ -772,16 +772,24 @@ out:
 static int wl18xx_set_mac_and_phy(struct wl1271 *wl)
 {
        struct wl18xx_priv *priv = wl->priv;
+       struct wl18xx_mac_and_phy_params *params;
        int ret;
 
+       params = kmemdup(&priv->conf.phy, sizeof(*params), GFP_KERNEL);
+       if (!params) {
+               ret = -ENOMEM;
+               goto out;
+       }
+
        ret = wlcore_set_partition(wl, &wl->ptable[PART_PHY_INIT]);
        if (ret < 0)
                goto out;
 
-       ret = wlcore_write(wl, WL18XX_PHY_INIT_MEM_ADDR, (u8 *)&priv->conf.phy,
-                          sizeof(struct wl18xx_mac_and_phy_params), false);
+       ret = wlcore_write(wl, WL18XX_PHY_INIT_MEM_ADDR, params,
+                          sizeof(*params), false);
 
 out:
+       kfree(params);
        return ret;
 }