UCC Ether driver: kmalloc casting cleanups
[sfrench/cifs-2.6.git] / drivers / net / ucc_geth.c
index 8243150f5b05ec6572cc8cfce779e7674a0b6ef0..abb8611c5a916b7d3e12223cdfbfeeb30920e523 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/fsl_devices.h>
 #include <linux/ethtool.h>
 #include <linux/mii.h>
+#include <linux/workqueue.h>
 
 #include <asm/of_platform.h>
 #include <asm/uaccess.h>
@@ -472,7 +473,7 @@ static void put_enet_addr_container(struct enet_addr_container *enet_addr_cont)
        kfree(enet_addr_cont);
 }
 
-static int set_mac_addr(__be16 __iomem *reg, u8 *mac)
+static void set_mac_addr(__be16 __iomem *reg, u8 *mac)
 {
        out_be16(&reg[0], ((u16)mac[5] << 8) | mac[4]);
        out_be16(&reg[1], ((u16)mac[3] << 8) | mac[2]);
@@ -2864,8 +2865,8 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
                        if (UCC_GETH_TX_BD_RING_ALIGNMENT > 4)
                                align = UCC_GETH_TX_BD_RING_ALIGNMENT;
                        ugeth->tx_bd_ring_offset[j] =
-                               (u32) (kmalloc((u32) (length + align),
-                               GFP_KERNEL));
+                               kmalloc((u32) (length + align), GFP_KERNEL);
+
                        if (ugeth->tx_bd_ring_offset[j] != 0)
                                ugeth->p_tx_bd_ring[j] =
                                        (void*)((ugeth->tx_bd_ring_offset[j] +
@@ -2900,7 +2901,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
                        if (UCC_GETH_RX_BD_RING_ALIGNMENT > 4)
                                align = UCC_GETH_RX_BD_RING_ALIGNMENT;
                        ugeth->rx_bd_ring_offset[j] =
-                           (u32) (kmalloc((u32) (length + align), GFP_KERNEL));
+                               kmalloc((u32) (length + align), GFP_KERNEL);
                        if (ugeth->rx_bd_ring_offset[j] != 0)
                                ugeth->p_rx_bd_ring[j] =
                                        (void*)((ugeth->rx_bd_ring_offset[j] +
@@ -2926,10 +2927,9 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
        /* Init Tx bds */
        for (j = 0; j < ug_info->numQueuesTx; j++) {
                /* Setup the skbuff rings */
-               ugeth->tx_skbuff[j] =
-                   (struct sk_buff **)kmalloc(sizeof(struct sk_buff *) *
-                                              ugeth->ug_info->bdRingLenTx[j],
-                                              GFP_KERNEL);
+               ugeth->tx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) *
+                                             ugeth->ug_info->bdRingLenTx[j],
+                                             GFP_KERNEL);
 
                if (ugeth->tx_skbuff[j] == NULL) {
                        ugeth_err("%s: Could not allocate tx_skbuff",
@@ -2958,10 +2958,9 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
        /* Init Rx bds */
        for (j = 0; j < ug_info->numQueuesRx; j++) {
                /* Setup the skbuff rings */
-               ugeth->rx_skbuff[j] =
-                   (struct sk_buff **)kmalloc(sizeof(struct sk_buff *) *
-                                              ugeth->ug_info->bdRingLenRx[j],
-                                              GFP_KERNEL);
+               ugeth->rx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) *
+                                             ugeth->ug_info->bdRingLenRx[j],
+                                             GFP_KERNEL);
 
                if (ugeth->rx_skbuff[j] == NULL) {
                        ugeth_err("%s: Could not allocate rx_skbuff",
@@ -3452,8 +3451,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
         * allocated resources can be released when the channel is freed.
         */
        if (!(ugeth->p_init_enet_param_shadow =
-            (struct ucc_geth_init_pram *) kmalloc(sizeof(struct ucc_geth_init_pram),
-                                             GFP_KERNEL))) {
+             kmalloc(sizeof(struct ucc_geth_init_pram), GFP_KERNEL))) {
                ugeth_err
                    ("%s: Can not allocate memory for"
                        " p_UccInitEnetParamShadows.", __FUNCTION__);
@@ -3920,10 +3918,11 @@ static irqreturn_t phy_interrupt(int irq, void *dev_id)
 }
 
 /* Scheduled by the phy_interrupt/timer to handle PHY changes */
-static void ugeth_phy_change(void *data)
+static void ugeth_phy_change(struct work_struct *work)
 {
-       struct net_device *dev = (struct net_device *)data;
-       struct ucc_geth_private *ugeth = netdev_priv(dev);
+       struct ucc_geth_private *ugeth =
+               container_of(work, struct ucc_geth_private, tq);
+       struct net_device *dev = ugeth->dev;
        struct ucc_geth *ug_regs;
        int result = 0;
 
@@ -4080,7 +4079,7 @@ static int ucc_geth_open(struct net_device *dev)
 #endif                         /* CONFIG_UGETH_NAPI */
 
        /* Set up the PHY change work queue */
-       INIT_WORK(&ugeth->tq, ugeth_phy_change, dev);
+       INIT_WORK(&ugeth->tq, ugeth_phy_change);
 
        init_timer(&ugeth->phy_info_timer);
        ugeth->phy_info_timer.function = &ugeth_phy_startup_timer;