3 Broadcom B43 wireless driver
7 Copyright (c) 2006 Michael Buesch <m@bues.ch>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; see the file COPYING. If not, write to
21 the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
22 Boston, MA 02110-1301, USA.
26 #include <linux/capability.h>
32 #include "phy_common.h"
34 #define GENERIC_FILESIZE 64
36 static int get_integer(const char *buf
, size_t count
)
38 char tmp
[10 + 1] = { 0 };
43 count
= min(count
, (size_t) 10);
44 memcpy(tmp
, buf
, count
);
45 ret
= simple_strtol(tmp
, NULL
, 10);
50 static ssize_t
b43_attr_interfmode_show(struct device
*dev
,
51 struct device_attribute
*attr
,
54 struct b43_wldev
*wldev
= dev_to_b43_wldev(dev
);
57 if (!capable(CAP_NET_ADMIN
))
60 mutex_lock(&wldev
->wl
->mutex
);
62 if (wldev
->phy
.type
!= B43_PHYTYPE_G
) {
63 mutex_unlock(&wldev
->wl
->mutex
);
67 switch (wldev
->phy
.g
->interfmode
) {
68 case B43_INTERFMODE_NONE
:
70 snprintf(buf
, PAGE_SIZE
,
71 "0 (No Interference Mitigation)\n");
73 case B43_INTERFMODE_NONWLAN
:
75 snprintf(buf
, PAGE_SIZE
,
76 "1 (Non-WLAN Interference Mitigation)\n");
78 case B43_INTERFMODE_MANUALWLAN
:
80 snprintf(buf
, PAGE_SIZE
,
81 "2 (WLAN Interference Mitigation)\n");
87 mutex_unlock(&wldev
->wl
->mutex
);
92 static ssize_t
b43_attr_interfmode_store(struct device
*dev
,
93 struct device_attribute
*attr
,
94 const char *buf
, size_t count
)
96 struct b43_wldev
*wldev
= dev_to_b43_wldev(dev
);
100 if (!capable(CAP_NET_ADMIN
))
103 mode
= get_integer(buf
, count
);
106 mode
= B43_INTERFMODE_NONE
;
109 mode
= B43_INTERFMODE_NONWLAN
;
112 mode
= B43_INTERFMODE_MANUALWLAN
;
115 mode
= B43_INTERFMODE_AUTOWLAN
;
121 mutex_lock(&wldev
->wl
->mutex
);
123 if (wldev
->phy
.ops
->interf_mitigation
) {
124 err
= wldev
->phy
.ops
->interf_mitigation(wldev
, mode
);
126 b43err(wldev
->wl
, "Interference Mitigation not "
127 "supported by device\n");
133 mutex_unlock(&wldev
->wl
->mutex
);
135 return err
? err
: count
;
138 static DEVICE_ATTR(interference
, 0644,
139 b43_attr_interfmode_show
, b43_attr_interfmode_store
);
141 int b43_sysfs_register(struct b43_wldev
*wldev
)
143 struct device
*dev
= wldev
->dev
->dev
;
145 B43_WARN_ON(b43_status(wldev
) != B43_STAT_INITIALIZED
);
147 return device_create_file(dev
, &dev_attr_interference
);
150 void b43_sysfs_unregister(struct b43_wldev
*wldev
)
152 struct device
*dev
= wldev
->dev
->dev
;
154 device_remove_file(dev
, &dev_attr_interference
);