aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/gianfar_sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/gianfar_sysfs.c')
-rw-r--r--drivers/net/gianfar_sysfs.c81
1 files changed, 52 insertions, 29 deletions
diff --git a/drivers/net/gianfar_sysfs.c b/drivers/net/gianfar_sysfs.c
index dd26da74f27..b98c6c51229 100644
--- a/drivers/net/gianfar_sysfs.c
+++ b/drivers/net/gianfar_sysfs.c
@@ -8,8 +8,9 @@
8 * 8 *
9 * Author: Andy Fleming 9 * Author: Andy Fleming
10 * Maintainer: Kumar Gala (galak@kernel.crashing.org) 10 * Maintainer: Kumar Gala (galak@kernel.crashing.org)
11 * Modifier: Sandeep Gopalpet <sandeep.kumar@freescale.com>
11 * 12 *
12 * Copyright (c) 2002-2005 Freescale Semiconductor, Inc. 13 * Copyright 2002-2009 Freescale Semiconductor, Inc.
13 * 14 *
14 * This program is free software; you can redistribute it and/or modify it 15 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the 16 * under the terms of the GNU General Public License as published by the
@@ -49,6 +50,7 @@ static ssize_t gfar_set_bd_stash(struct device *dev,
49 const char *buf, size_t count) 50 const char *buf, size_t count)
50{ 51{
51 struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 52 struct gfar_private *priv = netdev_priv(to_net_dev(dev));
53 struct gfar __iomem *regs = priv->gfargrp[0].regs;
52 int new_setting = 0; 54 int new_setting = 0;
53 u32 temp; 55 u32 temp;
54 unsigned long flags; 56 unsigned long flags;
@@ -56,30 +58,34 @@ static ssize_t gfar_set_bd_stash(struct device *dev,
56 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BD_STASHING)) 58 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BD_STASHING))
57 return count; 59 return count;
58 60
61
59 /* Find out the new setting */ 62 /* Find out the new setting */
60 if (!strncmp("on", buf, count - 1) || !strncmp("1", buf, count - 1)) 63 if (!strncmp("on", buf, count - 1) || !strncmp("1", buf, count - 1))
61 new_setting = 1; 64 new_setting = 1;
62 else if (!strncmp("off", buf, count - 1) 65 else if (!strncmp("off", buf, count - 1) ||
63 || !strncmp("0", buf, count - 1)) 66 !strncmp("0", buf, count - 1))
64 new_setting = 0; 67 new_setting = 0;
65 else 68 else
66 return count; 69 return count;
67 70
68 spin_lock_irqsave(&priv->rxlock, flags); 71
72 local_irq_save(flags);
73 lock_rx_qs(priv);
69 74
70 /* Set the new stashing value */ 75 /* Set the new stashing value */
71 priv->bd_stash_en = new_setting; 76 priv->bd_stash_en = new_setting;
72 77
73 temp = gfar_read(&priv->regs->attr); 78 temp = gfar_read(&regs->attr);
74 79
75 if (new_setting) 80 if (new_setting)
76 temp |= ATTR_BDSTASH; 81 temp |= ATTR_BDSTASH;
77 else 82 else
78 temp &= ~(ATTR_BDSTASH); 83 temp &= ~(ATTR_BDSTASH);
79 84
80 gfar_write(&priv->regs->attr, temp); 85 gfar_write(&regs->attr, temp);
81 86
82 spin_unlock_irqrestore(&priv->rxlock, flags); 87 unlock_rx_qs(priv);
88 local_irq_restore(flags);
83 89
84 return count; 90 return count;
85} 91}
@@ -99,6 +105,7 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev,
99 const char *buf, size_t count) 105 const char *buf, size_t count)
100{ 106{
101 struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 107 struct gfar_private *priv = netdev_priv(to_net_dev(dev));
108 struct gfar __iomem *regs = priv->gfargrp[0].regs;
102 unsigned int length = simple_strtoul(buf, NULL, 0); 109 unsigned int length = simple_strtoul(buf, NULL, 0);
103 u32 temp; 110 u32 temp;
104 unsigned long flags; 111 unsigned long flags;
@@ -106,7 +113,9 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev,
106 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING)) 113 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING))
107 return count; 114 return count;
108 115
109 spin_lock_irqsave(&priv->rxlock, flags); 116 local_irq_save(flags);
117 lock_rx_qs(priv);
118
110 if (length > priv->rx_buffer_size) 119 if (length > priv->rx_buffer_size)
111 goto out; 120 goto out;
112 121
@@ -115,23 +124,24 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev,
115 124
116 priv->rx_stash_size = length; 125 priv->rx_stash_size = length;
117 126
118 temp = gfar_read(&priv->regs->attreli); 127 temp = gfar_read(&regs->attreli);
119 temp &= ~ATTRELI_EL_MASK; 128 temp &= ~ATTRELI_EL_MASK;
120 temp |= ATTRELI_EL(length); 129 temp |= ATTRELI_EL(length);
121 gfar_write(&priv->regs->attreli, temp); 130 gfar_write(&regs->attreli, temp);
122 131
123 /* Turn stashing on/off as appropriate */ 132 /* Turn stashing on/off as appropriate */
124 temp = gfar_read(&priv->regs->attr); 133 temp = gfar_read(&regs->attr);
125 134
126 if (length) 135 if (length)
127 temp |= ATTR_BUFSTASH; 136 temp |= ATTR_BUFSTASH;
128 else 137 else
129 temp &= ~(ATTR_BUFSTASH); 138 temp &= ~(ATTR_BUFSTASH);
130 139
131 gfar_write(&priv->regs->attr, temp); 140 gfar_write(&regs->attr, temp);
132 141
133out: 142out:
134 spin_unlock_irqrestore(&priv->rxlock, flags); 143 unlock_rx_qs(priv);
144 local_irq_restore(flags);
135 145
136 return count; 146 return count;
137} 147}
@@ -154,6 +164,7 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev,
154 const char *buf, size_t count) 164 const char *buf, size_t count)
155{ 165{
156 struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 166 struct gfar_private *priv = netdev_priv(to_net_dev(dev));
167 struct gfar __iomem *regs = priv->gfargrp[0].regs;
157 unsigned short index = simple_strtoul(buf, NULL, 0); 168 unsigned short index = simple_strtoul(buf, NULL, 0);
158 u32 temp; 169 u32 temp;
159 unsigned long flags; 170 unsigned long flags;
@@ -161,7 +172,9 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev,
161 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING)) 172 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING))
162 return count; 173 return count;
163 174
164 spin_lock_irqsave(&priv->rxlock, flags); 175 local_irq_save(flags);
176 lock_rx_qs(priv);
177
165 if (index > priv->rx_stash_size) 178 if (index > priv->rx_stash_size)
166 goto out; 179 goto out;
167 180
@@ -170,13 +183,14 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev,
170 183
171 priv->rx_stash_index = index; 184 priv->rx_stash_index = index;
172 185
173 temp = gfar_read(&priv->regs->attreli); 186 temp = gfar_read(&regs->attreli);
174 temp &= ~ATTRELI_EI_MASK; 187 temp &= ~ATTRELI_EI_MASK;
175 temp |= ATTRELI_EI(index); 188 temp |= ATTRELI_EI(index);
176 gfar_write(&priv->regs->attreli, flags); 189 gfar_write(&regs->attreli, temp);
177 190
178out: 191out:
179 spin_unlock_irqrestore(&priv->rxlock, flags); 192 unlock_rx_qs(priv);
193 local_irq_restore(flags);
180 194
181 return count; 195 return count;
182} 196}
@@ -198,6 +212,7 @@ static ssize_t gfar_set_fifo_threshold(struct device *dev,
198 const char *buf, size_t count) 212 const char *buf, size_t count)
199{ 213{
200 struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 214 struct gfar_private *priv = netdev_priv(to_net_dev(dev));
215 struct gfar __iomem *regs = priv->gfargrp[0].regs;
201 unsigned int length = simple_strtoul(buf, NULL, 0); 216 unsigned int length = simple_strtoul(buf, NULL, 0);
202 u32 temp; 217 u32 temp;
203 unsigned long flags; 218 unsigned long flags;
@@ -205,16 +220,18 @@ static ssize_t gfar_set_fifo_threshold(struct device *dev,
205 if (length > GFAR_MAX_FIFO_THRESHOLD) 220 if (length > GFAR_MAX_FIFO_THRESHOLD)
206 return count; 221 return count;
207 222
208 spin_lock_irqsave(&priv->txlock, flags); 223 local_irq_save(flags);
224 lock_tx_qs(priv);
209 225
210 priv->fifo_threshold = length; 226 priv->fifo_threshold = length;
211 227
212 temp = gfar_read(&priv->regs->fifo_tx_thr); 228 temp = gfar_read(&regs->fifo_tx_thr);
213 temp &= ~FIFO_TX_THR_MASK; 229 temp &= ~FIFO_TX_THR_MASK;
214 temp |= length; 230 temp |= length;
215 gfar_write(&priv->regs->fifo_tx_thr, temp); 231 gfar_write(&regs->fifo_tx_thr, temp);
216 232
217 spin_unlock_irqrestore(&priv->txlock, flags); 233 unlock_tx_qs(priv);
234 local_irq_restore(flags);
218 235
219 return count; 236 return count;
220} 237}
@@ -235,6 +252,7 @@ static ssize_t gfar_set_fifo_starve(struct device *dev,
235 const char *buf, size_t count) 252 const char *buf, size_t count)
236{ 253{
237 struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 254 struct gfar_private *priv = netdev_priv(to_net_dev(dev));
255 struct gfar __iomem *regs = priv->gfargrp[0].regs;
238 unsigned int num = simple_strtoul(buf, NULL, 0); 256 unsigned int num = simple_strtoul(buf, NULL, 0);
239 u32 temp; 257 u32 temp;
240 unsigned long flags; 258 unsigned long flags;
@@ -242,16 +260,18 @@ static ssize_t gfar_set_fifo_starve(struct device *dev,
242 if (num > GFAR_MAX_FIFO_STARVE) 260 if (num > GFAR_MAX_FIFO_STARVE)
243 return count; 261 return count;
244 262
245 spin_lock_irqsave(&priv->txlock, flags); 263 local_irq_save(flags);
264 lock_tx_qs(priv);
246 265
247 priv->fifo_starve = num; 266 priv->fifo_starve = num;
248 267
249 temp = gfar_read(&priv->regs->fifo_tx_starve); 268 temp = gfar_read(&regs->fifo_tx_starve);
250 temp &= ~FIFO_TX_STARVE_MASK; 269 temp &= ~FIFO_TX_STARVE_MASK;
251 temp |= num; 270 temp |= num;
252 gfar_write(&priv->regs->fifo_tx_starve, temp); 271 gfar_write(&regs->fifo_tx_starve, temp);
253 272
254 spin_unlock_irqrestore(&priv->txlock, flags); 273 unlock_tx_qs(priv);
274 local_irq_restore(flags);
255 275
256 return count; 276 return count;
257} 277}
@@ -273,6 +293,7 @@ static ssize_t gfar_set_fifo_starve_off(struct device *dev,
273 const char *buf, size_t count) 293 const char *buf, size_t count)
274{ 294{
275 struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 295 struct gfar_private *priv = netdev_priv(to_net_dev(dev));
296 struct gfar __iomem *regs = priv->gfargrp[0].regs;
276 unsigned int num = simple_strtoul(buf, NULL, 0); 297 unsigned int num = simple_strtoul(buf, NULL, 0);
277 u32 temp; 298 u32 temp;
278 unsigned long flags; 299 unsigned long flags;
@@ -280,16 +301,18 @@ static ssize_t gfar_set_fifo_starve_off(struct device *dev,
280 if (num > GFAR_MAX_FIFO_STARVE_OFF) 301 if (num > GFAR_MAX_FIFO_STARVE_OFF)
281 return count; 302 return count;
282 303
283 spin_lock_irqsave(&priv->txlock, flags); 304 local_irq_save(flags);
305 lock_tx_qs(priv);
284 306
285 priv->fifo_starve_off = num; 307 priv->fifo_starve_off = num;
286 308
287 temp = gfar_read(&priv->regs->fifo_tx_starve_shutoff); 309 temp = gfar_read(&regs->fifo_tx_starve_shutoff);
288 temp &= ~FIFO_TX_STARVE_OFF_MASK; 310 temp &= ~FIFO_TX_STARVE_OFF_MASK;
289 temp |= num; 311 temp |= num;
290 gfar_write(&priv->regs->fifo_tx_starve_shutoff, temp); 312 gfar_write(&regs->fifo_tx_starve_shutoff, temp);
291 313
292 spin_unlock_irqrestore(&priv->txlock, flags); 314 unlock_tx_qs(priv);
315 local_irq_restore(flags);
293 316
294 return count; 317 return count;
295} 318}