netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] atl1c_main.c: add wait_for_idle routine
@ 2009-06-01  6:44 Joe Perches
  2009-06-01  6:59 ` Jie Yang
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2009-06-01  6:44 UTC (permalink / raw)
  To: Jie Yang; +Cc: netdev, David S. Miller, Yang Hongyang, Andrew Morton

Slight refactoring of duplicated wait for idle checks
Spelling fix

Signed-off-by: Joe Perches <joe@perches.com>

diff --git a/drivers/net/atl1c/atl1c_main.c b/drivers/net/atl1c/atl1c_main.c
index fc1092b..5d2c8f7 100644
--- a/drivers/net/atl1c/atl1c_main.c
+++ b/drivers/net/atl1c/atl1c_main.c
@@ -164,6 +164,24 @@ static inline void atl1c_irq_reset(struct atl1c_adapter *adapter)
 }
 
 /*
+ * atl1c_wait_until_idle - wait up to AT_HW_MAX_IDLE_DELAY reads
+ * of the idle status register until the device is actually idle
+ */
+static u32 atl1c_wait_until_idle(struct atl1c_hw *hw)
+{
+	int timeout;
+	u32 data;
+
+	for (timeout = 0; timeout < AT_HW_MAX_IDLE_DELAY; timeout++) {
+		AT_READ_REG(hw, REG_IDLE_STATUS, &data);
+		if ((data & IDLE_STATUS_MASK) == 0)
+			return 0;
+		msleep(1);
+	}
+	return data;
+}
+
+/*
  * atl1c_phy_config - Timer Call-back
  * @data: pointer to netdev cast into an unsigned long
  */
@@ -1106,7 +1124,6 @@ static void atl1c_configure_dma(struct atl1c_adapter *adapter)
 static int atl1c_stop_mac(struct atl1c_hw *hw)
 {
 	u32 data;
-	int timeout;
 
 	AT_READ_REG(hw, REG_RXQ_CTRL, &data);
 	data &= ~(RXQ1_CTRL_EN | RXQ2_CTRL_EN |
@@ -1117,25 +1134,13 @@ static int atl1c_stop_mac(struct atl1c_hw *hw)
 	data &= ~TXQ_CTRL_EN;
 	AT_WRITE_REG(hw, REG_TWSI_CTRL, data);
 
-	for (timeout = 0; timeout < AT_HW_MAX_IDLE_DELAY; timeout++) {
-		AT_READ_REG(hw, REG_IDLE_STATUS, &data);
-		if ((data & (IDLE_STATUS_RXQ_NO_IDLE |
-			IDLE_STATUS_TXQ_NO_IDLE)) == 0)
-			break;
-		msleep(1);
-	}
+	atl1c_wait_until_idle(hw);
 
 	AT_READ_REG(hw, REG_MAC_CTRL, &data);
 	data &= ~(MAC_CTRL_TX_EN | MAC_CTRL_RX_EN);
 	AT_WRITE_REG(hw, REG_MAC_CTRL, data);
 
-	for (timeout = 0; timeout < AT_HW_MAX_IDLE_DELAY; timeout++) {
-		AT_READ_REG(hw, REG_IDLE_STATUS, &data);
-		if ((data & IDLE_STATUS_MASK) == 0)
-			return 0;
-		msleep(1);
-	}
-	return data;
+	return (int)atl1c_wait_until_idle(hw);
 }
 
 static void atl1c_enable_rx_ctrl(struct atl1c_hw *hw)
@@ -1178,8 +1183,6 @@ static int atl1c_reset_mac(struct atl1c_hw *hw)
 {
 	struct atl1c_adapter *adapter = (struct atl1c_adapter *)hw->adapter;
 	struct pci_dev *pdev = adapter->pdev;
-	u32 idle_status_data = 0;
-	int timeout = 0;
 	int ret;
 
 	AT_WRITE_REG(hw, REG_IMR, 0);
@@ -1198,15 +1201,10 @@ static int atl1c_reset_mac(struct atl1c_hw *hw)
 	AT_WRITE_FLUSH(hw);
 	msleep(10);
 	/* Wait at least 10ms for All module to be Idle */
-	for (timeout = 0; timeout < AT_HW_MAX_IDLE_DELAY; timeout++) {
-		AT_READ_REG(hw, REG_IDLE_STATUS, &idle_status_data);
-		if ((idle_status_data & IDLE_STATUS_MASK) == 0)
-			break;
-		msleep(1);
-	}
-	if (timeout >= AT_HW_MAX_IDLE_DELAY) {
+
+	if (atl1c_wait_until_idle(hw)) {
 		dev_err(&pdev->dev,
-			"MAC state machine cann't be idle since"
+			"MAC state machine can't be idle since"
 			" disabled for 10ms second\n");
 		return -1;
 	}



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

* RE: [PATCH] atl1c_main.c: add wait_for_idle routine
  2009-06-01  6:44 [PATCH] atl1c_main.c: add wait_for_idle routine Joe Perches
@ 2009-06-01  6:59 ` Jie Yang
  2009-06-01 10:14   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Jie Yang @ 2009-06-01  6:59 UTC (permalink / raw)
  To: Joe Perches
  Cc: netdev@vger.kernel.org, David S. Miller, Yang Hongyang,
	Andrew Morton

On  Monday, June 01, 2009 2:45 PM
Joe Perches <joe@perches.com> wrote:
> Slight refactoring of duplicated wait for idle checks Spelling fix
>
> Signed-off-by: Joe Perches <joe@perches.com>
>
> diff --git a/drivers/net/atl1c/atl1c_main.c
> b/drivers/net/atl1c/atl1c_main.c index fc1092b..5d2c8f7 100644
> --- a/drivers/net/atl1c/atl1c_main.c
> +++ b/drivers/net/atl1c/atl1c_main.c
> @@ -164,6 +164,24 @@ static inline void
> atl1c_irq_reset(struct atl1c_adapter *adapter)  }
>
>  /*
> + * atl1c_wait_until_idle - wait up to AT_HW_MAX_IDLE_DELAY reads
> + * of the idle status register until the device is actually idle  */
> +static u32 atl1c_wait_until_idle(struct atl1c_hw *hw) {
> +       int timeout;
> +       u32 data;
> +
> +       for (timeout = 0; timeout < AT_HW_MAX_IDLE_DELAY; timeout++) {
> +               AT_READ_REG(hw, REG_IDLE_STATUS, &data);
> +               if ((data & IDLE_STATUS_MASK) == 0)
> +                       return 0;
> +               msleep(1);
> +       }
> +       return data;
> +}
> +
> +/*
>   * atl1c_phy_config - Timer Call-back
>   * @data: pointer to netdev cast into an unsigned long
>   */
> @@ -1106,7 +1124,6 @@ static void atl1c_configure_dma(struct
> atl1c_adapter *adapter)  static int atl1c_stop_mac(struct
> atl1c_hw *hw)  {
>         u32 data;
> -       int timeout;
>
>         AT_READ_REG(hw, REG_RXQ_CTRL, &data);
>         data &= ~(RXQ1_CTRL_EN | RXQ2_CTRL_EN | @@ -1117,25
> +1134,13 @@ static int atl1c_stop_mac(struct atl1c_hw *hw)
>         data &= ~TXQ_CTRL_EN;
>         AT_WRITE_REG(hw, REG_TWSI_CTRL, data);
>
> -       for (timeout = 0; timeout < AT_HW_MAX_IDLE_DELAY; timeout++) {
> -               AT_READ_REG(hw, REG_IDLE_STATUS, &data);
> -               if ((data & (IDLE_STATUS_RXQ_NO_IDLE |
> -                       IDLE_STATUS_TXQ_NO_IDLE)) == 0)
> -                       break;
> -               msleep(1);
> -       }
> +       atl1c_wait_until_idle(hw);
>
>         AT_READ_REG(hw, REG_MAC_CTRL, &data);
>         data &= ~(MAC_CTRL_TX_EN | MAC_CTRL_RX_EN);
>         AT_WRITE_REG(hw, REG_MAC_CTRL, data);
>
> -       for (timeout = 0; timeout < AT_HW_MAX_IDLE_DELAY; timeout++) {
> -               AT_READ_REG(hw, REG_IDLE_STATUS, &data);
> -               if ((data & IDLE_STATUS_MASK) == 0)
> -                       return 0;
> -               msleep(1);
> -       }
> -       return data;
> +       return (int)atl1c_wait_until_idle(hw);
>  }
>
>  static void atl1c_enable_rx_ctrl(struct atl1c_hw *hw) @@
> -1178,8 +1183,6 @@ static int atl1c_reset_mac(struct atl1c_hw *hw)  {
>         struct atl1c_adapter *adapter = (struct atl1c_adapter
> *)hw->adapter;
>         struct pci_dev *pdev = adapter->pdev;
> -       u32 idle_status_data = 0;
> -       int timeout = 0;
>         int ret;
>
>         AT_WRITE_REG(hw, REG_IMR, 0);
> @@ -1198,15 +1201,10 @@ static int atl1c_reset_mac(struct
> atl1c_hw *hw)
>         AT_WRITE_FLUSH(hw);
>         msleep(10);
>         /* Wait at least 10ms for All module to be Idle */
> -       for (timeout = 0; timeout < AT_HW_MAX_IDLE_DELAY; timeout++) {
> -               AT_READ_REG(hw, REG_IDLE_STATUS, &idle_status_data);
> -               if ((idle_status_data & IDLE_STATUS_MASK) == 0)
> -                       break;
> -               msleep(1);
> -       }
> -       if (timeout >= AT_HW_MAX_IDLE_DELAY) {
> +
> +       if (atl1c_wait_until_idle(hw)) {
>                 dev_err(&pdev->dev,
> -                       "MAC state machine cann't be idle since"
> +                       "MAC state machine can't be idle since"
>                         " disabled for 10ms second\n");
>                 return -1;
>         }
>

Acked-by: jie.yang@atheros.com

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

* Re: [PATCH] atl1c_main.c: add wait_for_idle routine
  2009-06-01  6:59 ` Jie Yang
@ 2009-06-01 10:14   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2009-06-01 10:14 UTC (permalink / raw)
  To: Jie.Yang; +Cc: joe, netdev, yanghy, akpm

From: Jie Yang <Jie.Yang@Atheros.com>
Date: Mon, 1 Jun 2009 14:59:17 +0800

> On  Monday, June 01, 2009 2:45 PM
> Joe Perches <joe@perches.com> wrote:
>> Slight refactoring of duplicated wait for idle checks Spelling fix
>>
>> Signed-off-by: Joe Perches <joe@perches.com>
...
> Acked-by: jie.yang@atheros.com

Applied to net-next-2.6, thanks.

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

end of thread, other threads:[~2009-06-01 10:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-01  6:44 [PATCH] atl1c_main.c: add wait_for_idle routine Joe Perches
2009-06-01  6:59 ` Jie Yang
2009-06-01 10:14   ` 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).