diff options
author | David Woodhouse <dwmw2@infradead.org> | 2007-07-23 05:20:10 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2007-07-23 05:20:10 -0400 |
commit | 39fe5434cb9de5da40510028b17b96bc4eb312b3 (patch) | |
tree | 7a02a317b9ad57da51ca99887c119e779ccf3f13 /net/irda | |
parent | 0fc72b81d3111d114ab378935b1cf07680ca1289 (diff) | |
parent | f695baf2df9e0413d3521661070103711545207a (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'net/irda')
-rw-r--r-- | net/irda/Makefile | 2 | ||||
-rw-r--r-- | net/irda/af_irda.c | 2 | ||||
-rw-r--r-- | net/irda/discovery.c | 2 | ||||
-rw-r--r-- | net/irda/ircomm/ircomm_core.c | 2 | ||||
-rw-r--r-- | net/irda/irda_device.c | 4 | ||||
-rw-r--r-- | net/irda/iriap.c | 4 | ||||
-rw-r--r-- | net/irda/irias_object.c | 43 | ||||
-rw-r--r-- | net/irda/irlan/irlan_common.c | 2 | ||||
-rw-r--r-- | net/irda/irlap.c | 4 | ||||
-rw-r--r-- | net/irda/irlap_frame.c | 7 | ||||
-rw-r--r-- | net/irda/irlmp.c | 4 | ||||
-rw-r--r-- | net/irda/irmod.c | 48 | ||||
-rw-r--r-- | net/irda/irnetlink.c | 170 | ||||
-rw-r--r-- | net/irda/irproc.c | 2 | ||||
-rw-r--r-- | net/irda/irsysctl.c | 2 | ||||
-rw-r--r-- | net/irda/irttp.c | 33 |
16 files changed, 262 insertions, 69 deletions
diff --git a/net/irda/Makefile b/net/irda/Makefile index d1366c2a39..187f6c563a 100644 --- a/net/irda/Makefile +++ b/net/irda/Makefile | |||
@@ -10,6 +10,6 @@ obj-$(CONFIG_IRCOMM) += ircomm/ | |||
10 | irda-y := iriap.o iriap_event.o irlmp.o irlmp_event.o irlmp_frame.o \ | 10 | irda-y := iriap.o iriap_event.o irlmp.o irlmp_event.o irlmp_frame.o \ |
11 | irlap.o irlap_event.o irlap_frame.o timer.o qos.o irqueue.o \ | 11 | irlap.o irlap_event.o irlap_frame.o timer.o qos.o irqueue.o \ |
12 | irttp.o irda_device.o irias_object.o wrapper.o af_irda.o \ | 12 | irttp.o irda_device.o irias_object.o wrapper.o af_irda.o \ |
13 | discovery.o parameters.o irmod.o | 13 | discovery.o parameters.o irnetlink.o irmod.o |
14 | irda-$(CONFIG_PROC_FS) += irproc.o | 14 | irda-$(CONFIG_PROC_FS) += irproc.o |
15 | irda-$(CONFIG_SYSCTL) += irsysctl.o | 15 | irda-$(CONFIG_SYSCTL) += irsysctl.o |
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index dcd7e325b2..4c670cf6ae 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c | |||
@@ -2567,7 +2567,7 @@ int __init irsock_init(void) | |||
2567 | * Remove IrDA protocol | 2567 | * Remove IrDA protocol |
2568 | * | 2568 | * |
2569 | */ | 2569 | */ |
2570 | void __exit irsock_cleanup(void) | 2570 | void irsock_cleanup(void) |
2571 | { | 2571 | { |
2572 | sock_unregister(PF_IRDA); | 2572 | sock_unregister(PF_IRDA); |
2573 | proto_unregister(&irda_proto); | 2573 | proto_unregister(&irda_proto); |
diff --git a/net/irda/discovery.c b/net/irda/discovery.c index f097341286..af0cea721d 100644 --- a/net/irda/discovery.c +++ b/net/irda/discovery.c | |||
@@ -395,7 +395,7 @@ static int discovery_seq_show(struct seq_file *seq, void *v) | |||
395 | return 0; | 395 | return 0; |
396 | } | 396 | } |
397 | 397 | ||
398 | static struct seq_operations discovery_seq_ops = { | 398 | static const struct seq_operations discovery_seq_ops = { |
399 | .start = discovery_seq_start, | 399 | .start = discovery_seq_start, |
400 | .next = discovery_seq_next, | 400 | .next = discovery_seq_next, |
401 | .stop = discovery_seq_stop, | 401 | .stop = discovery_seq_stop, |
diff --git a/net/irda/ircomm/ircomm_core.c b/net/irda/ircomm/ircomm_core.c index 4749f8f553..2d63fa8e15 100644 --- a/net/irda/ircomm/ircomm_core.c +++ b/net/irda/ircomm/ircomm_core.c | |||
@@ -562,7 +562,7 @@ static int ircomm_seq_show(struct seq_file *seq, void *v) | |||
562 | return 0; | 562 | return 0; |
563 | } | 563 | } |
564 | 564 | ||
565 | static struct seq_operations ircomm_seq_ops = { | 565 | static const struct seq_operations ircomm_seq_ops = { |
566 | .start = ircomm_seq_start, | 566 | .start = ircomm_seq_start, |
567 | .next = ircomm_seq_next, | 567 | .next = ircomm_seq_next, |
568 | .stop = ircomm_seq_stop, | 568 | .stop = ircomm_seq_stop, |
diff --git a/net/irda/irda_device.c b/net/irda/irda_device.c index 7b5def1ea6..435b563d29 100644 --- a/net/irda/irda_device.c +++ b/net/irda/irda_device.c | |||
@@ -95,14 +95,14 @@ int __init irda_device_init( void) | |||
95 | return 0; | 95 | return 0; |
96 | } | 96 | } |
97 | 97 | ||
98 | static void __exit leftover_dongle(void *arg) | 98 | static void leftover_dongle(void *arg) |
99 | { | 99 | { |
100 | struct dongle_reg *reg = arg; | 100 | struct dongle_reg *reg = arg; |
101 | IRDA_WARNING("IrDA: Dongle type %x not unregistered\n", | 101 | IRDA_WARNING("IrDA: Dongle type %x not unregistered\n", |
102 | reg->type); | 102 | reg->type); |
103 | } | 103 | } |
104 | 104 | ||
105 | void __exit irda_device_cleanup(void) | 105 | void irda_device_cleanup(void) |
106 | { | 106 | { |
107 | IRDA_DEBUG(4, "%s()\n", __FUNCTION__); | 107 | IRDA_DEBUG(4, "%s()\n", __FUNCTION__); |
108 | 108 | ||
diff --git a/net/irda/iriap.c b/net/irda/iriap.c index 915d9384f3..ee3889fa49 100644 --- a/net/irda/iriap.c +++ b/net/irda/iriap.c | |||
@@ -153,7 +153,7 @@ int __init iriap_init(void) | |||
153 | * Initializes the IrIAP layer, called by the module cleanup code in | 153 | * Initializes the IrIAP layer, called by the module cleanup code in |
154 | * irmod.c | 154 | * irmod.c |
155 | */ | 155 | */ |
156 | void __exit iriap_cleanup(void) | 156 | void iriap_cleanup(void) |
157 | { | 157 | { |
158 | irlmp_unregister_service(service_handle); | 158 | irlmp_unregister_service(service_handle); |
159 | 159 | ||
@@ -1066,7 +1066,7 @@ static int irias_seq_show(struct seq_file *seq, void *v) | |||
1066 | return 0; | 1066 | return 0; |
1067 | } | 1067 | } |
1068 | 1068 | ||
1069 | static struct seq_operations irias_seq_ops = { | 1069 | static const struct seq_operations irias_seq_ops = { |
1070 | .start = irias_seq_start, | 1070 | .start = irias_seq_start, |
1071 | .next = irias_seq_next, | 1071 | .next = irias_seq_next, |
1072 | .stop = irias_seq_stop, | 1072 | .stop = irias_seq_stop, |
diff --git a/net/irda/irias_object.c b/net/irda/irias_object.c index 4adaae242b..cf30245709 100644 --- a/net/irda/irias_object.c +++ b/net/irda/irias_object.c | |||
@@ -36,39 +36,6 @@ hashbin_t *irias_objects; | |||
36 | */ | 36 | */ |
37 | struct ias_value irias_missing = { IAS_MISSING, 0, 0, 0, {0}}; | 37 | struct ias_value irias_missing = { IAS_MISSING, 0, 0, 0, {0}}; |
38 | 38 | ||
39 | /* | ||
40 | * Function strndup (str, max) | ||
41 | * | ||
42 | * My own kernel version of strndup! | ||
43 | * | ||
44 | * Faster, check boundary... Jean II | ||
45 | */ | ||
46 | static char *strndup(char *str, size_t max) | ||
47 | { | ||
48 | char *new_str; | ||
49 | int len; | ||
50 | |||
51 | /* Check string */ | ||
52 | if (str == NULL) | ||
53 | return NULL; | ||
54 | /* Check length, truncate */ | ||
55 | len = strlen(str); | ||
56 | if(len > max) | ||
57 | len = max; | ||
58 | |||
59 | /* Allocate new string */ | ||
60 | new_str = kmalloc(len + 1, GFP_ATOMIC); | ||
61 | if (new_str == NULL) { | ||
62 | IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__); | ||
63 | return NULL; | ||
64 | } | ||
65 | |||
66 | /* Copy and truncate */ | ||
67 | memcpy(new_str, str, len); | ||
68 | new_str[len] = '\0'; | ||
69 | |||
70 | return new_str; | ||
71 | } | ||
72 | 39 | ||
73 | /* | 40 | /* |
74 | * Function ias_new_object (name, id) | 41 | * Function ias_new_object (name, id) |
@@ -90,7 +57,7 @@ struct ias_object *irias_new_object( char *name, int id) | |||
90 | } | 57 | } |
91 | 58 | ||
92 | obj->magic = IAS_OBJECT_MAGIC; | 59 | obj->magic = IAS_OBJECT_MAGIC; |
93 | obj->name = strndup(name, IAS_MAX_CLASSNAME); | 60 | obj->name = kstrndup(name, IAS_MAX_CLASSNAME, GFP_ATOMIC); |
94 | if (!obj->name) { | 61 | if (!obj->name) { |
95 | IRDA_WARNING("%s(), Unable to allocate name!\n", | 62 | IRDA_WARNING("%s(), Unable to allocate name!\n", |
96 | __FUNCTION__); | 63 | __FUNCTION__); |
@@ -360,7 +327,7 @@ void irias_add_integer_attrib(struct ias_object *obj, char *name, int value, | |||
360 | } | 327 | } |
361 | 328 | ||
362 | attrib->magic = IAS_ATTRIB_MAGIC; | 329 | attrib->magic = IAS_ATTRIB_MAGIC; |
363 | attrib->name = strndup(name, IAS_MAX_ATTRIBNAME); | 330 | attrib->name = kstrndup(name, IAS_MAX_ATTRIBNAME, GFP_ATOMIC); |
364 | 331 | ||
365 | /* Insert value */ | 332 | /* Insert value */ |
366 | attrib->value = irias_new_integer_value(value); | 333 | attrib->value = irias_new_integer_value(value); |
@@ -404,7 +371,7 @@ void irias_add_octseq_attrib(struct ias_object *obj, char *name, __u8 *octets, | |||
404 | } | 371 | } |
405 | 372 | ||
406 | attrib->magic = IAS_ATTRIB_MAGIC; | 373 | attrib->magic = IAS_ATTRIB_MAGIC; |
407 | attrib->name = strndup(name, IAS_MAX_ATTRIBNAME); | 374 | attrib->name = kstrndup(name, IAS_MAX_ATTRIBNAME, GFP_ATOMIC); |
408 | 375 | ||
409 | attrib->value = irias_new_octseq_value( octets, len); | 376 | attrib->value = irias_new_octseq_value( octets, len); |
410 | if (!attrib->name || !attrib->value) { | 377 | if (!attrib->name || !attrib->value) { |
@@ -446,7 +413,7 @@ void irias_add_string_attrib(struct ias_object *obj, char *name, char *value, | |||
446 | } | 413 | } |
447 | 414 | ||
448 | attrib->magic = IAS_ATTRIB_MAGIC; | 415 | attrib->magic = IAS_ATTRIB_MAGIC; |
449 | attrib->name = strndup(name, IAS_MAX_ATTRIBNAME); | 416 | attrib->name = kstrndup(name, IAS_MAX_ATTRIBNAME, GFP_ATOMIC); |
450 | 417 | ||
451 | attrib->value = irias_new_string_value(value); | 418 | attrib->value = irias_new_string_value(value); |
452 | if (!attrib->name || !attrib->value) { | 419 | if (!attrib->name || !attrib->value) { |
@@ -506,7 +473,7 @@ struct ias_value *irias_new_string_value(char *string) | |||
506 | 473 | ||
507 | value->type = IAS_STRING; | 474 | value->type = IAS_STRING; |
508 | value->charset = CS_ASCII; | 475 | value->charset = CS_ASCII; |
509 | value->t.string = strndup(string, IAS_MAX_STRING); | 476 | value->t.string = kstrndup(string, IAS_MAX_STRING, GFP_ATOMIC); |
510 | if (!value->t.string) { | 477 | if (!value->t.string) { |
511 | IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__); | 478 | IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__); |
512 | kfree(value); | 479 | kfree(value); |
diff --git a/net/irda/irlan/irlan_common.c b/net/irda/irlan/irlan_common.c index ed69773b0f..f5778ef3cc 100644 --- a/net/irda/irlan/irlan_common.c +++ b/net/irda/irlan/irlan_common.c | |||
@@ -1217,7 +1217,7 @@ static int irlan_seq_show(struct seq_file *seq, void *v) | |||
1217 | return 0; | 1217 | return 0; |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | static struct seq_operations irlan_seq_ops = { | 1220 | static const struct seq_operations irlan_seq_ops = { |
1221 | .start = irlan_seq_start, | 1221 | .start = irlan_seq_start, |
1222 | .next = irlan_seq_next, | 1222 | .next = irlan_seq_next, |
1223 | .stop = irlan_seq_stop, | 1223 | .stop = irlan_seq_stop, |
diff --git a/net/irda/irlap.c b/net/irda/irlap.c index d93ebd1143..3d76aafdb2 100644 --- a/net/irda/irlap.c +++ b/net/irda/irlap.c | |||
@@ -95,7 +95,7 @@ int __init irlap_init(void) | |||
95 | return 0; | 95 | return 0; |
96 | } | 96 | } |
97 | 97 | ||
98 | void __exit irlap_cleanup(void) | 98 | void irlap_cleanup(void) |
99 | { | 99 | { |
100 | IRDA_ASSERT(irlap != NULL, return;); | 100 | IRDA_ASSERT(irlap != NULL, return;); |
101 | 101 | ||
@@ -1210,7 +1210,7 @@ static int irlap_seq_show(struct seq_file *seq, void *v) | |||
1210 | return 0; | 1210 | return 0; |
1211 | } | 1211 | } |
1212 | 1212 | ||
1213 | static struct seq_operations irlap_seq_ops = { | 1213 | static const struct seq_operations irlap_seq_ops = { |
1214 | .start = irlap_seq_start, | 1214 | .start = irlap_seq_start, |
1215 | .next = irlap_seq_next, | 1215 | .next = irlap_seq_next, |
1216 | .stop = irlap_seq_stop, | 1216 | .stop = irlap_seq_stop, |
diff --git a/net/irda/irlap_frame.c b/net/irda/irlap_frame.c index 3013c49ab9..25a3444a92 100644 --- a/net/irda/irlap_frame.c +++ b/net/irda/irlap_frame.c | |||
@@ -101,6 +101,13 @@ void irlap_queue_xmit(struct irlap_cb *self, struct sk_buff *skb) | |||
101 | 101 | ||
102 | irlap_insert_info(self, skb); | 102 | irlap_insert_info(self, skb); |
103 | 103 | ||
104 | if (unlikely(self->mode & IRDA_MODE_MONITOR)) { | ||
105 | IRDA_DEBUG(3, "%s(): %s is in monitor mode\n", __FUNCTION__, | ||
106 | self->netdev->name); | ||
107 | dev_kfree_skb(skb); | ||
108 | return; | ||
109 | } | ||
110 | |||
104 | dev_queue_xmit(skb); | 111 | dev_queue_xmit(skb); |
105 | } | 112 | } |
106 | 113 | ||
diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c index 9df0461b6d..7efa930ed6 100644 --- a/net/irda/irlmp.c +++ b/net/irda/irlmp.c | |||
@@ -116,7 +116,7 @@ int __init irlmp_init(void) | |||
116 | * Remove IrLMP layer | 116 | * Remove IrLMP layer |
117 | * | 117 | * |
118 | */ | 118 | */ |
119 | void __exit irlmp_cleanup(void) | 119 | void irlmp_cleanup(void) |
120 | { | 120 | { |
121 | /* Check for main structure */ | 121 | /* Check for main structure */ |
122 | IRDA_ASSERT(irlmp != NULL, return;); | 122 | IRDA_ASSERT(irlmp != NULL, return;); |
@@ -1994,7 +1994,7 @@ static int irlmp_seq_show(struct seq_file *seq, void *v) | |||
1994 | return 0; | 1994 | return 0; |
1995 | } | 1995 | } |
1996 | 1996 | ||
1997 | static struct seq_operations irlmp_seq_ops = { | 1997 | static const struct seq_operations irlmp_seq_ops = { |
1998 | .start = irlmp_seq_start, | 1998 | .start = irlmp_seq_start, |
1999 | .next = irlmp_seq_next, | 1999 | .next = irlmp_seq_next, |
2000 | .stop = irlmp_seq_stop, | 2000 | .stop = irlmp_seq_stop, |
diff --git a/net/irda/irmod.c b/net/irda/irmod.c index c7fad2c5b9..1900937b33 100644 --- a/net/irda/irmod.c +++ b/net/irda/irmod.c | |||
@@ -88,16 +88,23 @@ EXPORT_SYMBOL(irda_notify_init); | |||
88 | */ | 88 | */ |
89 | static int __init irda_init(void) | 89 | static int __init irda_init(void) |
90 | { | 90 | { |
91 | int ret = 0; | ||
92 | |||
91 | IRDA_DEBUG(0, "%s()\n", __FUNCTION__); | 93 | IRDA_DEBUG(0, "%s()\n", __FUNCTION__); |
92 | 94 | ||
93 | /* Lower layer of the stack */ | 95 | /* Lower layer of the stack */ |
94 | irlmp_init(); | 96 | irlmp_init(); |
95 | irlap_init(); | 97 | irlap_init(); |
96 | 98 | ||
99 | /* Driver/dongle support */ | ||
100 | irda_device_init(); | ||
101 | |||
97 | /* Higher layers of the stack */ | 102 | /* Higher layers of the stack */ |
98 | iriap_init(); | 103 | iriap_init(); |
99 | irttp_init(); | 104 | irttp_init(); |
100 | irsock_init(); | 105 | ret = irsock_init(); |
106 | if (ret < 0) | ||
107 | goto out_err_1; | ||
101 | 108 | ||
102 | /* Add IrDA packet type (Start receiving packets) */ | 109 | /* Add IrDA packet type (Start receiving packets) */ |
103 | dev_add_pack(&irda_packet_type); | 110 | dev_add_pack(&irda_packet_type); |
@@ -107,13 +114,44 @@ static int __init irda_init(void) | |||
107 | irda_proc_register(); | 114 | irda_proc_register(); |
108 | #endif | 115 | #endif |
109 | #ifdef CONFIG_SYSCTL | 116 | #ifdef CONFIG_SYSCTL |
110 | irda_sysctl_register(); | 117 | ret = irda_sysctl_register(); |
118 | if (ret < 0) | ||
119 | goto out_err_2; | ||
111 | #endif | 120 | #endif |
112 | 121 | ||
113 | /* Driver/dongle support */ | 122 | ret = irda_nl_register(); |
114 | irda_device_init(); | 123 | if (ret < 0) |
124 | goto out_err_3; | ||
115 | 125 | ||
116 | return 0; | 126 | return 0; |
127 | |||
128 | out_err_3: | ||
129 | #ifdef CONFIG_SYSCTL | ||
130 | irda_sysctl_unregister(); | ||
131 | #endif | ||
132 | out_err_2: | ||
133 | #ifdef CONFIG_PROC_FS | ||
134 | irda_proc_unregister(); | ||
135 | #endif | ||
136 | |||
137 | /* Remove IrDA packet type (stop receiving packets) */ | ||
138 | dev_remove_pack(&irda_packet_type); | ||
139 | |||
140 | /* Remove higher layers */ | ||
141 | irsock_cleanup(); | ||
142 | out_err_1: | ||
143 | irttp_cleanup(); | ||
144 | iriap_cleanup(); | ||
145 | |||
146 | /* Remove lower layers */ | ||
147 | irda_device_cleanup(); | ||
148 | irlap_cleanup(); /* Must be done before irlmp_cleanup()! DB */ | ||
149 | |||
150 | /* Remove middle layer */ | ||
151 | irlmp_cleanup(); | ||
152 | |||
153 | |||
154 | return ret; | ||
117 | } | 155 | } |
118 | 156 | ||
119 | /* | 157 | /* |
@@ -125,6 +163,8 @@ static int __init irda_init(void) | |||
125 | static void __exit irda_cleanup(void) | 163 | static void __exit irda_cleanup(void) |
126 | { | 164 | { |
127 | /* Remove External APIs */ | 165 | /* Remove External APIs */ |
166 | irda_nl_unregister(); | ||
167 | |||
128 | #ifdef CONFIG_SYSCTL | 168 | #ifdef CONFIG_SYSCTL |
129 | irda_sysctl_unregister(); | 169 | irda_sysctl_unregister(); |
130 | #endif | 170 | #endif |
diff --git a/net/irda/irnetlink.c b/net/irda/irnetlink.c new file mode 100644 index 0000000000..694ea4d92f --- /dev/null +++ b/net/irda/irnetlink.c | |||
@@ -0,0 +1,170 @@ | |||
1 | /* | ||
2 | * IrDA netlink layer, for stack configuration. | ||
3 | * | ||
4 | * Copyright (c) 2007 Samuel Ortiz <samuel@sortiz.org> | ||
5 | * | ||
6 | * Partly based on the 802.11 nelink implementation | ||
7 | * (see net/wireless/nl80211.c) which is: | ||
8 | * Copyright 2006 Johannes Berg <johannes@sipsolutions.net> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | #include <linux/socket.h> | ||
17 | #include <linux/irda.h> | ||
18 | #include <net/sock.h> | ||
19 | #include <net/irda/irda.h> | ||
20 | #include <net/irda/irlap.h> | ||
21 | #include <net/genetlink.h> | ||
22 | |||
23 | |||
24 | |||
25 | static struct genl_family irda_nl_family = { | ||
26 | .id = GENL_ID_GENERATE, | ||
27 | .name = IRDA_NL_NAME, | ||
28 | .hdrsize = 0, | ||
29 | .version = IRDA_NL_VERSION, | ||
30 | .maxattr = IRDA_NL_CMD_MAX, | ||
31 | }; | ||
32 | |||
33 | static struct net_device * ifname_to_netdev(struct genl_info *info) | ||
34 | { | ||
35 | char * ifname; | ||
36 | |||
37 | if (!info->attrs[IRDA_NL_ATTR_IFNAME]) | ||
38 | return NULL; | ||
39 | |||
40 | ifname = nla_data(info->attrs[IRDA_NL_ATTR_IFNAME]); | ||
41 | |||
42 | IRDA_DEBUG(5, "%s(): Looking for %s\n", __FUNCTION__, ifname); | ||
43 | |||
44 | return dev_get_by_name(ifname); | ||
45 | } | ||
46 | |||
47 | static int irda_nl_set_mode(struct sk_buff *skb, struct genl_info *info) | ||
48 | { | ||
49 | struct net_device * dev; | ||
50 | struct irlap_cb * irlap; | ||
51 | u32 mode; | ||
52 | |||
53 | if (!info->attrs[IRDA_NL_ATTR_MODE]) | ||
54 | return -EINVAL; | ||
55 | |||
56 | mode = nla_get_u32(info->attrs[IRDA_NL_ATTR_MODE]); | ||
57 | |||
58 | IRDA_DEBUG(5, "%s(): Switching to mode: %d\n", __FUNCTION__, mode); | ||
59 | |||
60 | dev = ifname_to_netdev(info); | ||
61 | if (!dev) | ||
62 | return -ENODEV; | ||
63 | |||
64 | irlap = (struct irlap_cb *)dev->atalk_ptr; | ||
65 | if (!irlap) { | ||
66 | dev_put(dev); | ||
67 | return -ENODEV; | ||
68 | } | ||
69 | |||
70 | irlap->mode = mode; | ||
71 | |||
72 | dev_put(dev); | ||
73 | |||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | static int irda_nl_get_mode(struct sk_buff *skb, struct genl_info *info) | ||
78 | { | ||
79 | struct net_device * dev; | ||
80 | struct irlap_cb * irlap; | ||
81 | struct sk_buff *msg; | ||
82 | void *hdr; | ||
83 | int ret = -ENOBUFS; | ||
84 | |||
85 | dev = ifname_to_netdev(info); | ||
86 | if (!dev) | ||
87 | return -ENODEV; | ||
88 | |||
89 | msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); | ||
90 | if (!msg) { | ||
91 | dev_put(dev); | ||
92 | return -ENOMEM; | ||
93 | } | ||
94 | |||
95 | irlap = (struct irlap_cb *)dev->atalk_ptr; | ||
96 | if (!irlap) { | ||
97 | ret = -ENODEV; | ||
98 | goto err_out; | ||
99 | } | ||
100 | |||
101 | hdr = genlmsg_put(msg, info->snd_pid, info->snd_seq, | ||
102 | &irda_nl_family, 0, IRDA_NL_CMD_GET_MODE); | ||
103 | if (IS_ERR(hdr)) { | ||
104 | ret = PTR_ERR(hdr); | ||
105 | goto err_out; | ||
106 | } | ||
107 | |||
108 | if(nla_put_string(msg, IRDA_NL_ATTR_IFNAME, | ||
109 | dev->name)); | ||
110 | goto err_out; | ||
111 | |||
112 | if(nla_put_u32(msg, IRDA_NL_ATTR_MODE, irlap->mode)) | ||
113 | goto err_out; | ||
114 | |||
115 | genlmsg_end(msg, hdr); | ||
116 | |||
117 | return genlmsg_unicast(msg, info->snd_pid); | ||
118 | |||
119 | err_out: | ||
120 | nlmsg_free(msg); | ||
121 | dev_put(dev); | ||
122 | |||
123 | return ret; | ||
124 | } | ||
125 | |||
126 | static struct nla_policy irda_nl_policy[IRDA_NL_ATTR_MAX + 1] = { | ||
127 | [IRDA_NL_ATTR_IFNAME] = { .type = NLA_NUL_STRING, | ||
128 | .len = IFNAMSIZ-1 }, | ||
129 | [IRDA_NL_ATTR_MODE] = { .type = NLA_U32 }, | ||
130 | }; | ||
131 | |||
132 | static struct genl_ops irda_nl_ops[] = { | ||
133 | { | ||
134 | .cmd = IRDA_NL_CMD_SET_MODE, | ||
135 | .doit = irda_nl_set_mode, | ||
136 | .policy = irda_nl_policy, | ||
137 | .flags = GENL_ADMIN_PERM, | ||
138 | }, | ||
139 | { | ||
140 | .cmd = IRDA_NL_CMD_GET_MODE, | ||
141 | .doit = irda_nl_get_mode, | ||
142 | .policy = irda_nl_policy, | ||
143 | /* can be retrieved by unprivileged users */ | ||
144 | }, | ||
145 | |||
146 | }; | ||
147 | |||
148 | int irda_nl_register(void) | ||
149 | { | ||
150 | int err, i; | ||
151 | |||
152 | err = genl_register_family(&irda_nl_family); | ||
153 | if (err) | ||
154 | return err; | ||
155 | |||
156 | for (i = 0; i < ARRAY_SIZE(irda_nl_ops); i++) { | ||
157 | err = genl_register_ops(&irda_nl_family, &irda_nl_ops[i]); | ||
158 | if (err) | ||
159 | goto err_out; | ||
160 | } | ||
161 | return 0; | ||
162 | err_out: | ||
163 | genl_unregister_family(&irda_nl_family); | ||
164 | return err; | ||
165 | } | ||
166 | |||
167 | void irda_nl_unregister(void) | ||
168 | { | ||
169 | genl_unregister_family(&irda_nl_family); | ||
170 | } | ||
diff --git a/net/irda/irproc.c b/net/irda/irproc.c index d6f9aba5b9..181cb51b48 100644 --- a/net/irda/irproc.c +++ b/net/irda/irproc.c | |||
@@ -84,7 +84,7 @@ void __init irda_proc_register(void) | |||
84 | * Unregister irda entry in /proc file system | 84 | * Unregister irda entry in /proc file system |
85 | * | 85 | * |
86 | */ | 86 | */ |
87 | void __exit irda_proc_unregister(void) | 87 | void irda_proc_unregister(void) |
88 | { | 88 | { |
89 | int i; | 89 | int i; |
90 | 90 | ||
diff --git a/net/irda/irsysctl.c b/net/irda/irsysctl.c index 2e968e7d8f..957e04feb0 100644 --- a/net/irda/irsysctl.c +++ b/net/irda/irsysctl.c | |||
@@ -287,7 +287,7 @@ int __init irda_sysctl_register(void) | |||
287 | * Unregister our sysctl interface | 287 | * Unregister our sysctl interface |
288 | * | 288 | * |
289 | */ | 289 | */ |
290 | void __exit irda_sysctl_unregister(void) | 290 | void irda_sysctl_unregister(void) |
291 | { | 291 | { |
292 | unregister_sysctl_table(irda_table_header); | 292 | unregister_sysctl_table(irda_table_header); |
293 | } | 293 | } |
diff --git a/net/irda/irttp.c b/net/irda/irttp.c index 7069e4a582..3d7ab03fb1 100644 --- a/net/irda/irttp.c +++ b/net/irda/irttp.c | |||
@@ -109,7 +109,7 @@ int __init irttp_init(void) | |||
109 | * Called by module destruction/cleanup code | 109 | * Called by module destruction/cleanup code |
110 | * | 110 | * |
111 | */ | 111 | */ |
112 | void __exit irttp_cleanup(void) | 112 | void irttp_cleanup(void) |
113 | { | 113 | { |
114 | /* Check for main structure */ | 114 | /* Check for main structure */ |
115 | IRDA_ASSERT(irttp->magic == TTP_MAGIC, return;); | 115 | IRDA_ASSERT(irttp->magic == TTP_MAGIC, return;); |
@@ -369,6 +369,20 @@ static int irttp_param_max_sdu_size(void *instance, irda_param_t *param, | |||
369 | /* Everything is happily mixed up. Waiting for next clean up - Jean II */ | 369 | /* Everything is happily mixed up. Waiting for next clean up - Jean II */ |
370 | 370 | ||
371 | /* | 371 | /* |
372 | * Initialization, that has to be done on new tsap | ||
373 | * instance allocation and on duplication | ||
374 | */ | ||
375 | static void irttp_init_tsap(struct tsap_cb *tsap) | ||
376 | { | ||
377 | spin_lock_init(&tsap->lock); | ||
378 | init_timer(&tsap->todo_timer); | ||
379 | |||
380 | skb_queue_head_init(&tsap->rx_queue); | ||
381 | skb_queue_head_init(&tsap->tx_queue); | ||
382 | skb_queue_head_init(&tsap->rx_fragments); | ||
383 | } | ||
384 | |||
385 | /* | ||
372 | * Function irttp_open_tsap (stsap, notify) | 386 | * Function irttp_open_tsap (stsap, notify) |
373 | * | 387 | * |
374 | * Create TSAP connection endpoint, | 388 | * Create TSAP connection endpoint, |
@@ -395,10 +409,11 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify) | |||
395 | IRDA_DEBUG(0, "%s(), unable to kmalloc!\n", __FUNCTION__); | 409 | IRDA_DEBUG(0, "%s(), unable to kmalloc!\n", __FUNCTION__); |
396 | return NULL; | 410 | return NULL; |
397 | } | 411 | } |
398 | spin_lock_init(&self->lock); | 412 | |
413 | /* Initialize internal objects */ | ||
414 | irttp_init_tsap(self); | ||
399 | 415 | ||
400 | /* Initialise todo timer */ | 416 | /* Initialise todo timer */ |
401 | init_timer(&self->todo_timer); | ||
402 | self->todo_timer.data = (unsigned long) self; | 417 | self->todo_timer.data = (unsigned long) self; |
403 | self->todo_timer.function = &irttp_todo_expired; | 418 | self->todo_timer.function = &irttp_todo_expired; |
404 | 419 | ||
@@ -418,9 +433,6 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify) | |||
418 | self->magic = TTP_TSAP_MAGIC; | 433 | self->magic = TTP_TSAP_MAGIC; |
419 | self->connected = FALSE; | 434 | self->connected = FALSE; |
420 | 435 | ||
421 | skb_queue_head_init(&self->rx_queue); | ||
422 | skb_queue_head_init(&self->tx_queue); | ||
423 | skb_queue_head_init(&self->rx_fragments); | ||
424 | /* | 436 | /* |
425 | * Create LSAP at IrLMP layer | 437 | * Create LSAP at IrLMP layer |
426 | */ | 438 | */ |
@@ -1455,12 +1467,9 @@ struct tsap_cb *irttp_dup(struct tsap_cb *orig, void *instance) | |||
1455 | 1467 | ||
1456 | /* Not everything should be copied */ | 1468 | /* Not everything should be copied */ |
1457 | new->notify.instance = instance; | 1469 | new->notify.instance = instance; |
1458 | spin_lock_init(&new->lock); | ||
1459 | init_timer(&new->todo_timer); | ||
1460 | 1470 | ||
1461 | skb_queue_head_init(&new->rx_queue); | 1471 | /* Initialize internal objects */ |
1462 | skb_queue_head_init(&new->tx_queue); | 1472 | irttp_init_tsap(new); |
1463 | skb_queue_head_init(&new->rx_fragments); | ||
1464 | 1473 | ||
1465 | /* This is locked */ | 1474 | /* This is locked */ |
1466 | hashbin_insert(irttp->tsaps, (irda_queue_t *) new, (long) new, NULL); | 1475 | hashbin_insert(irttp->tsaps, (irda_queue_t *) new, (long) new, NULL); |
@@ -1866,7 +1875,7 @@ static int irttp_seq_show(struct seq_file *seq, void *v) | |||
1866 | return 0; | 1875 | return 0; |
1867 | } | 1876 | } |
1868 | 1877 | ||
1869 | static struct seq_operations irttp_seq_ops = { | 1878 | static const struct seq_operations irttp_seq_ops = { |
1870 | .start = irttp_seq_start, | 1879 | .start = irttp_seq_start, |
1871 | .next = irttp_seq_next, | 1880 | .next = irttp_seq_next, |
1872 | .stop = irttp_seq_stop, | 1881 | .stop = irttp_seq_stop, |