[U-Boot] [PATCH V2 1/5] dm9000: whitespace cleanups

Andrew Ruder andrew.ruder at elecsyscorp.com
Wed Aug 12 19:24:02 CEST 2015


Signed-off-by: Andrew Ruder <andrew.ruder at elecsyscorp.com>
Cc: Joe Hershberger <joe.hershberger at gmail.com>
---
 drivers/net/dm9000x.c | 108 ++++++++++++++++++++++++--------------------------
 1 file changed, 52 insertions(+), 56 deletions(-)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index 3c41cec..415c4b7 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -29,7 +29,7 @@ v1.2   03/18/2003       Weilun Huang <weilun_huang at davicom.com.tw>:
 --------------------------------------
 
        12/15/2003       Initial port to u-boot by
-       			Sascha Hauer <saschahauer at web.de>
+			Sascha Hauer <saschahauer at web.de>
 
        06/03/2008	Remy Bohmer <linux at bohmer.net>
 			- Fixed the driver to work with DM9000A.
@@ -46,7 +46,6 @@ v1.2   03/18/2003       Weilun Huang <weilun_huang at davicom.com.tw>:
 			- some minor code cleanups
 			These changes are tested with DM9000{A,EP,E} together
 			with a 200MHz Atmel AT91SAM9261 core
-
 TODO: external MII is not functional, only internal at the moment.
 */
 
@@ -63,20 +62,20 @@ TODO: external MII is not functional, only internal at the moment.
 /* #define CONFIG_DM9000_DEBUG */
 
 #ifdef CONFIG_DM9000_DEBUG
-#define DM9000_DBG(fmt,args...) printf(fmt, ##args)
-#define DM9000_DMP_PACKET(func,packet,length)  \
+#define DM9000_DBG(fmt, args...) printf(fmt, ##args)
+#define DM9000_DMP_PACKET(func, packet, length)  \
 	do { \
-		int i; 							\
+		int i;							\
 		printf("%s: length: %d\n", func, length);		\
 		for (i = 0; i < length; i++) {				\
 			if (i % 8 == 0)					\
 				printf("\n%s: %02x: ", func, i);	\
-			printf("%02x ", ((unsigned char *) packet)[i]);	\
+			printf("%02x ", ((unsigned char *)packet)[i]);	\
 		} printf("\n");						\
-	} while(0)
+	} while (0)
 #else
-#define DM9000_DBG(fmt,args...)
-#define DM9000_DMP_PACKET(func,packet,length)
+#define DM9000_DBG(fmt, args...) do {} while (0)
+#define DM9000_DMP_PACKET(func, packet, length) do {} while (0)
 #endif
 
 /* Structure/enum declaration ------------------------------- */
@@ -92,9 +91,9 @@ typedef struct board_info {
 	u8 phy_addr;
 	u8 device_wait_reset;	/* device state */
 	unsigned char srom[128];
-	void (*outblk)(volatile void *data_ptr, int count);
+	void (*outblk)(void *data_ptr, int count);
 	void (*inblk)(void *data_ptr, int count);
-	void (*rx_status)(u16 *RxStatus, u16 *RxLen);
+	void (*rx_status)(u16 *rx_status, u16 *rx_len);
 	struct eth_device netdev;
 } board_info_t;
 static board_info_t dm9000_info;
@@ -109,12 +108,12 @@ static void DM9000_iow(int reg, u8 value);
 
 /* DM9000 network board routine ---------------------------- */
 #ifndef CONFIG_DM9000_BYTE_SWAPPED
-#define DM9000_outb(d,r) writeb(d, (volatile u8 *)(r))
-#define DM9000_outw(d,r) writew(d, (volatile u16 *)(r))
-#define DM9000_outl(d,r) writel(d, (volatile u32 *)(r))
-#define DM9000_inb(r) readb((volatile u8 *)(r))
-#define DM9000_inw(r) readw((volatile u16 *)(r))
-#define DM9000_inl(r) readl((volatile u32 *)(r))
+#define DM9000_outb(d, r) writeb(d, (u8 *)(r))
+#define DM9000_outw(d, r) writew(d, (u16 *)(r))
+#define DM9000_outl(d, r) writel(d, (u32 *)(r))
+#define DM9000_inb(r) readb((u8 *)(r))
+#define DM9000_inw(r) readw((u16 *)(r))
+#define DM9000_inl(r) readl((u32 *)(r))
 #else
 #define DM9000_outb(d, r) __raw_writeb(d, r)
 #define DM9000_outw(d, r) __raw_writew(d, r)
@@ -141,35 +140,35 @@ dump_regs(void)
 }
 #endif
 
-static void dm9000_outblk_8bit(volatile void *data_ptr, int count)
+static void dm9000_outblk_8bit(void *data_ptr, int count)
 {
 	int i;
 	for (i = 0; i < count; i++)
-		DM9000_outb((((u8 *) data_ptr)[i] & 0xff), DM9000_DATA);
+		DM9000_outb((((u8 *)data_ptr)[i] & 0xff), DM9000_DATA);
 }
 
-static void dm9000_outblk_16bit(volatile void *data_ptr, int count)
+static void dm9000_outblk_16bit(void *data_ptr, int count)
 {
 	int i;
 	u32 tmplen = (count + 1) / 2;
 
 	for (i = 0; i < tmplen; i++)
-		DM9000_outw(((u16 *) data_ptr)[i], DM9000_DATA);
+		DM9000_outw(((u16 *)data_ptr)[i], DM9000_DATA);
 }
-static void dm9000_outblk_32bit(volatile void *data_ptr, int count)
+static void dm9000_outblk_32bit(void *data_ptr, int count)
 {
 	int i;
 	u32 tmplen = (count + 3) / 4;
 
 	for (i = 0; i < tmplen; i++)
-		DM9000_outl(((u32 *) data_ptr)[i], DM9000_DATA);
+		DM9000_outl(((u32 *)data_ptr)[i], DM9000_DATA);
 }
 
 static void dm9000_inblk_8bit(void *data_ptr, int count)
 {
 	int i;
 	for (i = 0; i < count; i++)
-		((u8 *) data_ptr)[i] = DM9000_inb(DM9000_DATA);
+		((u8 *)data_ptr)[i] = DM9000_inb(DM9000_DATA);
 }
 
 static void dm9000_inblk_16bit(void *data_ptr, int count)
@@ -178,7 +177,7 @@ static void dm9000_inblk_16bit(void *data_ptr, int count)
 	u32 tmplen = (count + 1) / 2;
 
 	for (i = 0; i < tmplen; i++)
-		((u16 *) data_ptr)[i] = DM9000_inw(DM9000_DATA);
+		((u16 *)data_ptr)[i] = DM9000_inw(DM9000_DATA);
 }
 static void dm9000_inblk_32bit(void *data_ptr, int count)
 {
@@ -186,36 +185,36 @@ static void dm9000_inblk_32bit(void *data_ptr, int count)
 	u32 tmplen = (count + 3) / 4;
 
 	for (i = 0; i < tmplen; i++)
-		((u32 *) data_ptr)[i] = DM9000_inl(DM9000_DATA);
+		((u32 *)data_ptr)[i] = DM9000_inl(DM9000_DATA);
 }
 
-static void dm9000_rx_status_32bit(u16 *RxStatus, u16 *RxLen)
+static void dm9000_rx_status_32bit(u16 *rx_status, u16 *rx_len)
 {
 	u32 tmpdata;
 
 	DM9000_outb(DM9000_MRCMD, DM9000_IO);
 
 	tmpdata = DM9000_inl(DM9000_DATA);
-	*RxStatus = __le16_to_cpu(tmpdata);
-	*RxLen = __le16_to_cpu(tmpdata >> 16);
+	*rx_status = __le16_to_cpu(tmpdata);
+	*rx_len = __le16_to_cpu(tmpdata >> 16);
 }
 
-static void dm9000_rx_status_16bit(u16 *RxStatus, u16 *RxLen)
+static void dm9000_rx_status_16bit(u16 *rx_status, u16 *rx_len)
 {
 	DM9000_outb(DM9000_MRCMD, DM9000_IO);
 
-	*RxStatus = __le16_to_cpu(DM9000_inw(DM9000_DATA));
-	*RxLen = __le16_to_cpu(DM9000_inw(DM9000_DATA));
+	*rx_status = __le16_to_cpu(DM9000_inw(DM9000_DATA));
+	*rx_len = __le16_to_cpu(DM9000_inw(DM9000_DATA));
 }
 
-static void dm9000_rx_status_8bit(u16 *RxStatus, u16 *RxLen)
+static void dm9000_rx_status_8bit(u16 *rx_status, u16 *rx_len)
 {
 	DM9000_outb(DM9000_MRCMD, DM9000_IO);
 
-	*RxStatus =
+	*rx_status =
 	    __le16_to_cpu(DM9000_inb(DM9000_DATA) +
 			  (DM9000_inb(DM9000_DATA) << 8));
-	*RxLen =
+	*rx_len =
 	    __le16_to_cpu(DM9000_inb(DM9000_DATA) +
 			  (DM9000_inb(DM9000_DATA) << 8));
 }
@@ -232,7 +231,7 @@ dm9000_probe(void)
 	id_val |= DM9000_ior(DM9000_PIDL) << 16;
 	id_val |= DM9000_ior(DM9000_PIDH) << 24;
 	if (id_val == DM9000_ID) {
-		printf("dm9000 i/o: 0x%x, id: 0x%x \n", CONFIG_DM9000_BASE,
+		printf("dm9000 i/o: 0x%x, id: 0x%x\n", CONFIG_DM9000_BASE,
 		       id_val);
 		return 0;
 	} else {
@@ -264,7 +263,8 @@ dm9000_reset(void)
 	} while (DM9000_ior(DM9000_NCR) & 1);
 
 	DM9000_iow(DM9000_NCR, 0);
-	DM9000_iow(DM9000_NCR, (NCR_LBK_INT_MAC | NCR_RST)); /* Issue a second reset */
+	/* Issue a second reset */
+	DM9000_iow(DM9000_NCR, (NCR_LBK_INT_MAC | NCR_RST));
 
 	do {
 		DM9000_DBG("resetting the DM9000, 2nd reset\n");
@@ -425,8 +425,8 @@ static int dm9000_send(struct eth_device *netdev, void *packet, int length)
 
 	/* wait for end of transmission */
 	tmo = get_timer(0) + 5 * CONFIG_SYS_HZ;
-	while ( !(DM9000_ior(DM9000_NSR) & (NSR_TX1END | NSR_TX2END)) ||
-		!(DM9000_ior(DM9000_ISR) & IMR_PTM) ) {
+	while (!(DM9000_ior(DM9000_NSR) & (NSR_TX1END | NSR_TX2END)) ||
+	       !(DM9000_ior(DM9000_ISR) & IMR_PTM)) {
 		if (get_timer(0) >= tmo) {
 			printf("transmission timeout\n");
 			break;
@@ -460,7 +460,7 @@ static int dm9000_rx(struct eth_device *netdev)
 {
 	u8 rxbyte;
 	u8 *rdptr = (u8 *)net_rx_packets[0];
-	u16 RxStatus, RxLen = 0;
+	u16 rx_status, rx_len = 0;
 	struct board_info *db = &dm9000_info;
 
 	/* Check packet ready or not, we must check
@@ -483,7 +483,7 @@ static int dm9000_rx(struct eth_device *netdev)
 			DM9000_iow(DM9000_RCR, 0x00);	/* Stop Device */
 			DM9000_iow(DM9000_ISR, 0x80);	/* Stop INT request */
 			printf("DM9000 error: status check fail: 0x%x\n",
-				rxbyte);
+			       rxbyte);
 			return 0;
 		}
 
@@ -493,34 +493,31 @@ static int dm9000_rx(struct eth_device *netdev)
 		DM9000_DBG("receiving packet\n");
 
 		/* A packet ready now  & Get status/length */
-		(db->rx_status)(&RxStatus, &RxLen);
+		(db->rx_status)(&rx_status, &rx_len);
 
-		DM9000_DBG("rx status: 0x%04x rx len: %d\n", RxStatus, RxLen);
+		DM9000_DBG("rx status: 0x%04x rx len: %d\n", rx_status, rx_len);
 
 		/* Move data from DM9000 */
 		/* Read received packet from RX SRAM */
-		(db->inblk)(rdptr, RxLen);
+		(db->inblk)(rdptr, rx_len);
 
-		if ((RxStatus & 0xbf00) || (RxLen < 0x40)
-			|| (RxLen > DM9000_PKT_MAX)) {
-			if (RxStatus & 0x100) {
+		if ((rx_status & 0xbf00) || (rx_len < 0x40) ||
+		    (rx_len > DM9000_PKT_MAX)) {
+			if (rx_status & 0x100)
 				printf("rx fifo error\n");
-			}
-			if (RxStatus & 0x200) {
+			if (rx_status & 0x200)
 				printf("rx crc error\n");
-			}
-			if (RxStatus & 0x8000) {
+			if (rx_status & 0x8000)
 				printf("rx length error\n");
-			}
-			if (RxLen > DM9000_PKT_MAX) {
+			if (rx_len > DM9000_PKT_MAX) {
 				printf("rx length too big\n");
 				dm9000_reset();
 			}
 		} else {
-			DM9000_DMP_PACKET(__func__ , rdptr, RxLen);
+			DM9000_DMP_PACKET(__func__ , rdptr, rx_len);
 
 			DM9000_DBG("passing packet to upper layer\n");
-			net_process_received_packet(net_rx_packets[0], RxLen);
+			net_process_received_packet(net_rx_packets[0], rx_len);
 		}
 	}
 	return 0;
@@ -606,7 +603,6 @@ dm9000_phy_read(int reg)
 static void
 dm9000_phy_write(int reg, u16 value)
 {
-
 	/* Fill the phyxcer register into REG_0C */
 	DM9000_iow(DM9000_EPAR, DM9000_PHY | reg);
 
-- 
2.1.4



More information about the U-Boot mailing list