diff options
Diffstat (limited to 'drivers/net/wireless/b43/sysfs.c')
-rw-r--r-- | drivers/net/wireless/b43/sysfs.c | 89 |
1 files changed, 1 insertions, 88 deletions
diff --git a/drivers/net/wireless/b43/sysfs.c b/drivers/net/wireless/b43/sysfs.c index f4faff6a7d6c..275095b8cbe7 100644 --- a/drivers/net/wireless/b43/sysfs.c +++ b/drivers/net/wireless/b43/sysfs.c | |||
@@ -47,29 +47,6 @@ static int get_integer(const char *buf, size_t count) | |||
47 | return ret; | 47 | return ret; |
48 | } | 48 | } |
49 | 49 | ||
50 | static int get_boolean(const char *buf, size_t count) | ||
51 | { | ||
52 | if (count != 0) { | ||
53 | if (buf[0] == '1') | ||
54 | return 1; | ||
55 | if (buf[0] == '0') | ||
56 | return 0; | ||
57 | if (count >= 4 && memcmp(buf, "true", 4) == 0) | ||
58 | return 1; | ||
59 | if (count >= 5 && memcmp(buf, "false", 5) == 0) | ||
60 | return 0; | ||
61 | if (count >= 3 && memcmp(buf, "yes", 3) == 0) | ||
62 | return 1; | ||
63 | if (count >= 2 && memcmp(buf, "no", 2) == 0) | ||
64 | return 0; | ||
65 | if (count >= 2 && memcmp(buf, "on", 2) == 0) | ||
66 | return 1; | ||
67 | if (count >= 3 && memcmp(buf, "off", 3) == 0) | ||
68 | return 0; | ||
69 | } | ||
70 | return -EINVAL; | ||
71 | } | ||
72 | |||
73 | static ssize_t b43_attr_interfmode_show(struct device *dev, | 50 | static ssize_t b43_attr_interfmode_show(struct device *dev, |
74 | struct device_attribute *attr, | 51 | struct device_attribute *attr, |
75 | char *buf) | 52 | char *buf) |
@@ -155,82 +132,18 @@ static ssize_t b43_attr_interfmode_store(struct device *dev, | |||
155 | static DEVICE_ATTR(interference, 0644, | 132 | static DEVICE_ATTR(interference, 0644, |
156 | b43_attr_interfmode_show, b43_attr_interfmode_store); | 133 | b43_attr_interfmode_show, b43_attr_interfmode_store); |
157 | 134 | ||
158 | static ssize_t b43_attr_preamble_show(struct device *dev, | ||
159 | struct device_attribute *attr, char *buf) | ||
160 | { | ||
161 | struct b43_wldev *wldev = dev_to_b43_wldev(dev); | ||
162 | ssize_t count; | ||
163 | |||
164 | if (!capable(CAP_NET_ADMIN)) | ||
165 | return -EPERM; | ||
166 | |||
167 | mutex_lock(&wldev->wl->mutex); | ||
168 | |||
169 | if (wldev->short_preamble) | ||
170 | count = | ||
171 | snprintf(buf, PAGE_SIZE, "1 (Short Preamble enabled)\n"); | ||
172 | else | ||
173 | count = | ||
174 | snprintf(buf, PAGE_SIZE, "0 (Short Preamble disabled)\n"); | ||
175 | |||
176 | mutex_unlock(&wldev->wl->mutex); | ||
177 | |||
178 | return count; | ||
179 | } | ||
180 | |||
181 | static ssize_t b43_attr_preamble_store(struct device *dev, | ||
182 | struct device_attribute *attr, | ||
183 | const char *buf, size_t count) | ||
184 | { | ||
185 | struct b43_wldev *wldev = dev_to_b43_wldev(dev); | ||
186 | unsigned long flags; | ||
187 | int value; | ||
188 | |||
189 | if (!capable(CAP_NET_ADMIN)) | ||
190 | return -EPERM; | ||
191 | |||
192 | value = get_boolean(buf, count); | ||
193 | if (value < 0) | ||
194 | return value; | ||
195 | mutex_lock(&wldev->wl->mutex); | ||
196 | spin_lock_irqsave(&wldev->wl->irq_lock, flags); | ||
197 | |||
198 | wldev->short_preamble = !!value; | ||
199 | |||
200 | spin_unlock_irqrestore(&wldev->wl->irq_lock, flags); | ||
201 | mutex_unlock(&wldev->wl->mutex); | ||
202 | |||
203 | return count; | ||
204 | } | ||
205 | |||
206 | static DEVICE_ATTR(shortpreamble, 0644, | ||
207 | b43_attr_preamble_show, b43_attr_preamble_store); | ||
208 | |||
209 | int b43_sysfs_register(struct b43_wldev *wldev) | 135 | int b43_sysfs_register(struct b43_wldev *wldev) |
210 | { | 136 | { |
211 | struct device *dev = wldev->dev->dev; | 137 | struct device *dev = wldev->dev->dev; |
212 | int err; | ||
213 | 138 | ||
214 | B43_WARN_ON(b43_status(wldev) != B43_STAT_INITIALIZED); | 139 | B43_WARN_ON(b43_status(wldev) != B43_STAT_INITIALIZED); |
215 | 140 | ||
216 | err = device_create_file(dev, &dev_attr_interference); | 141 | return device_create_file(dev, &dev_attr_interference); |
217 | if (err) | ||
218 | goto out; | ||
219 | err = device_create_file(dev, &dev_attr_shortpreamble); | ||
220 | if (err) | ||
221 | goto err_remove_interfmode; | ||
222 | |||
223 | out: | ||
224 | return err; | ||
225 | err_remove_interfmode: | ||
226 | device_remove_file(dev, &dev_attr_interference); | ||
227 | goto out; | ||
228 | } | 142 | } |
229 | 143 | ||
230 | void b43_sysfs_unregister(struct b43_wldev *wldev) | 144 | void b43_sysfs_unregister(struct b43_wldev *wldev) |
231 | { | 145 | { |
232 | struct device *dev = wldev->dev->dev; | 146 | struct device *dev = wldev->dev->dev; |
233 | 147 | ||
234 | device_remove_file(dev, &dev_attr_shortpreamble); | ||
235 | device_remove_file(dev, &dev_attr_interference); | 148 | device_remove_file(dev, &dev_attr_interference); |
236 | } | 149 | } |