]> rtime.felk.cvut.cz Git - vajnamar/linux-xlnx.git/commitdiff
net: emaclite: Fix coding style violations
authorKedareswara rao Appana <appana.durga.rao@xilinx.com>
Thu, 23 Mar 2017 14:14:16 +0000 (19:44 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Mon, 29 May 2017 10:25:43 +0000 (12:25 +0200)
This patch fixes the checkpatch.pl warnings in the
driver.

Signed-off-by: Kedareswara rao Appana <appanad@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/net/ethernet/xilinx/xilinx_emaclite.c

index 3db8ac4330bdb8fed21a1299402b4362d892f511..e3b0f82c679ac08c909ad9d419f08a9808d863c2 100644 (file)
@@ -70,7 +70,8 @@
 #define XEL_TSR_XMIT_IE_MASK    0x00000008     /* Tx interrupt enable bit */
 #define XEL_TSR_XMIT_ACTIVE_MASK 0x80000000    /* Buffer is active, SW bit
                                                 * only. This is not documented
-                                                * in the HW spec */
+                                                * in the HW spec
+                                                */
 
 /* Define for programming the MAC address into the EmacLite */
 #define XEL_TSR_PROG_MAC_ADDR  (XEL_TSR_XMIT_BUSY_MASK | XEL_TSR_PROGRAM_MASK)
@@ -92,9 +93,7 @@
 #define XEL_ARP_PACKET_SIZE            28      /* Max ARP packet size */
 #define XEL_HEADER_IP_LENGTH_OFFSET    16      /* IP Length Offset */
 
-
-
-#define TX_TIMEOUT             (60*HZ)         /* Tx timeout is 60 seconds. */
+#define TX_TIMEOUT             (60 * HZ)       /* Tx timeout is 60 seconds. */
 #define ALIGNMENT              4
 
 /* BUFFER_ALIGN(adr) calculates the number of bytes to the next alignment. */
  * @has_mdio:          indicates whether MDIO is included in the HW
  */
 struct net_local {
-
        struct net_device *ndev;
 
        bool tx_ping_pong;
@@ -127,7 +125,7 @@ struct net_local {
        u32 next_rx_buf_to_use;
        void __iomem *base_addr;
 
-       spinlock_t reset_lock;
+       spinlock_t reset_lock; /* lock used for synchronization */
        struct sk_buff *deferred_skb;
 
        struct phy_device *phy_dev;
@@ -139,7 +137,6 @@ struct net_local {
        bool has_mdio;
 };
 
-
 /*************************/
 /* EmacLite driver calls */
 /*************************/
@@ -202,7 +199,7 @@ static void xemaclite_disable_interrupts(struct net_local *drvdata)
  * address in the EmacLite device.
  */
 static void xemaclite_aligned_write(void *src_ptr, u32 *dest_ptr,
-                                   unsigned length)
+                                   unsigned int length)
 {
        u32 align_buffer;
        u32 *to_u32_ptr;
@@ -232,8 +229,8 @@ static void xemaclite_aligned_write(void *src_ptr, u32 *dest_ptr,
 
                /* Set up to output the remaining data */
                align_buffer = 0;
-               to_u8_ptr = (u8 *) &align_buffer;
-               from_u8_ptr = (u8 *) from_u16_ptr;
+               to_u8_ptr = (u8 *)&align_buffer;
+               from_u8_ptr = (u8 *)from_u16_ptr;
 
                /* Output the remaining data */
                for (; length > 0; length--)
@@ -259,14 +256,14 @@ static void xemaclite_aligned_write(void *src_ptr, u32 *dest_ptr,
  * to a 16-bit aligned buffer.
  */
 static void xemaclite_aligned_read(u32 *src_ptr, u8 *dest_ptr,
-                                  unsigned length)
+                                  unsigned int length)
 {
        u16 *to_u16_ptr, *from_u16_ptr;
        u32 *from_u32_ptr;
        u32 align_buffer;
 
        from_u32_ptr = src_ptr;
-       to_u16_ptr = (u16 *) dest_ptr;
+       to_u16_ptr = (u16 *)dest_ptr;
 
        for (; length > 3; length -= 4) {
                /* Copy each word into the temporary buffer */
@@ -282,9 +279,9 @@ static void xemaclite_aligned_read(u32 *src_ptr, u8 *dest_ptr,
                u8 *to_u8_ptr, *from_u8_ptr;
 
                /* Set up to read the remaining data */
-               to_u8_ptr = (u8 *) to_u16_ptr;
+               to_u8_ptr = (u8 *)to_u16_ptr;
                align_buffer = *from_u32_ptr++;
-               from_u8_ptr = (u8 *) &align_buffer;
+               from_u8_ptr = (u8 *)&align_buffer;
 
                /* Read the remaining data */
                for (; length > 0; length--)
@@ -324,13 +321,13 @@ static int xemaclite_send_data(struct net_local *drvdata, u8 *data,
        reg_data = __raw_readl(addr + XEL_TSR_OFFSET);
        if ((reg_data & (XEL_TSR_XMIT_BUSY_MASK |
             XEL_TSR_XMIT_ACTIVE_MASK)) == 0) {
-
                /* Switch to next buffer if configured */
                if (drvdata->tx_ping_pong != 0)
                        drvdata->next_tx_buf_to_use ^= XEL_BUFFER_OFFSET;
        } else if (drvdata->tx_ping_pong != 0) {
                /* If the expected buffer is full, try the other buffer,
-                * if it is configured in HW */
+                * if it is configured in HW
+                */
 
                addr = (void __iomem __force *)((ulong __force)addr ^
                                                 XEL_BUFFER_OFFSET);
@@ -339,11 +336,12 @@ static int xemaclite_send_data(struct net_local *drvdata, u8 *data,
                if ((reg_data & (XEL_TSR_XMIT_BUSY_MASK |
                     XEL_TSR_XMIT_ACTIVE_MASK)) != 0)
                        return -1; /* Buffers were full, return failure */
-       } else
+       } else {
                return -1; /* Buffer was full, return failure */
+       }
 
        /* Write the frame to the buffer */
-       xemaclite_aligned_write(data, (u32 __force *) addr, byte_count);
+       xemaclite_aligned_write(data, (u32 __force *)addr, byte_count);
 
        __raw_writel((byte_count & XEL_TPLR_LENGTH_MASK),
                     addr + XEL_TPLR_OFFSET);
@@ -351,7 +349,8 @@ static int xemaclite_send_data(struct net_local *drvdata, u8 *data,
        /* Update the Tx Status Register to indicate that there is a
         * frame to send. Set the XEL_TSR_XMIT_ACTIVE_MASK flag which
         * is used by the interrupt handler to check whether a frame
-        * has been transmitted */
+        * has been transmitted
+        */
        reg_data = __raw_readl(addr + XEL_TSR_OFFSET);
        reg_data |= (XEL_TSR_XMIT_BUSY_MASK | XEL_TSR_XMIT_ACTIVE_MASK);
        __raw_writel(reg_data, addr + XEL_TSR_OFFSET);
@@ -388,7 +387,8 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
                /* The instance is out of sync, try other buffer if other
                 * buffer is configured, return 0 otherwise. If the instance is
                 * out of sync, do not update the 'next_rx_buf_to_use' since it
-                * will correct on subsequent calls */
+                * will correct on subsequent calls
+                */
                if (drvdata->rx_ping_pong != 0)
                        addr = (void __iomem __force *)((ulong __force)addr ^
                                                         XEL_BUFFER_OFFSET);
@@ -408,9 +408,9 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
                        XEL_RPLR_LENGTH_MASK);
 
        /* Check if received ethernet frame is a raw ethernet frame
-        * or an IP packet or an ARP packet */
+        * or an IP packet or an ARP packet
+        */
        if (proto_type > (ETH_FRAME_LEN + ETH_FCS_LEN)) {
-
                if (proto_type == ETH_P_IP) {
                        length = ((ntohl(__raw_readl(addr +
                                        XEL_HEADER_IP_LENGTH_OFFSET +
@@ -419,19 +419,21 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
                                        XEL_RPLR_LENGTH_MASK);
                        length += ETH_HLEN + ETH_FCS_LEN;
 
-               } else if (proto_type == ETH_P_ARP)
+               } else if (proto_type == ETH_P_ARP) {
                        length = XEL_ARP_PACKET_SIZE + ETH_HLEN + ETH_FCS_LEN;
-               else
+               } else {
                        /* Field contains type other than IP or ARP, use max
-                        * frame size and let user parse it */
+                        * frame size and let user parse it
+                        */
                        length = ETH_FRAME_LEN + ETH_FCS_LEN;
+               }
        } else
                /* Use the length in the frame, plus the header and trailer */
                length = proto_type + ETH_HLEN + ETH_FCS_LEN;
 
        /* Read from the EmacLite device */
-       xemaclite_aligned_read((u32 __force *) (addr + XEL_RXBUFF_OFFSET),
-                               data, length);
+       xemaclite_aligned_read((u32 __force *)(addr + XEL_RXBUFF_OFFSET),
+                              data, length);
 
        /* Acknowledge the frame */
        reg_data = __raw_readl(addr + XEL_RSR_OFFSET);
@@ -461,7 +463,7 @@ static void xemaclite_update_address(struct net_local *drvdata,
        /* Determine the expected Tx buffer address */
        addr = drvdata->base_addr + drvdata->next_tx_buf_to_use;
 
-       xemaclite_aligned_write(address_ptr, (u32 __force *) addr, ETH_ALEN);
+       xemaclite_aligned_write(address_ptr, (u32 __force *)addr, ETH_ALEN);
 
        __raw_writel(ETH_ALEN, addr + XEL_TPLR_OFFSET);
 
@@ -556,9 +558,9 @@ static void xemaclite_tx_handler(struct net_device *dev)
        dev->stats.tx_packets++;
        if (lp->deferred_skb) {
                if (xemaclite_send_data(lp,
-                                       (u8 *) lp->deferred_skb->data,
+                                       (u8 *)lp->deferred_skb->data,
                                        lp->deferred_skb->len) != 0)
-                       return;
+                       goto out;
                else {
                        dev->stats.tx_bytes += lp->deferred_skb->len;
                        dev_kfree_skb_irq(lp->deferred_skb);
@@ -567,6 +569,9 @@ static void xemaclite_tx_handler(struct net_device *dev)
                        netif_wake_queue(dev);
                }
        }
+
+out:
+       return;
 }
 
 /**
@@ -592,18 +597,18 @@ static void xemaclite_rx_handler(struct net_device *dev)
                return;
        }
 
-       /*
-        * A new skb should have the data halfword aligned, but this code is
+       /* A new skb should have the data halfword aligned, but this code is
         * here just in case that isn't true. Calculate how many
         * bytes we should reserve to get the data to start on a word
-        * boundary */
+        * boundary
+        */
        align = BUFFER_ALIGN(skb->data);
        if (align)
                skb_reserve(skb, align);
 
        skb_reserve(skb, 2);
 
-       len = xemaclite_recv_data(lp, (u8 *) skb->data);
+       len = xemaclite_recv_data(lp, (u8 *)skb->data);
 
        if (!len) {
                dev->stats.rx_errors++;
@@ -652,8 +657,7 @@ static irqreturn_t xemaclite_interrupt(int irq, void *dev_id)
        /* Check if the Transmission for the first buffer is completed */
        tx_status = __raw_readl(base_addr + XEL_TSR_OFFSET);
        if (((tx_status & XEL_TSR_XMIT_BUSY_MASK) == 0) &&
-               (tx_status & XEL_TSR_XMIT_ACTIVE_MASK) != 0) {
-
+           (tx_status & XEL_TSR_XMIT_ACTIVE_MASK) != 0) {
                tx_status &= ~XEL_TSR_XMIT_ACTIVE_MASK;
                __raw_writel(tx_status, base_addr + XEL_TSR_OFFSET);
 
@@ -663,8 +667,7 @@ static irqreturn_t xemaclite_interrupt(int irq, void *dev_id)
        /* Check if the Transmission for the second buffer is completed */
        tx_status = __raw_readl(base_addr + XEL_BUFFER_OFFSET + XEL_TSR_OFFSET);
        if (((tx_status & XEL_TSR_XMIT_BUSY_MASK) == 0) &&
-               (tx_status & XEL_TSR_XMIT_ACTIVE_MASK) != 0) {
-
+           (tx_status & XEL_TSR_XMIT_ACTIVE_MASK) != 0) {
                tx_status &= ~XEL_TSR_XMIT_ACTIVE_MASK;
                __raw_writel(tx_status, base_addr + XEL_BUFFER_OFFSET +
                             XEL_TSR_OFFSET);
@@ -698,15 +701,15 @@ static int xemaclite_mdio_wait(struct net_local *lp)
        unsigned long end = jiffies + 2;
 
        /* wait for the MDIO interface to not be busy or timeout
-          after some time.
-       */
+        * after some time.
+        */
        while (__raw_readl(lp->base_addr + XEL_MDIOCTRL_OFFSET) &
                        XEL_MDIOCTRL_MDIOSTS_MASK) {
                if (time_before_eq(end, jiffies)) {
                        WARN_ON(1);
                        return -ETIMEDOUT;
                }
-               msleep(1);
+               msleep(20);
        }
        return 0;
 }
@@ -826,6 +829,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
        of_address_to_resource(npp, 0, &res);
        if (lp->ndev->mem_start != res.start) {
                struct phy_device *phydev;
+
                phydev = of_phy_find_device(lp->phy_node);
                if (!phydev)
                        dev_info(dev,
@@ -1017,10 +1021,11 @@ static int xemaclite_send(struct sk_buff *orig_skb, struct net_device *dev)
        new_skb = orig_skb;
 
        spin_lock_irqsave(&lp->reset_lock, flags);
-       if (xemaclite_send_data(lp, (u8 *) new_skb->data, len) != 0) {
+       if (xemaclite_send_data(lp, (u8 *)new_skb->data, len) != 0) {
                /* If the Emaclite Tx buffer is busy, stop the Tx queue and
                 * defer the skb for transmission during the ISR, after the
-                * current transmission is complete */
+                * current transmission is complete
+                */
                netif_stop_queue(dev);
                lp->deferred_skb = new_skb;
                /* Take the time stamp now, since we can't do this in an ISR. */
@@ -1047,9 +1052,8 @@ static int xemaclite_send(struct sk_buff *orig_skb, struct net_device *dev)
  */
 static void xemaclite_remove_ndev(struct net_device *ndev)
 {
-       if (ndev) {
+       if (ndev)
                free_netdev(ndev);
-       }
 }
 
 /**
@@ -1067,15 +1071,18 @@ static bool get_bool(struct platform_device *ofdev, const char *s)
        u32 *p = (u32 *)of_get_property(ofdev->dev.of_node, s, NULL);
 
        if (p) {
-               return (bool)*p;
+               goto out;
        } else {
-               dev_warn(&ofdev->dev, "Parameter %s not found,"
-                       "defaulting to false\n", s);
+               dev_warn(&ofdev->dev, "Parameter %s not found", s);
+               dev_warn(&ofdev->dev, " defaulting to false\n");
                return false;
        }
+
+out:
+       return (bool)*p;
 }
 
-static struct net_device_ops xemaclite_netdev_ops;
+static const struct net_device_ops xemaclite_netdev_ops;
 
 /**
  * xemaclite_of_probe - Probe method for the Emaclite device.
@@ -1228,7 +1235,7 @@ xemaclite_poll_controller(struct net_device *ndev)
 }
 #endif
 
-static struct net_device_ops xemaclite_netdev_ops = {
+static const struct net_device_ops xemaclite_netdev_ops = {
        .ndo_open               = xemaclite_open,
        .ndo_stop               = xemaclite_close,
        .ndo_start_xmit         = xemaclite_send,