Skip to content

Commit 48b48b6

Browse files
committed
Merge branch 'emaclite-cleanups'
Radhey Shyam Pandey says: ==================== net: emaclite: Trivial code cleanup This patchset fix coding style issues, remove BUFFER_ALIGN macro and also update copyright text. I have to resend as earlier series didn't reach mailing list due to some configuration issue. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 81669e7 + 7240bf6 commit 48b48b6

File tree

1 file changed

+18
-37
lines changed

1 file changed

+18
-37
lines changed

drivers/net/ethernet/xilinx/xilinx_emaclite.c

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
2-
/*
3-
* Xilinx EmacLite Linux driver for the Xilinx Ethernet MAC Lite device.
2+
/* Xilinx EmacLite Linux driver for the Xilinx Ethernet MAC Lite device.
43
*
54
* This is a new flat driver which is based on the original emac_lite
65
* driver from John Williams <[email protected]>.
76
*
8-
* 2007 - 2013 (c) Xilinx, Inc.
7+
* Copyright (c) 2007 - 2013 Xilinx, Inc.
98
*/
109

1110
#include <linux/module.h>
@@ -91,13 +90,7 @@
9190
#define XEL_ARP_PACKET_SIZE 28 /* Max ARP packet size */
9291
#define XEL_HEADER_IP_LENGTH_OFFSET 16 /* IP Length Offset */
9392

94-
95-
9693
#define TX_TIMEOUT (60 * HZ) /* Tx timeout is 60 seconds. */
97-
#define ALIGNMENT 4
98-
99-
/* BUFFER_ALIGN(adr) calculates the number of bytes to the next alignment. */
100-
#define BUFFER_ALIGN(adr) ((ALIGNMENT - ((uintptr_t)adr)) % ALIGNMENT)
10194

10295
#ifdef __BIG_ENDIAN
10396
#define xemaclite_readl ioread32be
@@ -124,7 +117,6 @@
124117
* @last_link: last link status
125118
*/
126119
struct net_local {
127-
128120
struct net_device *ndev;
129121

130122
bool tx_ping_pong;
@@ -133,7 +125,7 @@ struct net_local {
133125
u32 next_rx_buf_to_use;
134126
void __iomem *base_addr;
135127

136-
spinlock_t reset_lock;
128+
spinlock_t reset_lock; /* serialize xmit and tx_timeout execution */
137129
struct sk_buff *deferred_skb;
138130

139131
struct phy_device *phy_dev;
@@ -144,7 +136,6 @@ struct net_local {
144136
int last_link;
145137
};
146138

147-
148139
/*************************/
149140
/* EmacLite driver calls */
150141
/*************************/
@@ -207,7 +198,7 @@ static void xemaclite_disable_interrupts(struct net_local *drvdata)
207198
* address in the EmacLite device.
208199
*/
209200
static void xemaclite_aligned_write(const void *src_ptr, u32 *dest_ptr,
210-
unsigned length)
201+
unsigned int length)
211202
{
212203
const u16 *from_u16_ptr;
213204
u32 align_buffer;
@@ -265,7 +256,7 @@ static void xemaclite_aligned_write(const void *src_ptr, u32 *dest_ptr,
265256
* to a 16-bit aligned buffer.
266257
*/
267258
static void xemaclite_aligned_read(u32 *src_ptr, u8 *dest_ptr,
268-
unsigned length)
259+
unsigned int length)
269260
{
270261
u16 *to_u16_ptr, *from_u16_ptr;
271262
u32 *from_u32_ptr;
@@ -330,7 +321,6 @@ static int xemaclite_send_data(struct net_local *drvdata, u8 *data,
330321
reg_data = xemaclite_readl(addr + XEL_TSR_OFFSET);
331322
if ((reg_data & (XEL_TSR_XMIT_BUSY_MASK |
332323
XEL_TSR_XMIT_ACTIVE_MASK)) == 0) {
333-
334324
/* Switch to next buffer if configured */
335325
if (drvdata->tx_ping_pong != 0)
336326
drvdata->next_tx_buf_to_use ^= XEL_BUFFER_OFFSET;
@@ -346,8 +336,9 @@ static int xemaclite_send_data(struct net_local *drvdata, u8 *data,
346336
if ((reg_data & (XEL_TSR_XMIT_BUSY_MASK |
347337
XEL_TSR_XMIT_ACTIVE_MASK)) != 0)
348338
return -1; /* Buffers were full, return failure */
349-
} else
339+
} else {
350340
return -1; /* Buffer was full, return failure */
341+
}
351342

352343
/* Write the frame to the buffer */
353344
xemaclite_aligned_write(data, (u32 __force *)addr, byte_count);
@@ -423,7 +414,6 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data, int maxlen)
423414
* or an IP packet or an ARP packet
424415
*/
425416
if (proto_type > ETH_DATA_LEN) {
426-
427417
if (proto_type == ETH_P_IP) {
428418
length = ((ntohl(xemaclite_readl(addr +
429419
XEL_HEADER_IP_LENGTH_OFFSET +
@@ -433,23 +423,25 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data, int maxlen)
433423
length = min_t(u16, length, ETH_DATA_LEN);
434424
length += ETH_HLEN + ETH_FCS_LEN;
435425

436-
} else if (proto_type == ETH_P_ARP)
426+
} else if (proto_type == ETH_P_ARP) {
437427
length = XEL_ARP_PACKET_SIZE + ETH_HLEN + ETH_FCS_LEN;
438-
else
428+
} else {
439429
/* Field contains type other than IP or ARP, use max
440430
* frame size and let user parse it
441431
*/
442432
length = ETH_FRAME_LEN + ETH_FCS_LEN;
443-
} else
433+
}
434+
} else {
444435
/* Use the length in the frame, plus the header and trailer */
445436
length = proto_type + ETH_HLEN + ETH_FCS_LEN;
437+
}
446438

447439
if (WARN_ON(length > maxlen))
448440
length = maxlen;
449441

450442
/* Read from the EmacLite device */
451443
xemaclite_aligned_read((u32 __force *)(addr + XEL_RXBUFF_OFFSET),
452-
data, length);
444+
data, length);
453445

454446
/* Acknowledge the frame */
455447
reg_data = xemaclite_readl(addr + XEL_RSR_OFFSET);
@@ -599,28 +591,18 @@ static void xemaclite_rx_handler(struct net_device *dev)
599591
{
600592
struct net_local *lp = netdev_priv(dev);
601593
struct sk_buff *skb;
602-
unsigned int align;
603594
u32 len;
604595

605596
len = ETH_FRAME_LEN + ETH_FCS_LEN;
606-
skb = netdev_alloc_skb(dev, len + ALIGNMENT);
597+
skb = netdev_alloc_skb(dev, len + NET_IP_ALIGN);
607598
if (!skb) {
608599
/* Couldn't get memory. */
609600
dev->stats.rx_dropped++;
610601
dev_err(&lp->ndev->dev, "Could not allocate receive buffer\n");
611602
return;
612603
}
613604

614-
/* A new skb should have the data halfword aligned, but this code is
615-
* here just in case that isn't true. Calculate how many
616-
* bytes we should reserve to get the data to start on a word
617-
* boundary
618-
*/
619-
align = BUFFER_ALIGN(skb->data);
620-
if (align)
621-
skb_reserve(skb, align);
622-
623-
skb_reserve(skb, 2);
605+
skb_reserve(skb, NET_IP_ALIGN);
624606

625607
len = xemaclite_recv_data(lp, (u8 *)skb->data, len);
626608

@@ -671,8 +653,7 @@ static irqreturn_t xemaclite_interrupt(int irq, void *dev_id)
671653
/* Check if the Transmission for the first buffer is completed */
672654
tx_status = xemaclite_readl(base_addr + XEL_TSR_OFFSET);
673655
if (((tx_status & XEL_TSR_XMIT_BUSY_MASK) == 0) &&
674-
(tx_status & XEL_TSR_XMIT_ACTIVE_MASK) != 0) {
675-
656+
(tx_status & XEL_TSR_XMIT_ACTIVE_MASK) != 0) {
676657
tx_status &= ~XEL_TSR_XMIT_ACTIVE_MASK;
677658
xemaclite_writel(tx_status, base_addr + XEL_TSR_OFFSET);
678659

@@ -682,8 +663,7 @@ static irqreturn_t xemaclite_interrupt(int irq, void *dev_id)
682663
/* Check if the Transmission for the second buffer is completed */
683664
tx_status = xemaclite_readl(base_addr + XEL_BUFFER_OFFSET + XEL_TSR_OFFSET);
684665
if (((tx_status & XEL_TSR_XMIT_BUSY_MASK) == 0) &&
685-
(tx_status & XEL_TSR_XMIT_ACTIVE_MASK) != 0) {
686-
666+
(tx_status & XEL_TSR_XMIT_ACTIVE_MASK) != 0) {
687667
tx_status &= ~XEL_TSR_XMIT_ACTIVE_MASK;
688668
xemaclite_writel(tx_status, base_addr + XEL_BUFFER_OFFSET +
689669
XEL_TSR_OFFSET);
@@ -840,6 +820,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
840820
of_address_to_resource(npp, 0, &res);
841821
if (lp->ndev->mem_start != res.start) {
842822
struct phy_device *phydev;
823+
843824
phydev = of_phy_find_device(lp->phy_node);
844825
if (!phydev)
845826
dev_info(dev,

0 commit comments

Comments
 (0)