CAN: add controller hardware name for Softing cards
[linux-2.6.git] / drivers / net / gianfar_sysfs.c
index 9c664f8..64f4094 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/unistd.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/etherdevice.h>
@@ -50,7 +49,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 +57,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 +104,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 +112,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 +123,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 +163,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 +171,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 +182,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 +211,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 +219,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 +251,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 +259,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 +292,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 +300,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;
 }