bonding: fix potential deadlock in bond_uninit()
[safe/jmp/linux-2.6] / drivers / net / gianfar_sysfs.c
index 9c664f8..b98c6c5 100644 (file)
@@ -50,7 +50,7 @@ static ssize_t gfar_set_bd_stash(struct device *dev,
                                 const char *buf, size_t count)
 {
        struct gfar_private *priv = netdev_priv(to_net_dev(dev));
-       struct gfar_priv_rx_q *rx_queue = NULL;
+       struct gfar __iomem *regs = priv->gfargrp[0].regs;
        int new_setting = 0;
        u32 temp;
        unsigned long flags;
@@ -58,32 +58,34 @@ static ssize_t gfar_set_bd_stash(struct device *dev,
        if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BD_STASHING))
                return count;
 
-       rx_queue = priv->rx_queue;
 
        /* Find out the new setting */
        if (!strncmp("on", buf, count - 1) || !strncmp("1", buf, count - 1))
                new_setting = 1;
-       else if (!strncmp("off", buf, count - 1)
-                || !strncmp("0", buf, count - 1))
+       else if (!strncmp("off", buf, count - 1) ||
+                !strncmp("0", buf, count - 1))
                new_setting = 0;
        else
                return count;
 
-       spin_lock_irqsave(&rx_queue->rxlock, flags);
+
+       local_irq_save(flags);
+       lock_rx_qs(priv);
 
        /* Set the new stashing value */
        priv->bd_stash_en = new_setting;
 
-       temp = gfar_read(&priv->regs->attr);
+       temp = gfar_read(&regs->attr);
 
        if (new_setting)
                temp |= ATTR_BDSTASH;
        else
                temp &= ~(ATTR_BDSTASH);
 
-       gfar_write(&priv->regs->attr, temp);
+       gfar_write(&regs->attr, temp);
 
-       spin_unlock_irqrestore(&rx_queue->rxlock, flags);
+       unlock_rx_qs(priv);
+       local_irq_restore(flags);
 
        return count;
 }
@@ -103,7 +105,7 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev,
                                      const char *buf, size_t count)
 {
        struct gfar_private *priv = netdev_priv(to_net_dev(dev));
-       struct gfar_priv_rx_q *rx_queue = NULL;
+       struct gfar __iomem *regs = priv->gfargrp[0].regs;
        unsigned int length = simple_strtoul(buf, NULL, 0);
        u32 temp;
        unsigned long flags;
@@ -111,9 +113,9 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev,
        if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING))
                return count;
 
-       rx_queue = priv->rx_queue;
+       local_irq_save(flags);
+       lock_rx_qs(priv);
 
-       spin_lock_irqsave(&rx_queue->rxlock, flags);
        if (length > priv->rx_buffer_size)
                goto out;
 
@@ -122,23 +124,24 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev,
 
        priv->rx_stash_size = length;
 
-       temp = gfar_read(&priv->regs->attreli);
+       temp = gfar_read(&regs->attreli);
        temp &= ~ATTRELI_EL_MASK;
        temp |= ATTRELI_EL(length);
-       gfar_write(&priv->regs->attreli, temp);
+       gfar_write(&regs->attreli, temp);
 
        /* Turn stashing on/off as appropriate */
-       temp = gfar_read(&priv->regs->attr);
+       temp = gfar_read(&regs->attr);
 
        if (length)
                temp |= ATTR_BUFSTASH;
        else
                temp &= ~(ATTR_BUFSTASH);
 
-       gfar_write(&priv->regs->attr, temp);
+       gfar_write(&regs->attr, temp);
 
 out:
-       spin_unlock_irqrestore(&rx_queue->rxlock, flags);
+       unlock_rx_qs(priv);
+       local_irq_restore(flags);
 
        return count;
 }
@@ -161,7 +164,7 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev,
                                       const char *buf, size_t count)
 {
        struct gfar_private *priv = netdev_priv(to_net_dev(dev));
-       struct gfar_priv_rx_q *rx_queue = NULL;
+       struct gfar __iomem *regs = priv->gfargrp[0].regs;
        unsigned short index = simple_strtoul(buf, NULL, 0);
        u32 temp;
        unsigned long flags;
@@ -169,9 +172,9 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev,
        if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING))
                return count;
 
-       rx_queue = priv->rx_queue;
+       local_irq_save(flags);
+       lock_rx_qs(priv);
 
-       spin_lock_irqsave(&rx_queue->rxlock, flags);
        if (index > priv->rx_stash_size)
                goto out;
 
@@ -180,13 +183,14 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev,
 
        priv->rx_stash_index = index;
 
-       temp = gfar_read(&priv->regs->attreli);
+       temp = gfar_read(&regs->attreli);
        temp &= ~ATTRELI_EI_MASK;
        temp |= ATTRELI_EI(index);
-       gfar_write(&priv->regs->attreli, flags);
+       gfar_write(&regs->attreli, temp);
 
 out:
-       spin_unlock_irqrestore(&rx_queue->rxlock, flags);
+       unlock_rx_qs(priv);
+       local_irq_restore(flags);
 
        return count;
 }
@@ -208,7 +212,7 @@ static ssize_t gfar_set_fifo_threshold(struct device *dev,
                                       const char *buf, size_t count)
 {
        struct gfar_private *priv = netdev_priv(to_net_dev(dev));
-       struct gfar_priv_tx_q *tx_queue = NULL;
+       struct gfar __iomem *regs = priv->gfargrp[0].regs;
        unsigned int length = simple_strtoul(buf, NULL, 0);
        u32 temp;
        unsigned long flags;
@@ -216,18 +220,18 @@ static ssize_t gfar_set_fifo_threshold(struct device *dev,
        if (length > GFAR_MAX_FIFO_THRESHOLD)
                return count;
 
-       tx_queue = priv->tx_queue;
-
-       spin_lock_irqsave(&tx_queue->txlock, flags);
+       local_irq_save(flags);
+       lock_tx_qs(priv);
 
        priv->fifo_threshold = length;
 
-       temp = gfar_read(&priv->regs->fifo_tx_thr);
+       temp = gfar_read(&regs->fifo_tx_thr);
        temp &= ~FIFO_TX_THR_MASK;
        temp |= length;
-       gfar_write(&priv->regs->fifo_tx_thr, temp);
+       gfar_write(&regs->fifo_tx_thr, temp);
 
-       spin_unlock_irqrestore(&tx_queue->txlock, flags);
+       unlock_tx_qs(priv);
+       local_irq_restore(flags);
 
        return count;
 }
@@ -248,7 +252,7 @@ static ssize_t gfar_set_fifo_starve(struct device *dev,
                                    const char *buf, size_t count)
 {
        struct gfar_private *priv = netdev_priv(to_net_dev(dev));
-       struct gfar_priv_tx_q *tx_queue = NULL;
+       struct gfar __iomem *regs = priv->gfargrp[0].regs;
        unsigned int num = simple_strtoul(buf, NULL, 0);
        u32 temp;
        unsigned long flags;
@@ -256,17 +260,18 @@ static ssize_t gfar_set_fifo_starve(struct device *dev,
        if (num > GFAR_MAX_FIFO_STARVE)
                return count;
 
-       tx_queue = priv->tx_queue;
-       spin_lock_irqsave(&tx_queue->txlock, flags);
+       local_irq_save(flags);
+       lock_tx_qs(priv);
 
        priv->fifo_starve = num;
 
-       temp = gfar_read(&priv->regs->fifo_tx_starve);
+       temp = gfar_read(&regs->fifo_tx_starve);
        temp &= ~FIFO_TX_STARVE_MASK;
        temp |= num;
-       gfar_write(&priv->regs->fifo_tx_starve, temp);
+       gfar_write(&regs->fifo_tx_starve, temp);
 
-       spin_unlock_irqrestore(&tx_queue->txlock, flags);
+       unlock_tx_qs(priv);
+       local_irq_restore(flags);
 
        return count;
 }
@@ -288,7 +293,7 @@ static ssize_t gfar_set_fifo_starve_off(struct device *dev,
                                        const char *buf, size_t count)
 {
        struct gfar_private *priv = netdev_priv(to_net_dev(dev));
-       struct gfar_priv_tx_q *tx_queue = NULL;
+       struct gfar __iomem *regs = priv->gfargrp[0].regs;
        unsigned int num = simple_strtoul(buf, NULL, 0);
        u32 temp;
        unsigned long flags;
@@ -296,17 +301,18 @@ static ssize_t gfar_set_fifo_starve_off(struct device *dev,
        if (num > GFAR_MAX_FIFO_STARVE_OFF)
                return count;
 
-       tx_queue = priv->tx_queue;
-       spin_lock_irqsave(&tx_queue->txlock, flags);
+       local_irq_save(flags);
+       lock_tx_qs(priv);
 
        priv->fifo_starve_off = num;
 
-       temp = gfar_read(&priv->regs->fifo_tx_starve_shutoff);
+       temp = gfar_read(&regs->fifo_tx_starve_shutoff);
        temp &= ~FIFO_TX_STARVE_OFF_MASK;
        temp |= num;
-       gfar_write(&priv->regs->fifo_tx_starve_shutoff, temp);
+       gfar_write(&regs->fifo_tx_starve_shutoff, temp);
 
-       spin_unlock_irqrestore(&tx_queue->txlock, flags);
+       unlock_tx_qs(priv);
+       local_irq_restore(flags);
 
        return count;
 }