diff options
author | Joe Perches <joe@perches.com> | 2010-01-26 06:40:17 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-01-27 00:16:04 -0500 |
commit | 0ec96e656fcd4a8ea8cb0e92f90ab4bb6f79cada (patch) | |
tree | 055222355c8f48010720c7a1ebd52c951f2f3ed5 /net/atm/signaling.c | |
parent | 07b54c9ad4804bdd546d3db0889b0db381c726e3 (diff) |
net/atm/signaling.c: checkpatch cleanups
Mostly 80 column wrapped.
Move embedded assigns out of tests
Move trailing statements to new lines
switch/case cleanups
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/atm/signaling.c')
-rw-r--r-- | net/atm/signaling.c | 202 |
1 files changed, 101 insertions, 101 deletions
diff --git a/net/atm/signaling.c b/net/atm/signaling.c index 28df4edf9ca4..ad1d28ae512b 100644 --- a/net/atm/signaling.c +++ b/net/atm/signaling.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include "resources.h" | 18 | #include "resources.h" |
19 | #include "signaling.h" | 19 | #include "signaling.h" |
20 | 20 | ||
21 | |||
22 | #undef WAIT_FOR_DEMON /* #define this if system calls on SVC sockets | 21 | #undef WAIT_FOR_DEMON /* #define this if system calls on SVC sockets |
23 | should block until the demon runs. | 22 | should block until the demon runs. |
24 | Danger: may cause nasty hangs if the demon | 23 | Danger: may cause nasty hangs if the demon |
@@ -29,20 +28,19 @@ struct atm_vcc *sigd = NULL; | |||
29 | static DECLARE_WAIT_QUEUE_HEAD(sigd_sleep); | 28 | static DECLARE_WAIT_QUEUE_HEAD(sigd_sleep); |
30 | #endif | 29 | #endif |
31 | 30 | ||
32 | |||
33 | static void sigd_put_skb(struct sk_buff *skb) | 31 | static void sigd_put_skb(struct sk_buff *skb) |
34 | { | 32 | { |
35 | #ifdef WAIT_FOR_DEMON | 33 | #ifdef WAIT_FOR_DEMON |
36 | DECLARE_WAITQUEUE(wait,current); | 34 | DECLARE_WAITQUEUE(wait, current); |
37 | 35 | ||
38 | add_wait_queue(&sigd_sleep,&wait); | 36 | add_wait_queue(&sigd_sleep, &wait); |
39 | while (!sigd) { | 37 | while (!sigd) { |
40 | set_current_state(TASK_UNINTERRUPTIBLE); | 38 | set_current_state(TASK_UNINTERRUPTIBLE); |
41 | pr_debug("atmsvc: waiting for signaling daemon...\n"); | 39 | pr_debug("atmsvc: waiting for signaling daemon...\n"); |
42 | schedule(); | 40 | schedule(); |
43 | } | 41 | } |
44 | current->state = TASK_RUNNING; | 42 | current->state = TASK_RUNNING; |
45 | remove_wait_queue(&sigd_sleep,&wait); | 43 | remove_wait_queue(&sigd_sleep, &wait); |
46 | #else | 44 | #else |
47 | if (!sigd) { | 45 | if (!sigd) { |
48 | pr_debug("atmsvc: no signaling daemon\n"); | 46 | pr_debug("atmsvc: no signaling daemon\n"); |
@@ -50,39 +48,39 @@ static void sigd_put_skb(struct sk_buff *skb) | |||
50 | return; | 48 | return; |
51 | } | 49 | } |
52 | #endif | 50 | #endif |
53 | atm_force_charge(sigd,skb->truesize); | 51 | atm_force_charge(sigd, skb->truesize); |
54 | skb_queue_tail(&sk_atm(sigd)->sk_receive_queue,skb); | 52 | skb_queue_tail(&sk_atm(sigd)->sk_receive_queue, skb); |
55 | sk_atm(sigd)->sk_data_ready(sk_atm(sigd), skb->len); | 53 | sk_atm(sigd)->sk_data_ready(sk_atm(sigd), skb->len); |
56 | } | 54 | } |
57 | 55 | ||
58 | 56 | static void modify_qos(struct atm_vcc *vcc, struct atmsvc_msg *msg) | |
59 | static void modify_qos(struct atm_vcc *vcc,struct atmsvc_msg *msg) | ||
60 | { | 57 | { |
61 | struct sk_buff *skb; | 58 | struct sk_buff *skb; |
62 | 59 | ||
63 | if (test_bit(ATM_VF_RELEASED,&vcc->flags) || | 60 | if (test_bit(ATM_VF_RELEASED, &vcc->flags) || |
64 | !test_bit(ATM_VF_READY,&vcc->flags)) | 61 | !test_bit(ATM_VF_READY, &vcc->flags)) |
65 | return; | 62 | return; |
66 | msg->type = as_error; | 63 | msg->type = as_error; |
67 | if (!vcc->dev->ops->change_qos) msg->reply = -EOPNOTSUPP; | 64 | if (!vcc->dev->ops->change_qos) |
65 | msg->reply = -EOPNOTSUPP; | ||
68 | else { | 66 | else { |
69 | /* should lock VCC */ | 67 | /* should lock VCC */ |
70 | msg->reply = vcc->dev->ops->change_qos(vcc,&msg->qos, | 68 | msg->reply = vcc->dev->ops->change_qos(vcc, &msg->qos, |
71 | msg->reply); | 69 | msg->reply); |
72 | if (!msg->reply) msg->type = as_okay; | 70 | if (!msg->reply) |
71 | msg->type = as_okay; | ||
73 | } | 72 | } |
74 | /* | 73 | /* |
75 | * Should probably just turn around the old skb. But the, the buffer | 74 | * Should probably just turn around the old skb. But the, the buffer |
76 | * space accounting needs to follow the change too. Maybe later. | 75 | * space accounting needs to follow the change too. Maybe later. |
77 | */ | 76 | */ |
78 | while (!(skb = alloc_skb(sizeof(struct atmsvc_msg),GFP_KERNEL))) | 77 | while (!(skb = alloc_skb(sizeof(struct atmsvc_msg), GFP_KERNEL))) |
79 | schedule(); | 78 | schedule(); |
80 | *(struct atmsvc_msg *) skb_put(skb,sizeof(struct atmsvc_msg)) = *msg; | 79 | *(struct atmsvc_msg *)skb_put(skb, sizeof(struct atmsvc_msg)) = *msg; |
81 | sigd_put_skb(skb); | 80 | sigd_put_skb(skb); |
82 | } | 81 | } |
83 | 82 | ||
84 | 83 | static int sigd_send(struct atm_vcc *vcc, struct sk_buff *skb) | |
85 | static int sigd_send(struct atm_vcc *vcc,struct sk_buff *skb) | ||
86 | { | 84 | { |
87 | struct atmsvc_msg *msg; | 85 | struct atmsvc_msg *msg; |
88 | struct atm_vcc *session_vcc; | 86 | struct atm_vcc *session_vcc; |
@@ -95,63 +93,64 @@ static int sigd_send(struct atm_vcc *vcc,struct sk_buff *skb) | |||
95 | sk = sk_atm(vcc); | 93 | sk = sk_atm(vcc); |
96 | 94 | ||
97 | switch (msg->type) { | 95 | switch (msg->type) { |
98 | case as_okay: | 96 | case as_okay: |
99 | sk->sk_err = -msg->reply; | 97 | sk->sk_err = -msg->reply; |
100 | clear_bit(ATM_VF_WAITING, &vcc->flags); | 98 | clear_bit(ATM_VF_WAITING, &vcc->flags); |
101 | if (!*vcc->local.sas_addr.prv && | 99 | if (!*vcc->local.sas_addr.prv && !*vcc->local.sas_addr.pub) { |
102 | !*vcc->local.sas_addr.pub) { | 100 | vcc->local.sas_family = AF_ATMSVC; |
103 | vcc->local.sas_family = AF_ATMSVC; | 101 | memcpy(vcc->local.sas_addr.prv, |
104 | memcpy(vcc->local.sas_addr.prv, | 102 | msg->local.sas_addr.prv, ATM_ESA_LEN); |
105 | msg->local.sas_addr.prv,ATM_ESA_LEN); | 103 | memcpy(vcc->local.sas_addr.pub, |
106 | memcpy(vcc->local.sas_addr.pub, | 104 | msg->local.sas_addr.pub, ATM_E164_LEN + 1); |
107 | msg->local.sas_addr.pub,ATM_E164_LEN+1); | 105 | } |
108 | } | 106 | session_vcc = vcc->session ? vcc->session : vcc; |
109 | session_vcc = vcc->session ? vcc->session : vcc; | 107 | if (session_vcc->vpi || session_vcc->vci) |
110 | if (session_vcc->vpi || session_vcc->vci) break; | ||
111 | session_vcc->itf = msg->pvc.sap_addr.itf; | ||
112 | session_vcc->vpi = msg->pvc.sap_addr.vpi; | ||
113 | session_vcc->vci = msg->pvc.sap_addr.vci; | ||
114 | if (session_vcc->vpi || session_vcc->vci) | ||
115 | session_vcc->qos = msg->qos; | ||
116 | break; | ||
117 | case as_error: | ||
118 | clear_bit(ATM_VF_REGIS,&vcc->flags); | ||
119 | clear_bit(ATM_VF_READY,&vcc->flags); | ||
120 | sk->sk_err = -msg->reply; | ||
121 | clear_bit(ATM_VF_WAITING, &vcc->flags); | ||
122 | break; | 108 | break; |
123 | case as_indicate: | 109 | session_vcc->itf = msg->pvc.sap_addr.itf; |
124 | vcc = *(struct atm_vcc **) &msg->listen_vcc; | 110 | session_vcc->vpi = msg->pvc.sap_addr.vpi; |
125 | sk = sk_atm(vcc); | 111 | session_vcc->vci = msg->pvc.sap_addr.vci; |
126 | pr_debug("as_indicate!!!\n"); | 112 | if (session_vcc->vpi || session_vcc->vci) |
127 | lock_sock(sk); | 113 | session_vcc->qos = msg->qos; |
128 | if (sk_acceptq_is_full(sk)) { | 114 | break; |
129 | sigd_enq(NULL,as_reject,vcc,NULL,NULL); | 115 | case as_error: |
130 | dev_kfree_skb(skb); | 116 | clear_bit(ATM_VF_REGIS, &vcc->flags); |
131 | goto as_indicate_complete; | 117 | clear_bit(ATM_VF_READY, &vcc->flags); |
132 | } | 118 | sk->sk_err = -msg->reply; |
133 | sk->sk_ack_backlog++; | 119 | clear_bit(ATM_VF_WAITING, &vcc->flags); |
134 | skb_queue_tail(&sk->sk_receive_queue, skb); | 120 | break; |
135 | pr_debug("waking sk->sk_sleep 0x%p\n", sk->sk_sleep); | 121 | case as_indicate: |
136 | sk->sk_state_change(sk); | 122 | vcc = *(struct atm_vcc **)&msg->listen_vcc; |
123 | sk = sk_atm(vcc); | ||
124 | pr_debug("as_indicate!!!\n"); | ||
125 | lock_sock(sk); | ||
126 | if (sk_acceptq_is_full(sk)) { | ||
127 | sigd_enq(NULL, as_reject, vcc, NULL, NULL); | ||
128 | dev_kfree_skb(skb); | ||
129 | goto as_indicate_complete; | ||
130 | } | ||
131 | sk->sk_ack_backlog++; | ||
132 | skb_queue_tail(&sk->sk_receive_queue, skb); | ||
133 | pr_debug("waking sk->sk_sleep 0x%p\n", sk->sk_sleep); | ||
134 | sk->sk_state_change(sk); | ||
137 | as_indicate_complete: | 135 | as_indicate_complete: |
138 | release_sock(sk); | 136 | release_sock(sk); |
139 | return 0; | 137 | return 0; |
140 | case as_close: | 138 | case as_close: |
141 | set_bit(ATM_VF_RELEASED,&vcc->flags); | 139 | set_bit(ATM_VF_RELEASED, &vcc->flags); |
142 | vcc_release_async(vcc, msg->reply); | 140 | vcc_release_async(vcc, msg->reply); |
143 | goto out; | 141 | goto out; |
144 | case as_modify: | 142 | case as_modify: |
145 | modify_qos(vcc,msg); | 143 | modify_qos(vcc, msg); |
146 | break; | 144 | break; |
147 | case as_addparty: | 145 | case as_addparty: |
148 | case as_dropparty: | 146 | case as_dropparty: |
149 | sk->sk_err_soft = msg->reply; /* < 0 failure, otherwise ep_ref */ | 147 | sk->sk_err_soft = msg->reply; |
150 | clear_bit(ATM_VF_WAITING, &vcc->flags); | 148 | /* < 0 failure, otherwise ep_ref */ |
151 | break; | 149 | clear_bit(ATM_VF_WAITING, &vcc->flags); |
152 | default: | 150 | break; |
153 | pr_alert("bad message type %d\n", (int)msg->type); | 151 | default: |
154 | return -EINVAL; | 152 | pr_alert("bad message type %d\n", (int)msg->type); |
153 | return -EINVAL; | ||
155 | } | 154 | } |
156 | sk->sk_state_change(sk); | 155 | sk->sk_state_change(sk); |
157 | out: | 156 | out: |
@@ -159,48 +158,52 @@ out: | |||
159 | return 0; | 158 | return 0; |
160 | } | 159 | } |
161 | 160 | ||
162 | 161 | void sigd_enq2(struct atm_vcc *vcc, enum atmsvc_msg_type type, | |
163 | void sigd_enq2(struct atm_vcc *vcc,enum atmsvc_msg_type type, | 162 | struct atm_vcc *listen_vcc, const struct sockaddr_atmpvc *pvc, |
164 | struct atm_vcc *listen_vcc,const struct sockaddr_atmpvc *pvc, | 163 | const struct sockaddr_atmsvc *svc, const struct atm_qos *qos, |
165 | const struct sockaddr_atmsvc *svc,const struct atm_qos *qos,int reply) | 164 | int reply) |
166 | { | 165 | { |
167 | struct sk_buff *skb; | 166 | struct sk_buff *skb; |
168 | struct atmsvc_msg *msg; | 167 | struct atmsvc_msg *msg; |
169 | static unsigned session = 0; | 168 | static unsigned session = 0; |
170 | 169 | ||
171 | pr_debug("%d (0x%p)\n", (int)type, vcc); | 170 | pr_debug("%d (0x%p)\n", (int)type, vcc); |
172 | while (!(skb = alloc_skb(sizeof(struct atmsvc_msg),GFP_KERNEL))) | 171 | while (!(skb = alloc_skb(sizeof(struct atmsvc_msg), GFP_KERNEL))) |
173 | schedule(); | 172 | schedule(); |
174 | msg = (struct atmsvc_msg *) skb_put(skb,sizeof(struct atmsvc_msg)); | 173 | msg = (struct atmsvc_msg *)skb_put(skb, sizeof(struct atmsvc_msg)); |
175 | memset(msg,0,sizeof(*msg)); | 174 | memset(msg, 0, sizeof(*msg)); |
176 | msg->type = type; | 175 | msg->type = type; |
177 | *(struct atm_vcc **) &msg->vcc = vcc; | 176 | *(struct atm_vcc **) &msg->vcc = vcc; |
178 | *(struct atm_vcc **) &msg->listen_vcc = listen_vcc; | 177 | *(struct atm_vcc **) &msg->listen_vcc = listen_vcc; |
179 | msg->reply = reply; | 178 | msg->reply = reply; |
180 | if (qos) msg->qos = *qos; | 179 | if (qos) |
181 | if (vcc) msg->sap = vcc->sap; | 180 | msg->qos = *qos; |
182 | if (svc) msg->svc = *svc; | 181 | if (vcc) |
183 | if (vcc) msg->local = vcc->local; | 182 | msg->sap = vcc->sap; |
184 | if (pvc) msg->pvc = *pvc; | 183 | if (svc) |
184 | msg->svc = *svc; | ||
185 | if (vcc) | ||
186 | msg->local = vcc->local; | ||
187 | if (pvc) | ||
188 | msg->pvc = *pvc; | ||
185 | if (vcc) { | 189 | if (vcc) { |
186 | if (type == as_connect && test_bit(ATM_VF_SESSION, &vcc->flags)) | 190 | if (type == as_connect && test_bit(ATM_VF_SESSION, &vcc->flags)) |
187 | msg->session = ++session; | 191 | msg->session = ++session; |
188 | /* every new pmp connect gets the next session number */ | 192 | /* every new pmp connect gets the next session number */ |
189 | } | 193 | } |
190 | sigd_put_skb(skb); | 194 | sigd_put_skb(skb); |
191 | if (vcc) set_bit(ATM_VF_REGIS,&vcc->flags); | 195 | if (vcc) |
196 | set_bit(ATM_VF_REGIS, &vcc->flags); | ||
192 | } | 197 | } |
193 | 198 | ||
194 | 199 | void sigd_enq(struct atm_vcc *vcc, enum atmsvc_msg_type type, | |
195 | void sigd_enq(struct atm_vcc *vcc,enum atmsvc_msg_type type, | 200 | struct atm_vcc *listen_vcc, const struct sockaddr_atmpvc *pvc, |
196 | struct atm_vcc *listen_vcc,const struct sockaddr_atmpvc *pvc, | 201 | const struct sockaddr_atmsvc *svc) |
197 | const struct sockaddr_atmsvc *svc) | ||
198 | { | 202 | { |
199 | sigd_enq2(vcc,type,listen_vcc,pvc,svc,vcc ? &vcc->qos : NULL,0); | 203 | sigd_enq2(vcc, type, listen_vcc, pvc, svc, vcc ? &vcc->qos : NULL, 0); |
200 | /* other ISP applications may use "reply" */ | 204 | /* other ISP applications may use "reply" */ |
201 | } | 205 | } |
202 | 206 | ||
203 | |||
204 | static void purge_vcc(struct atm_vcc *vcc) | 207 | static void purge_vcc(struct atm_vcc *vcc) |
205 | { | 208 | { |
206 | if (sk_atm(vcc)->sk_family == PF_ATMSVC && | 209 | if (sk_atm(vcc)->sk_family == PF_ATMSVC && |
@@ -211,7 +214,6 @@ static void purge_vcc(struct atm_vcc *vcc) | |||
211 | } | 214 | } |
212 | } | 215 | } |
213 | 216 | ||
214 | |||
215 | static void sigd_close(struct atm_vcc *vcc) | 217 | static void sigd_close(struct atm_vcc *vcc) |
216 | { | 218 | { |
217 | struct hlist_node *node; | 219 | struct hlist_node *node; |
@@ -225,7 +227,7 @@ static void sigd_close(struct atm_vcc *vcc) | |||
225 | skb_queue_purge(&sk_atm(vcc)->sk_receive_queue); | 227 | skb_queue_purge(&sk_atm(vcc)->sk_receive_queue); |
226 | 228 | ||
227 | read_lock(&vcc_sklist_lock); | 229 | read_lock(&vcc_sklist_lock); |
228 | for(i = 0; i < VCC_HTABLE_SIZE; ++i) { | 230 | for (i = 0; i < VCC_HTABLE_SIZE; ++i) { |
229 | struct hlist_head *head = &vcc_hash[i]; | 231 | struct hlist_head *head = &vcc_hash[i]; |
230 | 232 | ||
231 | sk_for_each(s, node, head) { | 233 | sk_for_each(s, node, head) { |
@@ -237,13 +239,11 @@ static void sigd_close(struct atm_vcc *vcc) | |||
237 | read_unlock(&vcc_sklist_lock); | 239 | read_unlock(&vcc_sklist_lock); |
238 | } | 240 | } |
239 | 241 | ||
240 | |||
241 | static struct atmdev_ops sigd_dev_ops = { | 242 | static struct atmdev_ops sigd_dev_ops = { |
242 | .close = sigd_close, | 243 | .close = sigd_close, |
243 | .send = sigd_send | 244 | .send = sigd_send |
244 | }; | 245 | }; |
245 | 246 | ||
246 | |||
247 | static struct atm_dev sigd_dev = { | 247 | static struct atm_dev sigd_dev = { |
248 | .ops = &sigd_dev_ops, | 248 | .ops = &sigd_dev_ops, |
249 | .type = "sig", | 249 | .type = "sig", |
@@ -251,16 +251,16 @@ static struct atm_dev sigd_dev = { | |||
251 | .lock = __SPIN_LOCK_UNLOCKED(sigd_dev.lock) | 251 | .lock = __SPIN_LOCK_UNLOCKED(sigd_dev.lock) |
252 | }; | 252 | }; |
253 | 253 | ||
254 | |||
255 | int sigd_attach(struct atm_vcc *vcc) | 254 | int sigd_attach(struct atm_vcc *vcc) |
256 | { | 255 | { |
257 | if (sigd) return -EADDRINUSE; | 256 | if (sigd) |
257 | return -EADDRINUSE; | ||
258 | pr_debug("\n"); | 258 | pr_debug("\n"); |
259 | sigd = vcc; | 259 | sigd = vcc; |
260 | vcc->dev = &sigd_dev; | 260 | vcc->dev = &sigd_dev; |
261 | vcc_insert_socket(sk_atm(vcc)); | 261 | vcc_insert_socket(sk_atm(vcc)); |
262 | set_bit(ATM_VF_META,&vcc->flags); | 262 | set_bit(ATM_VF_META, &vcc->flags); |
263 | set_bit(ATM_VF_READY,&vcc->flags); | 263 | set_bit(ATM_VF_READY, &vcc->flags); |
264 | #ifdef WAIT_FOR_DEMON | 264 | #ifdef WAIT_FOR_DEMON |
265 | wake_up(&sigd_sleep); | 265 | wake_up(&sigd_sleep); |
266 | #endif | 266 | #endif |