aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-09-12 11:43:28 -0400
committerJeff Garzik <jeff@garzik.org>2006-09-12 11:43:28 -0400
commitc925f1ea9ec20a95d46f57810f4a4d69db74580e (patch)
tree150d09324f1cf6b231bbe1f3791a75f9169470dd /drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c
parent8083e1656211eb1487329923d592ee061d08d7b3 (diff)
parent884d3a2bad7293e56fe99d9322a1090bfdfd7c4e (diff)
Merge branch 'upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6 into upstream
Diffstat (limited to 'drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c')
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c74
1 files changed, 65 insertions, 9 deletions
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c b/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c
index ece335178f6a..c71b998a3694 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c
@@ -176,7 +176,6 @@ static ssize_t bcm43xx_attr_interfmode_show(struct device *dev,
176 char *buf) 176 char *buf)
177{ 177{
178 struct bcm43xx_private *bcm = dev_to_bcm(dev); 178 struct bcm43xx_private *bcm = dev_to_bcm(dev);
179 int err;
180 ssize_t count = 0; 179 ssize_t count = 0;
181 180
182 if (!capable(CAP_NET_ADMIN)) 181 if (!capable(CAP_NET_ADMIN))
@@ -197,11 +196,10 @@ static ssize_t bcm43xx_attr_interfmode_show(struct device *dev,
197 default: 196 default:
198 assert(0); 197 assert(0);
199 } 198 }
200 err = 0;
201 199
202 mutex_unlock(&bcm->mutex); 200 mutex_unlock(&bcm->mutex);
203 201
204 return err ? err : count; 202 return count;
205 203
206} 204}
207 205
@@ -259,7 +257,6 @@ static ssize_t bcm43xx_attr_preamble_show(struct device *dev,
259 char *buf) 257 char *buf)
260{ 258{
261 struct bcm43xx_private *bcm = dev_to_bcm(dev); 259 struct bcm43xx_private *bcm = dev_to_bcm(dev);
262 int err;
263 ssize_t count; 260 ssize_t count;
264 261
265 if (!capable(CAP_NET_ADMIN)) 262 if (!capable(CAP_NET_ADMIN))
@@ -272,10 +269,9 @@ static ssize_t bcm43xx_attr_preamble_show(struct device *dev,
272 else 269 else
273 count = snprintf(buf, PAGE_SIZE, "0 (Short Preamble disabled)\n"); 270 count = snprintf(buf, PAGE_SIZE, "0 (Short Preamble disabled)\n");
274 271
275 err = 0;
276 mutex_unlock(&bcm->mutex); 272 mutex_unlock(&bcm->mutex);
277 273
278 return err ? err : count; 274 return count;
279} 275}
280 276
281static ssize_t bcm43xx_attr_preamble_store(struct device *dev, 277static ssize_t bcm43xx_attr_preamble_store(struct device *dev,
@@ -284,7 +280,6 @@ static ssize_t bcm43xx_attr_preamble_store(struct device *dev,
284{ 280{
285 struct bcm43xx_private *bcm = dev_to_bcm(dev); 281 struct bcm43xx_private *bcm = dev_to_bcm(dev);
286 unsigned long flags; 282 unsigned long flags;
287 int err;
288 int value; 283 int value;
289 284
290 if (!capable(CAP_NET_ADMIN)) 285 if (!capable(CAP_NET_ADMIN))
@@ -298,11 +293,10 @@ static ssize_t bcm43xx_attr_preamble_store(struct device *dev,
298 293
299 bcm->short_preamble = !!value; 294 bcm->short_preamble = !!value;
300 295
301 err = 0;
302 spin_unlock_irqrestore(&bcm->irq_lock, flags); 296 spin_unlock_irqrestore(&bcm->irq_lock, flags);
303 mutex_unlock(&bcm->mutex); 297 mutex_unlock(&bcm->mutex);
304 298
305 return err ? err : count; 299 return count;
306} 300}
307 301
308static DEVICE_ATTR(shortpreamble, 0644, 302static DEVICE_ATTR(shortpreamble, 0644,
@@ -333,8 +327,11 @@ static ssize_t bcm43xx_attr_phymode_store(struct device *dev,
333 goto out; 327 goto out;
334 } 328 }
335 329
330 bcm43xx_periodic_tasks_delete(bcm);
336 mutex_lock(&(bcm)->mutex); 331 mutex_lock(&(bcm)->mutex);
337 err = bcm43xx_select_wireless_core(bcm, phytype); 332 err = bcm43xx_select_wireless_core(bcm, phytype);
333 if (!err)
334 bcm43xx_periodic_tasks_setup(bcm);
338 mutex_unlock(&(bcm)->mutex); 335 mutex_unlock(&(bcm)->mutex);
339 if (err == -ESRCH) 336 if (err == -ESRCH)
340 err = -ENODEV; 337 err = -ENODEV;
@@ -373,6 +370,59 @@ static DEVICE_ATTR(phymode, 0644,
373 bcm43xx_attr_phymode_show, 370 bcm43xx_attr_phymode_show,
374 bcm43xx_attr_phymode_store); 371 bcm43xx_attr_phymode_store);
375 372
373static ssize_t bcm43xx_attr_microcode_show(struct device *dev,
374 struct device_attribute *attr,
375 char *buf)
376{
377 unsigned long flags;
378 struct bcm43xx_private *bcm = dev_to_bcm(dev);
379 ssize_t count = 0;
380 u16 status;
381
382 if (!capable(CAP_NET_ADMIN))
383 return -EPERM;
384
385 mutex_lock(&(bcm)->mutex);
386 spin_lock_irqsave(&bcm->irq_lock, flags);
387 status = bcm43xx_shm_read16(bcm, BCM43xx_SHM_SHARED,
388 BCM43xx_UCODE_STATUS);
389
390 spin_unlock_irqrestore(&bcm->irq_lock, flags);
391 mutex_unlock(&(bcm)->mutex);
392 switch (status) {
393 case 0x0000:
394 count = snprintf(buf, PAGE_SIZE, "0x%.4x (invalid)\n",
395 status);
396 break;
397 case 0x0001:
398 count = snprintf(buf, PAGE_SIZE, "0x%.4x (init)\n",
399 status);
400 break;
401 case 0x0002:
402 count = snprintf(buf, PAGE_SIZE, "0x%.4x (active)\n",
403 status);
404 break;
405 case 0x0003:
406 count = snprintf(buf, PAGE_SIZE, "0x%.4x (suspended)\n",
407 status);
408 break;
409 case 0x0004:
410 count = snprintf(buf, PAGE_SIZE, "0x%.4x (asleep)\n",
411 status);
412 break;
413 default:
414 count = snprintf(buf, PAGE_SIZE, "0x%.4x (unknown)\n",
415 status);
416 break;
417 }
418
419 return count;
420}
421
422static DEVICE_ATTR(microcodestatus, 0444,
423 bcm43xx_attr_microcode_show,
424 NULL);
425
376int bcm43xx_sysfs_register(struct bcm43xx_private *bcm) 426int bcm43xx_sysfs_register(struct bcm43xx_private *bcm)
377{ 427{
378 struct device *dev = &bcm->pci_dev->dev; 428 struct device *dev = &bcm->pci_dev->dev;
@@ -392,9 +442,14 @@ int bcm43xx_sysfs_register(struct bcm43xx_private *bcm)
392 err = device_create_file(dev, &dev_attr_phymode); 442 err = device_create_file(dev, &dev_attr_phymode);
393 if (err) 443 if (err)
394 goto err_remove_shortpreamble; 444 goto err_remove_shortpreamble;
445 err = device_create_file(dev, &dev_attr_microcodestatus);
446 if (err)
447 goto err_remove_phymode;
395 448
396out: 449out:
397 return err; 450 return err;
451err_remove_phymode:
452 device_remove_file(dev, &dev_attr_phymode);
398err_remove_shortpreamble: 453err_remove_shortpreamble:
399 device_remove_file(dev, &dev_attr_shortpreamble); 454 device_remove_file(dev, &dev_attr_shortpreamble);
400err_remove_interfmode: 455err_remove_interfmode:
@@ -408,6 +463,7 @@ void bcm43xx_sysfs_unregister(struct bcm43xx_private *bcm)
408{ 463{
409 struct device *dev = &bcm->pci_dev->dev; 464 struct device *dev = &bcm->pci_dev->dev;
410 465
466 device_remove_file(dev, &dev_attr_microcodestatus);
411 device_remove_file(dev, &dev_attr_phymode); 467 device_remove_file(dev, &dev_attr_phymode);
412 device_remove_file(dev, &dev_attr_shortpreamble); 468 device_remove_file(dev, &dev_attr_shortpreamble);
413 device_remove_file(dev, &dev_attr_interference); 469 device_remove_file(dev, &dev_attr_interference);