static ssize_t gfar_set_rx_stash_size(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct gfar_private *priv = netdev_priv(to_net_dev(dev)); struct gfar __iomem *regs = priv->gfargrp[0].regs; unsigned int length = simple_strtoul(buf, NULL, 0); u32 temp; unsigned long flags; if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING)) return count; local_irq_save(flags); lock_rx_qs(priv); if (length > priv->rx_buffer_size) goto out; if (length == priv->rx_stash_size) goto out; priv->rx_stash_size = length; temp = gfar_read(®s->attreli); temp &= ~ATTRELI_EL_MASK; temp |= ATTRELI_EL(length); gfar_write(®s->attreli, temp); /* Turn stashing on/off as appropriate */ temp = gfar_read(®s->attr); if (length) temp |= ATTR_BUFSTASH; else temp &= ~(ATTR_BUFSTASH); gfar_write(®s->attr, temp); out: unlock_rx_qs(priv); local_irq_restore(flags); return count; }
static ssize_t gfar_set_rx_stash_size(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct gfar_private *priv = netdev_priv(to_net_dev(dev)); unsigned int length = simple_strtoul(buf, NULL, 0); u32 temp; unsigned long flags; if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING)) return count; spin_lock_irqsave(&priv->rxlock, flags); if (length > priv->rx_buffer_size) goto out; if (length == priv->rx_stash_size) goto out; priv->rx_stash_size = length; temp = gfar_read(&priv->regs->attreli); temp &= ~ATTRELI_EL_MASK; temp |= ATTRELI_EL(length); gfar_write(&priv->regs->attreli, temp); temp = gfar_read(&priv->regs->attr); if (length) temp |= ATTR_BUFSTASH; else temp &= ~(ATTR_BUFSTASH); gfar_write(&priv->regs->attr, temp); out: spin_unlock_irqrestore(&priv->rxlock, flags); return count; }
static ssize_t gfar_set_rx_stash_size(struct class_device *cdev, const char *buf, size_t count) { struct net_device *dev = to_net_dev(cdev); struct gfar_private *priv = netdev_priv(dev); unsigned int length = simple_strtoul(buf, NULL, 0); u32 temp; unsigned long flags; spin_lock_irqsave(&priv->rxlock, flags); if (length > priv->rx_buffer_size) return count; if (length == priv->rx_stash_size) return count; priv->rx_stash_size = length; temp = gfar_read(&priv->regs->attreli); temp &= ~ATTRELI_EL_MASK; temp |= ATTRELI_EL(length); gfar_write(&priv->regs->attreli, temp); /* Turn stashing on/off as appropriate */ temp = gfar_read(&priv->regs->attr); if (length) temp |= ATTR_BUFSTASH; else temp &= ~(ATTR_BUFSTASH); gfar_write(&priv->regs->attr, temp); spin_unlock_irqrestore(&priv->rxlock, flags); return count; }