netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] r6040: cleanups
@ 2012-01-04 18:59 Florian Fainelli
  2012-01-04 18:59 ` [PATCH 1/6] r6040: remove unused variables and definitions Florian Fainelli
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Florian Fainelli @ 2012-01-04 18:59 UTC (permalink / raw)
  To: davem; +Cc: netdev, Florian Fainelli

This series cleanups the r6040 driver by:
- using appropriate definitions instead of bits values
- fixing checkpatch errors and warnings

Florian Fainelli (6):
  r6040: remove unused variables and definitions
  r6040: define more MCR0 register bits
  r6040: use MAC_RST bit definition with MCR1 read/writes
  r6040: use definitions for MAC_SM register read/writes
  r6040: use __aligned(size)
  r6040: place comments before code

 drivers/net/ethernet/rdc/r6040.c |   39 +++++++++++++++----------------------
 1 files changed, 16 insertions(+), 23 deletions(-)

-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/6] r6040: remove unused variables and definitions
  2012-01-04 18:59 [PATCH 0/6] r6040: cleanups Florian Fainelli
@ 2012-01-04 18:59 ` Florian Fainelli
  2012-01-04 18:59 ` [PATCH 2/6] r6040: define more MCR0 register bits Florian Fainelli
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2012-01-04 18:59 UTC (permalink / raw)
  To: davem; +Cc: netdev, Florian Fainelli

Since the conversion to phylib (3831861b: r6040: implement phylib) some
PHY-related variables and definitions are now useless, remove them.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
---
 drivers/net/ethernet/rdc/r6040.c |   14 +-------------
 1 files changed, 1 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c
index a63b23f..c2135f2 100644
--- a/drivers/net/ethernet/rdc/r6040.c
+++ b/drivers/net/ethernet/rdc/r6040.c
@@ -52,12 +52,6 @@
 #define DRV_VERSION	"0.28"
 #define DRV_RELDATE	"07Oct2011"
 
-/* PHY CHIP Address */
-#define PHY1_ADDR	1	/* For MAC1 */
-#define PHY2_ADDR	3	/* For MAC2 */
-#define PHY_MODE	0x3100	/* PHY CHIP Register 0 */
-#define PHY_CAP		0x01E1	/* PHY CHIP Register 4 */
-
 /* Time in jiffies before concluding the transmitter is hung. */
 #define TX_TIMEOUT	(6000 * HZ / 1000)
 
@@ -154,9 +148,6 @@
 #define DSC_RX_MIDH_HIT	0x0004	/* RX MID table hit (no error) */
 #define DSC_RX_IDX_MID_MASK 3	/* RX mask for the index of matched MIDx */
 
-/* PHY settings */
-#define ICPLUS_PHY_ID	0x0243
-
 MODULE_AUTHOR("Sten Wang <sten.wang@rdc.com.tw>,"
 	"Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>,"
 	"Florian Fainelli <florian@openwrt.org>");
@@ -191,7 +182,7 @@ struct r6040_private {
 	struct r6040_descriptor *tx_ring;
 	dma_addr_t rx_ring_dma;
 	dma_addr_t tx_ring_dma;
-	u16	tx_free_desc, phy_addr;
+	u16	tx_free_desc;
 	u16	mcr0, mcr1;
 	struct net_device *dev;
 	struct mii_bus *mii_bus;
@@ -206,8 +197,6 @@ static char version[] __devinitdata = DRV_NAME
 	": RDC R6040 NAPI net driver,"
 	"version "DRV_VERSION " (" DRV_RELDATE ")";
 
-static int phy_table[] = { PHY1_ADDR, PHY2_ADDR };
-
 /* Read a word data from PHY Chip */
 static int r6040_phy_read(void __iomem *ioaddr, int phy_addr, int reg)
 {
@@ -1167,7 +1156,6 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
 
 	/* Init RDC private data */
 	lp->mcr0 = 0x1002;
-	lp->phy_addr = phy_table[card_idx];
 
 	/* The RDC-specific entries in the device structure. */
 	dev->netdev_ops = &r6040_netdev_ops;
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/6] r6040: define more MCR0 register bits
  2012-01-04 18:59 [PATCH 0/6] r6040: cleanups Florian Fainelli
  2012-01-04 18:59 ` [PATCH 1/6] r6040: remove unused variables and definitions Florian Fainelli
@ 2012-01-04 18:59 ` Florian Fainelli
  2012-01-04 18:59 ` [PATCH 3/6] r6040: use MAC_RST bit definition with MCR1 read/writes Florian Fainelli
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2012-01-04 18:59 UTC (permalink / raw)
  To: davem; +Cc: netdev, Florian Fainelli

Define more MCR0-register bits and use them in place of the bits values.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
---
 drivers/net/ethernet/rdc/r6040.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c
index c2135f2..f4dddcee 100644
--- a/drivers/net/ethernet/rdc/r6040.c
+++ b/drivers/net/ethernet/rdc/r6040.c
@@ -63,8 +63,11 @@
 
 /* MAC registers */
 #define MCR0		0x00	/* Control register 0 */
+#define  MCR0_RCVEN	0x0002	/* Receive enable */
 #define  MCR0_PROMISC	0x0020	/* Promiscuous mode */
 #define  MCR0_HASH_EN	0x0100	/* Enable multicast hash table function */
+#define  MCR0_XMTEN	0x1000	/* Transmission enable */
+#define  MCR0_FD	0x8000	/* Full/Half duplex */
 #define MCR1		0x04	/* Control register 1 */
 #define  MAC_RST	0x0001	/* Reset the MAC */
 #define MBCR		0x08	/* Bus control */
@@ -398,7 +401,7 @@ static void r6040_init_mac_regs(struct net_device *dev)
 	iowrite16(INT_MASK, ioaddr + MIER);
 
 	/* Enable TX and RX */
-	iowrite16(lp->mcr0 | 0x0002, ioaddr);
+	iowrite16(lp->mcr0 | MCR0_RCVEN, ioaddr);
 
 	/* Let TX poll the descriptors
 	 * we may got called by r6040_tx_timeout which has left
@@ -1002,7 +1005,7 @@ static void r6040_adjust_link(struct net_device *dev)
 
 	/* reflect duplex change */
 	if (phydev->link && (lp->old_duplex != phydev->duplex)) {
-		lp->mcr0 |= (phydev->duplex == DUPLEX_FULL ? 0x8000 : 0);
+		lp->mcr0 |= (phydev->duplex == DUPLEX_FULL ? MCR0_FD : 0);
 		iowrite16(lp->mcr0, ioaddr);
 
 		status_changed = 1;
@@ -1155,7 +1158,7 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
 	lp->dev = dev;
 
 	/* Init RDC private data */
-	lp->mcr0 = 0x1002;
+	lp->mcr0 = MCR0_XMTEN | MCR0;
 
 	/* The RDC-specific entries in the device structure. */
 	dev->netdev_ops = &r6040_netdev_ops;
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/6] r6040: use MAC_RST bit definition with MCR1 read/writes
  2012-01-04 18:59 [PATCH 0/6] r6040: cleanups Florian Fainelli
  2012-01-04 18:59 ` [PATCH 1/6] r6040: remove unused variables and definitions Florian Fainelli
  2012-01-04 18:59 ` [PATCH 2/6] r6040: define more MCR0 register bits Florian Fainelli
@ 2012-01-04 18:59 ` Florian Fainelli
  2012-01-04 18:59 ` [PATCH 4/6] r6040: use definitions for MAC_SM register read/writes Florian Fainelli
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2012-01-04 18:59 UTC (permalink / raw)
  To: davem; +Cc: netdev, Florian Fainelli

MAC_RST bit is already defined, use it instead of 0x1 where applicable.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
---
 drivers/net/ethernet/rdc/r6040.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c
index f4dddcee..4665a39 100644
--- a/drivers/net/ethernet/rdc/r6040.c
+++ b/drivers/net/ethernet/rdc/r6040.c
@@ -371,7 +371,7 @@ static void r6040_init_mac_regs(struct net_device *dev)
 	iowrite16(MAC_RST, ioaddr + MCR1);
 	while (limit--) {
 		cmd = ioread16(ioaddr + MCR1);
-		if (cmd & 0x1)
+		if (cmd & MAC_RST)
 			break;
 	}
 	/* Reset internal state machine */
@@ -453,7 +453,7 @@ static void r6040_down(struct net_device *dev)
 	iowrite16(MAC_RST, ioaddr + MCR1);	/* Reset RDC MAC */
 	while (limit--) {
 		cmd = ioread16(ioaddr + MCR1);
-		if (cmd & 0x1)
+		if (cmd & MAC_RST)
 			break;
 	}
 
@@ -735,7 +735,7 @@ static void r6040_mac_address(struct net_device *dev)
 	u16 *adrp;
 
 	/* MAC operation register */
-	iowrite16(0x01, ioaddr + MCR1); /* Reset MAC */
+	iowrite16(MAC_RST, ioaddr + MCR1); /* Reset MAC */
 	iowrite16(2, ioaddr + MAC_SM); /* Reset internal state machine */
 	iowrite16(0, ioaddr + MAC_SM);
 	mdelay(5);
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/6] r6040: use definitions for MAC_SM register read/writes
  2012-01-04 18:59 [PATCH 0/6] r6040: cleanups Florian Fainelli
                   ` (2 preceding siblings ...)
  2012-01-04 18:59 ` [PATCH 3/6] r6040: use MAC_RST bit definition with MCR1 read/writes Florian Fainelli
@ 2012-01-04 18:59 ` Florian Fainelli
  2012-01-04 18:59 ` [PATCH 5/6] r6040: use __aligned(size) Florian Fainelli
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2012-01-04 18:59 UTC (permalink / raw)
  To: davem; +Cc: netdev, Florian Fainelli

Bit 1 is the reset bit of the MAC status machine register, define and
use it.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
---
 drivers/net/ethernet/rdc/r6040.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c
index 4665a39..e9054a9 100644
--- a/drivers/net/ethernet/rdc/r6040.c
+++ b/drivers/net/ethernet/rdc/r6040.c
@@ -126,6 +126,7 @@
 #define PHY_CC		0x88	/* PHY status change configuration register */
 #define PHY_ST		0x8A	/* PHY status register */
 #define MAC_SM		0xAC	/* MAC status machine */
+#define  MAC_SM_RST	0x0002	/* MAC status machine reset */
 #define MAC_ID		0xBE	/* Identifier register */
 
 #define TX_DCNT		0x80	/* TX descriptor count */
@@ -375,7 +376,7 @@ static void r6040_init_mac_regs(struct net_device *dev)
 			break;
 	}
 	/* Reset internal state machine */
-	iowrite16(2, ioaddr + MAC_SM);
+	iowrite16(MAC_SM_RST, ioaddr + MAC_SM);
 	iowrite16(0, ioaddr + MAC_SM);
 	mdelay(5);
 
@@ -736,7 +737,7 @@ static void r6040_mac_address(struct net_device *dev)
 
 	/* MAC operation register */
 	iowrite16(MAC_RST, ioaddr + MCR1); /* Reset MAC */
-	iowrite16(2, ioaddr + MAC_SM); /* Reset internal state machine */
+	iowrite16(MAC_SM_RST, ioaddr + MAC_SM); /* Reset internal state machine */
 	iowrite16(0, ioaddr + MAC_SM);
 	mdelay(5);
 
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/6] r6040: use __aligned(size)
  2012-01-04 18:59 [PATCH 0/6] r6040: cleanups Florian Fainelli
                   ` (3 preceding siblings ...)
  2012-01-04 18:59 ` [PATCH 4/6] r6040: use definitions for MAC_SM register read/writes Florian Fainelli
@ 2012-01-04 18:59 ` Florian Fainelli
  2012-01-04 18:59 ` [PATCH 6/6] r6040: place comments before code Florian Fainelli
  2012-01-04 20:56 ` [PATCH 0/6] r6040: cleanups David Miller
  6 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2012-01-04 18:59 UTC (permalink / raw)
  To: davem; +Cc: netdev, Florian Fainelli

instead of __attribute__((__aligned(size)__))

Signed-off-by: Florian Fainelli <florian@openwrt.org>
---
 drivers/net/ethernet/rdc/r6040.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c
index e9054a9..b8dc727 100644
--- a/drivers/net/ethernet/rdc/r6040.c
+++ b/drivers/net/ethernet/rdc/r6040.c
@@ -173,7 +173,7 @@ struct r6040_descriptor {
 	struct r6040_descriptor *vndescp;	/* 14-17 */
 	struct sk_buff *skb_ptr;	/* 18-1B */
 	u32	rev2;			/* 1C-1F */
-} __attribute__((aligned(32)));
+} __aligned(32);
 
 struct r6040_private {
 	spinlock_t lock;		/* driver lock */
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6/6] r6040: place comments before code
  2012-01-04 18:59 [PATCH 0/6] r6040: cleanups Florian Fainelli
                   ` (4 preceding siblings ...)
  2012-01-04 18:59 ` [PATCH 5/6] r6040: use __aligned(size) Florian Fainelli
@ 2012-01-04 18:59 ` Florian Fainelli
  2012-01-04 20:56 ` [PATCH 0/6] r6040: cleanups David Miller
  6 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2012-01-04 18:59 UTC (permalink / raw)
  To: davem; +Cc: netdev, Florian Fainelli

checkpatch.pl complained about the line exceding 80 columns, and the
comment was actually on the same line as the code, fix that.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
---
 drivers/net/ethernet/rdc/r6040.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c
index b8dc727..87aa439 100644
--- a/drivers/net/ethernet/rdc/r6040.c
+++ b/drivers/net/ethernet/rdc/r6040.c
@@ -735,9 +735,10 @@ static void r6040_mac_address(struct net_device *dev)
 	void __iomem *ioaddr = lp->base;
 	u16 *adrp;
 
-	/* MAC operation register */
-	iowrite16(MAC_RST, ioaddr + MCR1); /* Reset MAC */
-	iowrite16(MAC_SM_RST, ioaddr + MAC_SM); /* Reset internal state machine */
+	/* Reset MAC */
+	iowrite16(MAC_RST, ioaddr + MCR1);
+	/* Reset internal state machine */
+	iowrite16(MAC_SM_RST, ioaddr + MAC_SM);
 	iowrite16(0, ioaddr + MAC_SM);
 	mdelay(5);
 
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/6] r6040: cleanups
  2012-01-04 18:59 [PATCH 0/6] r6040: cleanups Florian Fainelli
                   ` (5 preceding siblings ...)
  2012-01-04 18:59 ` [PATCH 6/6] r6040: place comments before code Florian Fainelli
@ 2012-01-04 20:56 ` David Miller
  6 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2012-01-04 20:56 UTC (permalink / raw)
  To: florian; +Cc: netdev

From: Florian Fainelli <florian@openwrt.org>
Date: Wed,  4 Jan 2012 19:59:32 +0100

> This series cleanups the r6040 driver by:
> - using appropriate definitions instead of bits values
> - fixing checkpatch errors and warnings
> 
> Florian Fainelli (6):
>   r6040: remove unused variables and definitions
>   r6040: define more MCR0 register bits
>   r6040: use MAC_RST bit definition with MCR1 read/writes
>   r6040: use definitions for MAC_SM register read/writes
>   r6040: use __aligned(size)
>   r6040: place comments before code

All applied, thanks Florian.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-04 20:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-04 18:59 [PATCH 0/6] r6040: cleanups Florian Fainelli
2012-01-04 18:59 ` [PATCH 1/6] r6040: remove unused variables and definitions Florian Fainelli
2012-01-04 18:59 ` [PATCH 2/6] r6040: define more MCR0 register bits Florian Fainelli
2012-01-04 18:59 ` [PATCH 3/6] r6040: use MAC_RST bit definition with MCR1 read/writes Florian Fainelli
2012-01-04 18:59 ` [PATCH 4/6] r6040: use definitions for MAC_SM register read/writes Florian Fainelli
2012-01-04 18:59 ` [PATCH 5/6] r6040: use __aligned(size) Florian Fainelli
2012-01-04 18:59 ` [PATCH 6/6] r6040: place comments before code Florian Fainelli
2012-01-04 20:56 ` [PATCH 0/6] r6040: cleanups David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).