[PATCH 01/04] smc91x: pass along private data V2

2008-02-22 Thread Magnus Damm
Pass a private data pointer to macros and functions. This makes it easy
to later on make run time decisions. This patch does not change any logic.
These changes should be optimized away during compilation.

V2 changes the macro argument name from priv to lp.

Signed-off-by: Magnus Damm [EMAIL PROTECTED]
---

 drivers/net/smc91x.c |  301 +-
 drivers/net/smc91x.h |  254 +-
 2 files changed, 280 insertions(+), 275 deletions(-)

--- 0001/drivers/net/smc91x.c
+++ work/drivers/net/smc91x.c   2008-02-22 14:07:43.0 +0900
@@ -220,22 +220,22 @@ static void PRINT_PKT(u_char *buf, int l
 
 
 /* this enables an interrupt in the interrupt mask register */
-#define SMC_ENABLE_INT(x) do { \
+#define SMC_ENABLE_INT(lp, x) do { \
unsigned char mask; \
spin_lock_irq(lp-lock);   \
-   mask = SMC_GET_INT_MASK();  \
+   mask = SMC_GET_INT_MASK(lp);\
mask |= (x);\
-   SMC_SET_INT_MASK(mask); \
+   SMC_SET_INT_MASK(lp, mask); \
spin_unlock_irq(lp-lock); \
 } while (0)
 
 /* this disables an interrupt from the interrupt mask register */
-#define SMC_DISABLE_INT(x) do {
\
+#define SMC_DISABLE_INT(lp, x) do {\
unsigned char mask; \
spin_lock_irq(lp-lock);   \
-   mask = SMC_GET_INT_MASK();  \
+   mask = SMC_GET_INT_MASK(lp);\
mask = ~(x);   \
-   SMC_SET_INT_MASK(mask); \
+   SMC_SET_INT_MASK(lp, mask); \
spin_unlock_irq(lp-lock); \
 } while (0)
 
@@ -244,10 +244,10 @@ static void PRINT_PKT(u_char *buf, int l
  * if at all, but let's avoid deadlocking the system if the hardware
  * decides to go south.
  */
-#define SMC_WAIT_MMU_BUSY() do {   \
-   if (unlikely(SMC_GET_MMU_CMD()  MC_BUSY)) {\
+#define SMC_WAIT_MMU_BUSY(lp) do { \
+   if (unlikely(SMC_GET_MMU_CMD(lp)  MC_BUSY)) {  \
unsigned long timeout = jiffies + 2;\
-   while (SMC_GET_MMU_CMD()  MC_BUSY) {   \
+   while (SMC_GET_MMU_CMD(lp)  MC_BUSY) { \
if (time_after(jiffies, timeout)) { \
printk(%s: timeout %s line %d\n,  \
dev-name, __FILE__, __LINE__); \
@@ -273,8 +273,8 @@ static void smc_reset(struct net_device 
 
/* Disable all interrupts, block TX tasklet */
spin_lock_irq(lp-lock);
-   SMC_SELECT_BANK(2);
-   SMC_SET_INT_MASK(0);
+   SMC_SELECT_BANK(lp, 2);
+   SMC_SET_INT_MASK(lp, 0);
pending_skb = lp-pending_tx_skb;
lp-pending_tx_skb = NULL;
spin_unlock_irq(lp-lock);
@@ -290,15 +290,15 @@ static void smc_reset(struct net_device 
 * This resets the registers mostly to defaults, but doesn't
 * affect EEPROM.  That seems unnecessary
 */
-   SMC_SELECT_BANK(0);
-   SMC_SET_RCR(RCR_SOFTRST);
+   SMC_SELECT_BANK(lp, 0);
+   SMC_SET_RCR(lp, RCR_SOFTRST);
 
/*
 * Setup the Configuration Register
 * This is necessary because the CONFIG_REG is not affected
 * by a soft reset
 */
-   SMC_SELECT_BANK(1);
+   SMC_SELECT_BANK(lp, 1);
 
cfg = CONFIG_DEFAULT;
 
@@ -316,7 +316,7 @@ static void smc_reset(struct net_device 
 */
cfg |= CONFIG_EPH_POWER_EN;
 
-   SMC_SET_CONFIG(cfg);
+   SMC_SET_CONFIG(lp, cfg);
 
/* this should pause enough for the chip to be happy */
/*
@@ -329,12 +329,12 @@ static void smc_reset(struct net_device 
udelay(1);
 
/* Disable transmit and receive functionality */
-   SMC_SELECT_BANK(0);
-   SMC_SET_RCR(RCR_CLEAR);
-   SMC_SET_TCR(TCR_CLEAR);
+   SMC_SELECT_BANK(lp, 0);
+   SMC_SET_RCR(lp, RCR_CLEAR);
+   SMC_SET_TCR(lp, TCR_CLEAR);
 
-   SMC_SELECT_BANK(1);
-   ctl = SMC_GET_CTL() | CTL_LE_ENABLE;
+   SMC_SELECT_BANK(lp, 1);
+   ctl = SMC_GET_CTL(lp) | CTL_LE_ENABLE;
 
/*
 * Set the control register to automatically release successfully
@@ 

Re: [PATCH 01/04] smc91x: pass along private data V2

2008-02-22 Thread Nicolas Pitre
On Fri, 22 Feb 2008, Magnus Damm wrote:

 Pass a private data pointer to macros and functions. This makes it easy
 to later on make run time decisions. This patch does not change any logic.
 These changes should be optimized away during compilation.
 
 V2 changes the macro argument name from priv to lp.
 
 Signed-off-by: Magnus Damm [EMAIL PROTECTED]

Acked-by: Nicolas Pitre [EMAIL PROTECTED]


 ---
 
  drivers/net/smc91x.c |  301 
 +-
  drivers/net/smc91x.h |  254 +-
  2 files changed, 280 insertions(+), 275 deletions(-)
 
 --- 0001/drivers/net/smc91x.c
 +++ work/drivers/net/smc91x.c 2008-02-22 14:07:43.0 +0900
 @@ -220,22 +220,22 @@ static void PRINT_PKT(u_char *buf, int l
  
  
  /* this enables an interrupt in the interrupt mask register */
 -#define SMC_ENABLE_INT(x) do {   
 \
 +#define SMC_ENABLE_INT(lp, x) do {   \
   unsigned char mask; \
   spin_lock_irq(lp-lock);   \
 - mask = SMC_GET_INT_MASK();  \
 + mask = SMC_GET_INT_MASK(lp);\
   mask |= (x);\
 - SMC_SET_INT_MASK(mask); \
 + SMC_SET_INT_MASK(lp, mask); \
   spin_unlock_irq(lp-lock); \
  } while (0)
  
  /* this disables an interrupt from the interrupt mask register */
 -#define SMC_DISABLE_INT(x) do {  
 \
 +#define SMC_DISABLE_INT(lp, x) do {  \
   unsigned char mask; \
   spin_lock_irq(lp-lock);   \
 - mask = SMC_GET_INT_MASK();  \
 + mask = SMC_GET_INT_MASK(lp);\
   mask = ~(x);   \
 - SMC_SET_INT_MASK(mask); \
 + SMC_SET_INT_MASK(lp, mask); \
   spin_unlock_irq(lp-lock); \
  } while (0)
  
 @@ -244,10 +244,10 @@ static void PRINT_PKT(u_char *buf, int l
   * if at all, but let's avoid deadlocking the system if the hardware
   * decides to go south.
   */
 -#define SMC_WAIT_MMU_BUSY() do { \
 - if (unlikely(SMC_GET_MMU_CMD()  MC_BUSY)) {\
 +#define SMC_WAIT_MMU_BUSY(lp) do {   \
 + if (unlikely(SMC_GET_MMU_CMD(lp)  MC_BUSY)) {  \
   unsigned long timeout = jiffies + 2;\
 - while (SMC_GET_MMU_CMD()  MC_BUSY) {   \
 + while (SMC_GET_MMU_CMD(lp)  MC_BUSY) { \
   if (time_after(jiffies, timeout)) { \
   printk(%s: timeout %s line %d\n,  \
   dev-name, __FILE__, __LINE__); \
 @@ -273,8 +273,8 @@ static void smc_reset(struct net_device 
  
   /* Disable all interrupts, block TX tasklet */
   spin_lock_irq(lp-lock);
 - SMC_SELECT_BANK(2);
 - SMC_SET_INT_MASK(0);
 + SMC_SELECT_BANK(lp, 2);
 + SMC_SET_INT_MASK(lp, 0);
   pending_skb = lp-pending_tx_skb;
   lp-pending_tx_skb = NULL;
   spin_unlock_irq(lp-lock);
 @@ -290,15 +290,15 @@ static void smc_reset(struct net_device 
* This resets the registers mostly to defaults, but doesn't
* affect EEPROM.  That seems unnecessary
*/
 - SMC_SELECT_BANK(0);
 - SMC_SET_RCR(RCR_SOFTRST);
 + SMC_SELECT_BANK(lp, 0);
 + SMC_SET_RCR(lp, RCR_SOFTRST);
  
   /*
* Setup the Configuration Register
* This is necessary because the CONFIG_REG is not affected
* by a soft reset
*/
 - SMC_SELECT_BANK(1);
 + SMC_SELECT_BANK(lp, 1);
  
   cfg = CONFIG_DEFAULT;
  
 @@ -316,7 +316,7 @@ static void smc_reset(struct net_device 
*/
   cfg |= CONFIG_EPH_POWER_EN;
  
 - SMC_SET_CONFIG(cfg);
 + SMC_SET_CONFIG(lp, cfg);
  
   /* this should pause enough for the chip to be happy */
   /*
 @@ -329,12 +329,12 @@ static void smc_reset(struct net_device 
   udelay(1);
  
   /* Disable transmit and receive functionality */
 - SMC_SELECT_BANK(0);
 - SMC_SET_RCR(RCR_CLEAR);
 - SMC_SET_TCR(TCR_CLEAR);
 + SMC_SELECT_BANK(lp, 0);
 + SMC_SET_RCR(lp, RCR_CLEAR);
 + SMC_SET_TCR(lp, TCR_CLEAR);
  
 - SMC_SELECT_BANK(1);
 - ctl = SMC_GET_CTL() | CTL_LE_ENABLE;
 + SMC_SELECT_BANK(lp, 1);
 + ctl = SMC_GET_CTL(lp) | CTL_LE_ENABLE;
  
   /*
*