aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/uwb/wlp
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/uwb/wlp
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/uwb/wlp')
-rw-r--r--drivers/uwb/wlp/eda.c1
-rw-r--r--drivers/uwb/wlp/messages.c107
-rw-r--r--drivers/uwb/wlp/sysfs.c3
-rw-r--r--drivers/uwb/wlp/txrx.c3
-rw-r--r--drivers/uwb/wlp/wlp-lc.c1
-rw-r--r--drivers/uwb/wlp/wss-lc.c1
6 files changed, 68 insertions, 48 deletions
diff --git a/drivers/uwb/wlp/eda.c b/drivers/uwb/wlp/eda.c
index 69e020039718..086fc0cf9401 100644
--- a/drivers/uwb/wlp/eda.c
+++ b/drivers/uwb/wlp/eda.c
@@ -53,6 +53,7 @@
53 53
54#include <linux/netdevice.h> 54#include <linux/netdevice.h>
55#include <linux/etherdevice.h> 55#include <linux/etherdevice.h>
56#include <linux/slab.h>
56#include <linux/wlp.h> 57#include <linux/wlp.h>
57#include "wlp-internal.h" 58#include "wlp-internal.h"
58 59
diff --git a/drivers/uwb/wlp/messages.c b/drivers/uwb/wlp/messages.c
index aa42fcee4c4f..3a8e033dce21 100644
--- a/drivers/uwb/wlp/messages.c
+++ b/drivers/uwb/wlp/messages.c
@@ -24,6 +24,7 @@
24 */ 24 */
25 25
26#include <linux/wlp.h> 26#include <linux/wlp.h>
27#include <linux/slab.h>
27 28
28#include "wlp-internal.h" 29#include "wlp-internal.h"
29 30
@@ -259,6 +260,63 @@ out:
259} 260}
260 261
261 262
263static ssize_t wlp_get_attribute(struct wlp *wlp, u16 type_code,
264 struct wlp_attr_hdr *attr_hdr, void *value, ssize_t value_len,
265 ssize_t buflen)
266{
267 struct device *dev = &wlp->rc->uwb_dev.dev;
268 ssize_t attr_len = sizeof(*attr_hdr) + value_len;
269 if (buflen < 0)
270 return -EINVAL;
271 if (buflen < attr_len) {
272 dev_err(dev, "WLP: Not enough space in buffer to parse"
273 " attribute field. Need %d, received %zu\n",
274 (int)attr_len, buflen);
275 return -EIO;
276 }
277 if (wlp_check_attr_hdr(wlp, attr_hdr, type_code, value_len) < 0) {
278 dev_err(dev, "WLP: Header verification failed. \n");
279 return -EINVAL;
280 }
281 memcpy(value, (void *)attr_hdr + sizeof(*attr_hdr), value_len);
282 return attr_len;
283}
284
285static ssize_t wlp_vget_attribute(struct wlp *wlp, u16 type_code,
286 struct wlp_attr_hdr *attr_hdr, void *value, ssize_t max_value_len,
287 ssize_t buflen)
288{
289 struct device *dev = &wlp->rc->uwb_dev.dev;
290 size_t len;
291 if (buflen < 0)
292 return -EINVAL;
293 if (buflen < sizeof(*attr_hdr)) {
294 dev_err(dev, "WLP: Not enough space in buffer to parse"
295 " header.\n");
296 return -EIO;
297 }
298 if (le16_to_cpu(attr_hdr->type) != type_code) {
299 dev_err(dev, "WLP: Unexpected attribute type. Got %u, "
300 "expected %u.\n", le16_to_cpu(attr_hdr->type),
301 type_code);
302 return -EINVAL;
303 }
304 len = le16_to_cpu(attr_hdr->length);
305 if (len > max_value_len) {
306 dev_err(dev, "WLP: Attribute larger than maximum "
307 "allowed. Received %zu, max is %d.\n", len,
308 (int)max_value_len);
309 return -EFBIG;
310 }
311 if (buflen < sizeof(*attr_hdr) + len) {
312 dev_err(dev, "WLP: Not enough space in buffer to parse "
313 "variable data.\n");
314 return -EIO;
315 }
316 memcpy(value, (void *)attr_hdr + sizeof(*attr_hdr), len);
317 return sizeof(*attr_hdr) + len;
318}
319
262/** 320/**
263 * Get value of attribute from fixed size attribute field. 321 * Get value of attribute from fixed size attribute field.
264 * 322 *
@@ -274,22 +332,8 @@ out:
274ssize_t wlp_get_##name(struct wlp *wlp, struct wlp_attr_##name *attr, \ 332ssize_t wlp_get_##name(struct wlp *wlp, struct wlp_attr_##name *attr, \
275 type *value, ssize_t buflen) \ 333 type *value, ssize_t buflen) \
276{ \ 334{ \
277 struct device *dev = &wlp->rc->uwb_dev.dev; \ 335 return wlp_get_attribute(wlp, (type_code), &attr->hdr, \
278 if (buflen < 0) \ 336 value, sizeof(*value), buflen); \
279 return -EINVAL; \
280 if (buflen < sizeof(*attr)) { \
281 dev_err(dev, "WLP: Not enough space in buffer to parse" \
282 " attribute field. Need %d, received %zu\n", \
283 (int)sizeof(*attr), buflen); \
284 return -EIO; \
285 } \
286 if (wlp_check_attr_hdr(wlp, &attr->hdr, type_code, \
287 sizeof(attr->name)) < 0) { \
288 dev_err(dev, "WLP: Header verification failed. \n"); \
289 return -EINVAL; \
290 } \
291 *value = attr->name; \
292 return sizeof(*attr); \
293} 337}
294 338
295#define wlp_get_sparse(type, type_code, name) \ 339#define wlp_get_sparse(type, type_code, name) \
@@ -313,35 +357,8 @@ static ssize_t wlp_get_##name(struct wlp *wlp, \
313 struct wlp_attr_##name *attr, \ 357 struct wlp_attr_##name *attr, \
314 type_val *value, ssize_t buflen) \ 358 type_val *value, ssize_t buflen) \
315{ \ 359{ \
316 struct device *dev = &wlp->rc->uwb_dev.dev; \ 360 return wlp_vget_attribute(wlp, (type_code), &attr->hdr, \
317 size_t len; \ 361 value, (max), buflen); \
318 if (buflen < 0) \
319 return -EINVAL; \
320 if (buflen < sizeof(*attr)) { \
321 dev_err(dev, "WLP: Not enough space in buffer to parse" \
322 " header.\n"); \
323 return -EIO; \
324 } \
325 if (le16_to_cpu(attr->hdr.type) != type_code) { \
326 dev_err(dev, "WLP: Unexpected attribute type. Got %u, " \
327 "expected %u.\n", le16_to_cpu(attr->hdr.type), \
328 type_code); \
329 return -EINVAL; \
330 } \
331 len = le16_to_cpu(attr->hdr.length); \
332 if (len > max) { \
333 dev_err(dev, "WLP: Attribute larger than maximum " \
334 "allowed. Received %zu, max is %d.\n", len, \
335 (int)max); \
336 return -EFBIG; \
337 } \
338 if (buflen < sizeof(*attr) + len) { \
339 dev_err(dev, "WLP: Not enough space in buffer to parse "\
340 "variable data.\n"); \
341 return -EIO; \
342 } \
343 memcpy(value, (void *) attr + sizeof(*attr), len); \
344 return sizeof(*attr) + len; \
345} 362}
346 363
347wlp_get(u8, WLP_ATTR_WLP_VER, version) 364wlp_get(u8, WLP_ATTR_WLP_VER, version)
diff --git a/drivers/uwb/wlp/sysfs.c b/drivers/uwb/wlp/sysfs.c
index 0370399ff4bb..6627c94cc854 100644
--- a/drivers/uwb/wlp/sysfs.c
+++ b/drivers/uwb/wlp/sysfs.c
@@ -615,8 +615,7 @@ ssize_t wlp_wss_attr_store(struct kobject *kobj, struct attribute *attr,
615 return ret; 615 return ret;
616} 616}
617 617
618static 618static const struct sysfs_ops wss_sysfs_ops = {
619struct sysfs_ops wss_sysfs_ops = {
620 .show = wlp_wss_attr_show, 619 .show = wlp_wss_attr_show,
621 .store = wlp_wss_attr_store, 620 .store = wlp_wss_attr_store,
622}; 621};
diff --git a/drivers/uwb/wlp/txrx.c b/drivers/uwb/wlp/txrx.c
index 86a853b84119..05dde44b3592 100644
--- a/drivers/uwb/wlp/txrx.c
+++ b/drivers/uwb/wlp/txrx.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/etherdevice.h> 27#include <linux/etherdevice.h>
28#include <linux/slab.h>
28#include <linux/wlp.h> 29#include <linux/wlp.h>
29 30
30#include "wlp-internal.h" 31#include "wlp-internal.h"
@@ -282,7 +283,7 @@ EXPORT_SYMBOL_GPL(wlp_receive_frame);
282 * and transmission will be done by the calling function. 283 * and transmission will be done by the calling function.
283 * @dst: On return this will contain the device address to which the 284 * @dst: On return this will contain the device address to which the
284 * frame is destined. 285 * frame is destined.
285 * @returns: 0 on success no tx : WLP header sucessfully applied to skb buffer, 286 * @returns: 0 on success no tx : WLP header successfully applied to skb buffer,
286 * calling function can proceed with tx 287 * calling function can proceed with tx
287 * 1 on success with tx : WLP will take over transmission of this 288 * 1 on success with tx : WLP will take over transmission of this
288 * frame 289 * frame
diff --git a/drivers/uwb/wlp/wlp-lc.c b/drivers/uwb/wlp/wlp-lc.c
index 13db739c4e39..7f6a630bf26c 100644
--- a/drivers/uwb/wlp/wlp-lc.c
+++ b/drivers/uwb/wlp/wlp-lc.c
@@ -22,6 +22,7 @@
22 * FIXME: docs 22 * FIXME: docs
23 */ 23 */
24#include <linux/wlp.h> 24#include <linux/wlp.h>
25#include <linux/slab.h>
25 26
26#include "wlp-internal.h" 27#include "wlp-internal.h"
27 28
diff --git a/drivers/uwb/wlp/wss-lc.c b/drivers/uwb/wlp/wss-lc.c
index 5913c7a5d922..90accdd54c07 100644
--- a/drivers/uwb/wlp/wss-lc.c
+++ b/drivers/uwb/wlp/wss-lc.c
@@ -45,6 +45,7 @@
45 */ 45 */
46#include <linux/etherdevice.h> /* for is_valid_ether_addr */ 46#include <linux/etherdevice.h> /* for is_valid_ether_addr */
47#include <linux/skbuff.h> 47#include <linux/skbuff.h>
48#include <linux/slab.h>
48#include <linux/wlp.h> 49#include <linux/wlp.h>
49 50
50#include "wlp-internal.h" 51#include "wlp-internal.h"