aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/gianfar_sysfs.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/net/gianfar_sysfs.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/net/gianfar_sysfs.c')
-rw-r--r--drivers/net/gianfar_sysfs.c82
1 files changed, 52 insertions, 30 deletions
diff --git a/drivers/net/gianfar_sysfs.c b/drivers/net/gianfar_sysfs.c
index dd26da74f27a..64f4094ac7f1 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
@@ -23,7 +24,6 @@
23#include <linux/string.h> 24#include <linux/string.h>
24#include <linux/errno.h> 25#include <linux/errno.h>
25#include <linux/unistd.h> 26#include <linux/unistd.h>
26#include <linux/slab.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/etherdevice.h> 29#include <linux/etherdevice.h>
@@ -49,6 +49,7 @@ static ssize_t gfar_set_bd_stash(struct device *dev,
49 const char *buf, size_t count) 49 const char *buf, size_t count)
50{ 50{
51 struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 51 struct gfar_private *priv = netdev_priv(to_net_dev(dev));
52 struct gfar __iomem *regs = priv->gfargrp[0].regs;
52 int new_setting = 0; 53 int new_setting = 0;
53 u32 temp; 54 u32 temp;
54 unsigned long flags; 55 unsigned long flags;
@@ -56,30 +57,34 @@ static ssize_t gfar_set_bd_stash(struct device *dev,
56 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BD_STASHING)) 57 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BD_STASHING))
57 return count; 58 return count;
58 59
60
59 /* Find out the new setting */ 61 /* Find out the new setting */
60 if (!strncmp("on", buf, count - 1) || !strncmp("1", buf, count - 1)) 62 if (!strncmp("on", buf, count - 1) || !strncmp("1", buf, count - 1))
61 new_setting = 1; 63 new_setting = 1;
62 else if (!strncmp("off", buf, count - 1) 64 else if (!strncmp("off", buf, count - 1) ||
63 || !strncmp("0", buf, count - 1)) 65 !strncmp("0", buf, count - 1))
64 new_setting = 0; 66 new_setting = 0;
65 else 67 else
66 return count; 68 return count;
67 69
68 spin_lock_irqsave(&priv->rxlock, flags); 70
71 local_irq_save(flags);
72 lock_rx_qs(priv);
69 73
70 /* Set the new stashing value */ 74 /* Set the new stashing value */
71 priv->bd_stash_en = new_setting; 75 priv->bd_stash_en = new_setting;
72 76
73 temp = gfar_read(&priv->regs->attr); 77 temp = gfar_read(&regs->attr);
74 78
75 if (new_setting) 79 if (new_setting)
76 temp |= ATTR_BDSTASH; 80 temp |= ATTR_BDSTASH;
77 else 81 else
78 temp &= ~(ATTR_BDSTASH); 82 temp &= ~(ATTR_BDSTASH);
79 83
80 gfar_write(&priv->regs->attr, temp); 84 gfar_write(&regs->attr, temp);
81 85
82 spin_unlock_irqrestore(&priv->rxlock, flags); 86 unlock_rx_qs(priv);
87 local_irq_restore(flags);
83 88
84 return count; 89 return count;
85} 90}
@@ -99,6 +104,7 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev,
99 const char *buf, size_t count) 104 const char *buf, size_t count)
100{ 105{
101 struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 106 struct gfar_private *priv = netdev_priv(to_net_dev(dev));
107 struct gfar __iomem *regs = priv->gfargrp[0].regs;
102 unsigned int length = simple_strtoul(buf, NULL, 0); 108 unsigned int length = simple_strtoul(buf, NULL, 0);
103 u32 temp; 109 u32 temp;
104 unsigned long flags; 110 unsigned long flags;
@@ -106,7 +112,9 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev,
106 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING)) 112 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING))
107 return count; 113 return count;
108 114
109 spin_lock_irqsave(&priv->rxlock, flags); 115 local_irq_save(flags);
116 lock_rx_qs(priv);
117
110 if (length > priv->rx_buffer_size) 118 if (length > priv->rx_buffer_size)
111 goto out; 119 goto out;
112 120
@@ -115,23 +123,24 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev,
115 123
116 priv->rx_stash_size = length; 124 priv->rx_stash_size = length;
117 125
118 temp = gfar_read(&priv->regs->attreli); 126 temp = gfar_read(&regs->attreli);
119 temp &= ~ATTRELI_EL_MASK; 127 temp &= ~ATTRELI_EL_MASK;
120 temp |= ATTRELI_EL(length); 128 temp |= ATTRELI_EL(length);
121 gfar_write(&priv->regs->attreli, temp); 129 gfar_write(&regs->attreli, temp);
122 130
123 /* Turn stashing on/off as appropriate */ 131 /* Turn stashing on/off as appropriate */
124 temp = gfar_read(&priv->regs->attr); 132 temp = gfar_read(&regs->attr);
125 133
126 if (length) 134 if (length)
127 temp |= ATTR_BUFSTASH; 135 temp |= ATTR_BUFSTASH;
128 else 136 else
129 temp &= ~(ATTR_BUFSTASH); 137 temp &= ~(ATTR_BUFSTASH);
130 138
131 gfar_write(&priv->regs->attr, temp); 139 gfar_write(&regs->attr, temp);
132 140
133out: 141out:
134 spin_unlock_irqrestore(&priv->rxlock, flags); 142 unlock_rx_qs(priv);
143 local_irq_restore(flags);
135 144
136 return count; 145 return count;
137} 146}
@@ -154,6 +163,7 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev,
154 const char *buf, size_t count) 163 const char *buf, size_t count)
155{ 164{
156 struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 165 struct gfar_private *priv = netdev_priv(to_net_dev(dev));
166 struct gfar __iomem *regs = priv->gfargrp[0].regs;
157 unsigned short index = simple_strtoul(buf, NULL, 0); 167 unsigned short index = simple_strtoul(buf, NULL, 0);
158 u32 temp; 168 u32 temp;
159 unsigned long flags; 169 unsigned long flags;
@@ -161,7 +171,9 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev,
161 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING)) 171 if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING))
162 return count; 172 return count;
163 173
164 spin_lock_irqsave(&priv->rxlock, flags); 174 local_irq_save(flags);
175 lock_rx_qs(priv);
176
165 if (index > priv->rx_stash_size) 177 if (index > priv->rx_stash_size)
166 goto out; 178 goto out;
167 179
@@ -170,13 +182,14 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev,
170 182
171 priv->rx_stash_index = index; 183 priv->rx_stash_index = index;
172 184
173 temp = gfar_read(&priv->regs->attreli); 185 temp = gfar_read(&regs->attreli);
174 temp &= ~ATTRELI_EI_MASK; 186 temp &= ~ATTRELI_EI_MASK;
175 temp |= ATTRELI_EI(index); 187 temp |= ATTRELI_EI(index);
176 gfar_write(&priv->regs->attreli, flags); 188 gfar_write(&regs->attreli, temp);
177 189
178out: 190out:
179 spin_unlock_irqrestore(&priv->rxlock, flags); 191 unlock_rx_qs(priv);
192 local_irq_restore(flags);
180 193
181 return count; 194 return count;
182} 195}
@@ -198,6 +211,7 @@ static ssize_t gfar_set_fifo_threshold(struct device *dev,
198 const char *buf, size_t count) 211 const char *buf, size_t count)
199{ 212{
200 struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 213 struct gfar_private *priv = netdev_priv(to_net_dev(dev));
214 struct gfar __iomem *regs = priv->gfargrp[0].regs;
201 unsigned int length = simple_strtoul(buf, NULL, 0); 215 unsigned int length = simple_strtoul(buf, NULL, 0);
202 u32 temp; 216 u32 temp;
203 unsigned long flags; 217 unsigned long flags;
@@ -205,16 +219,18 @@ static ssize_t gfar_set_fifo_threshold(struct device *dev,
205 if (length > GFAR_MAX_FIFO_THRESHOLD) 219 if (length > GFAR_MAX_FIFO_THRESHOLD)
206 return count; 220 return count;
207 221
208 spin_lock_irqsave(&priv->txlock, flags); 222 local_irq_save(flags);
223 lock_tx_qs(priv);
209 224
210 priv->fifo_threshold = length; 225 priv->fifo_threshold = length;
211 226
212 temp = gfar_read(&priv->regs->fifo_tx_thr); 227 temp = gfar_read(&regs->fifo_tx_thr);
213 temp &= ~FIFO_TX_THR_MASK; 228 temp &= ~FIFO_TX_THR_MASK;
214 temp |= length; 229 temp |= length;
215 gfar_write(&priv->regs->fifo_tx_thr, temp); 230 gfar_write(&regs->fifo_tx_thr, temp);
216 231
217 spin_unlock_irqrestore(&priv->txlock, flags); 232 unlock_tx_qs(priv);
233 local_irq_restore(flags);
218 234
219 return count; 235 return count;
220} 236}
@@ -235,6 +251,7 @@ static ssize_t gfar_set_fifo_starve(struct device *dev,
235 const char *buf, size_t count) 251 const char *buf, size_t count)
236{ 252{
237 struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 253 struct gfar_private *priv = netdev_priv(to_net_dev(dev));
254 struct gfar __iomem *regs = priv->gfargrp[0].regs;
238 unsigned int num = simple_strtoul(buf, NULL, 0); 255 unsigned int num = simple_strtoul(buf, NULL, 0);
239 u32 temp; 256 u32 temp;
240 unsigned long flags; 257 unsigned long flags;
@@ -242,16 +259,18 @@ static ssize_t gfar_set_fifo_starve(struct device *dev,
242 if (num > GFAR_MAX_FIFO_STARVE) 259 if (num > GFAR_MAX_FIFO_STARVE)
243 return count; 260 return count;
244 261
245 spin_lock_irqsave(&priv->txlock, flags); 262 local_irq_save(flags);
263 lock_tx_qs(priv);
246 264
247 priv->fifo_starve = num; 265 priv->fifo_starve = num;
248 266
249 temp = gfar_read(&priv->regs->fifo_tx_starve); 267 temp = gfar_read(&regs->fifo_tx_starve);
250 temp &= ~FIFO_TX_STARVE_MASK; 268 temp &= ~FIFO_TX_STARVE_MASK;
251 temp |= num; 269 temp |= num;
252 gfar_write(&priv->regs->fifo_tx_starve, temp); 270 gfar_write(&regs->fifo_tx_starve, temp);
253 271
254 spin_unlock_irqrestore(&priv->txlock, flags); 272 unlock_tx_qs(priv);
273 local_irq_restore(flags);
255 274
256 return count; 275 return count;
257} 276}
@@ -273,6 +292,7 @@ static ssize_t gfar_set_fifo_starve_off(struct device *dev,
273 const char *buf, size_t count) 292 const char *buf, size_t count)
274{ 293{
275 struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 294 struct gfar_private *priv = netdev_priv(to_net_dev(dev));
295 struct gfar __iomem *regs = priv->gfargrp[0].regs;
276 unsigned int num = simple_strtoul(buf, NULL, 0); 296 unsigned int num = simple_strtoul(buf, NULL, 0);
277 u32 temp; 297 u32 temp;
278 unsigned long flags; 298 unsigned long flags;
@@ -280,16 +300,18 @@ static ssize_t gfar_set_fifo_starve_off(struct device *dev,
280 if (num > GFAR_MAX_FIFO_STARVE_OFF) 300 if (num > GFAR_MAX_FIFO_STARVE_OFF)
281 return count; 301 return count;
282 302
283 spin_lock_irqsave(&priv->txlock, flags); 303 local_irq_save(flags);
304 lock_tx_qs(priv);
284 305
285 priv->fifo_starve_off = num; 306 priv->fifo_starve_off = num;
286 307
287 temp = gfar_read(&priv->regs->fifo_tx_starve_shutoff); 308 temp = gfar_read(&regs->fifo_tx_starve_shutoff);
288 temp &= ~FIFO_TX_STARVE_OFF_MASK; 309 temp &= ~FIFO_TX_STARVE_OFF_MASK;
289 temp |= num; 310 temp |= num;
290 gfar_write(&priv->regs->fifo_tx_starve_shutoff, temp); 311 gfar_write(&regs->fifo_tx_starve_shutoff, temp);
291 312
292 spin_unlock_irqrestore(&priv->txlock, flags); 313 unlock_tx_qs(priv);
314 local_irq_restore(flags);
293 315
294 return count; 316 return count;
295} 317}