Lines Matching full:mp

147 static int capiminor_add_ack(struct capiminor *mp, u16 datahandle)  in capiminor_add_ack()  argument
158 spin_lock_bh(&mp->ackqlock); in capiminor_add_ack()
159 list_add_tail(&n->list, &mp->ackqueue); in capiminor_add_ack()
160 mp->nack++; in capiminor_add_ack()
161 spin_unlock_bh(&mp->ackqlock); in capiminor_add_ack()
165 static int capiminor_del_ack(struct capiminor *mp, u16 datahandle) in capiminor_del_ack() argument
169 spin_lock_bh(&mp->ackqlock); in capiminor_del_ack()
170 list_for_each_entry_safe(p, tmp, &mp->ackqueue, list) { in capiminor_del_ack()
173 mp->nack--; in capiminor_del_ack()
174 spin_unlock_bh(&mp->ackqlock); in capiminor_del_ack()
179 spin_unlock_bh(&mp->ackqlock); in capiminor_del_ack()
183 static void capiminor_del_all_ack(struct capiminor *mp) in capiminor_del_all_ack() argument
187 list_for_each_entry_safe(p, tmp, &mp->ackqueue, list) { in capiminor_del_all_ack()
190 mp->nack--; in capiminor_del_all_ack()
199 struct capiminor *mp = container_of(port, struct capiminor, port); in capiminor_destroy() local
201 kfree_skb(mp->outskb); in capiminor_destroy()
202 skb_queue_purge(&mp->inqueue); in capiminor_destroy()
203 skb_queue_purge(&mp->outqueue); in capiminor_destroy()
204 capiminor_del_all_ack(mp); in capiminor_destroy()
205 kfree(mp); in capiminor_destroy()
214 struct capiminor *mp; in capiminor_alloc() local
218 mp = kzalloc(sizeof(*mp), GFP_KERNEL); in capiminor_alloc()
219 if (!mp) { in capiminor_alloc()
224 mp->ap = ap; in capiminor_alloc()
225 mp->ncci = ncci; in capiminor_alloc()
226 INIT_LIST_HEAD(&mp->ackqueue); in capiminor_alloc()
227 spin_lock_init(&mp->ackqlock); in capiminor_alloc()
229 skb_queue_head_init(&mp->inqueue); in capiminor_alloc()
230 skb_queue_head_init(&mp->outqueue); in capiminor_alloc()
231 spin_lock_init(&mp->outlock); in capiminor_alloc()
233 tty_port_init(&mp->port); in capiminor_alloc()
234 mp->port.ops = &capiminor_port_ops; in capiminor_alloc()
240 capiminors[minor] = mp; in capiminor_alloc()
250 mp->minor = minor; in capiminor_alloc()
252 dev = tty_port_register_device(&mp->port, capinc_tty_driver, minor, in capiminor_alloc()
257 return mp; in capiminor_alloc()
265 tty_port_put(&mp->port); in capiminor_alloc()
271 struct capiminor *mp; in capiminor_get() local
274 mp = capiminors[minor]; in capiminor_get()
275 if (mp) in capiminor_get()
276 tty_port_get(&mp->port); in capiminor_get()
279 return mp; in capiminor_get()
282 static inline void capiminor_put(struct capiminor *mp) in capiminor_put() argument
284 tty_port_put(&mp->port); in capiminor_put()
287 static void capiminor_free(struct capiminor *mp) in capiminor_free() argument
289 tty_unregister_device(capinc_tty_driver, mp->minor); in capiminor_free()
292 capiminors[mp->minor] = NULL; in capiminor_free()
295 capiminor_put(mp); in capiminor_free()
308 struct capiminor *mp = np->minorp; in capincci_free_minor() local
311 if (mp) { in capincci_free_minor()
312 tty = tty_port_tty_get(&mp->port); in capincci_free_minor()
318 capiminor_free(mp); in capincci_free_minor()
324 struct capiminor *mp = np->minorp; in capincci_minor_opencount() local
328 if (mp) { in capincci_minor_opencount()
329 tty = tty_port_tty_get(&mp->port); in capincci_minor_opencount()
389 gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb) in gen_data_b3_resp_for() argument
397 capimsg_setu16(s, 2, mp->ap->applid); in gen_data_b3_resp_for()
400 capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid)); in gen_data_b3_resp_for()
401 capimsg_setu32(s, 8, mp->ncci); in gen_data_b3_resp_for()
407 static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) in handle_recv_skb() argument
416 tty = tty_port_tty_get(&mp->port); in handle_recv_skb()
435 if (mp->ttyinstop) { in handle_recv_skb()
445 nskb = gen_data_b3_resp_for(mp, skb); in handle_recv_skb()
453 errcode = capi20_put_message(mp->ap, nskb); in handle_recv_skb()
481 static void handle_minor_recv(struct capiminor *mp) in handle_minor_recv() argument
485 while ((skb = skb_dequeue(&mp->inqueue)) != NULL) in handle_minor_recv()
486 if (handle_recv_skb(mp, skb) < 0) { in handle_minor_recv()
487 skb_queue_head(&mp->inqueue, skb); in handle_minor_recv()
492 static void handle_minor_send(struct capiminor *mp) in handle_minor_send() argument
500 tty = tty_port_tty_get(&mp->port); in handle_minor_send()
504 if (mp->ttyoutstop) { in handle_minor_send()
511 spin_lock_bh(&mp->outlock); in handle_minor_send()
512 skb = __skb_dequeue(&mp->outqueue); in handle_minor_send()
514 spin_unlock_bh(&mp->outlock); in handle_minor_send()
518 mp->outbytes -= len; in handle_minor_send()
519 spin_unlock_bh(&mp->outlock); in handle_minor_send()
521 datahandle = atomic_inc_return(&mp->datahandle); in handle_minor_send()
525 capimsg_setu16(skb->data, 2, mp->ap->applid); in handle_minor_send()
528 capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid)); in handle_minor_send()
529 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */ in handle_minor_send()
535 if (capiminor_add_ack(mp, datahandle) < 0) { in handle_minor_send()
538 spin_lock_bh(&mp->outlock); in handle_minor_send()
539 __skb_queue_head(&mp->outqueue, skb); in handle_minor_send()
540 mp->outbytes += len; in handle_minor_send()
541 spin_unlock_bh(&mp->outlock); in handle_minor_send()
545 errcode = capi20_put_message(mp->ap, skb); in handle_minor_send()
551 capiminor_del_ack(mp, datahandle); in handle_minor_send()
556 spin_lock_bh(&mp->outlock); in handle_minor_send()
557 __skb_queue_head(&mp->outqueue, skb); in handle_minor_send()
558 mp->outbytes += len; in handle_minor_send()
559 spin_unlock_bh(&mp->outlock); in handle_minor_send()
578 struct capiminor *mp; in capi_recv_message() local
613 mp = np->minorp; in capi_recv_message()
614 if (!mp) { in capi_recv_message()
623 skb_queue_tail(&mp->inqueue, skb); in capi_recv_message()
625 handle_minor_recv(mp); in capi_recv_message()
634 capiminor_del_ack(mp, datahandle); in capi_recv_message()
635 tty_port_tty_wakeup(&mp->port); in capi_recv_message()
636 handle_minor_send(mp); in capi_recv_message()
922 struct capiminor *mp; in capi_ioctl() local
932 mp = nccip->minorp; in capi_ioctl()
933 if (mp) in capi_ioctl()
934 unit = mp->minor; in capi_ioctl()
1044 struct capiminor *mp = capiminor_get(tty->index); in capinc_tty_install() local
1048 tty->driver_data = mp; in capinc_tty_install()
1050 capiminor_put(mp); in capinc_tty_install()
1056 struct capiminor *mp = tty->driver_data; in capinc_tty_cleanup() local
1058 capiminor_put(mp); in capinc_tty_cleanup()
1063 struct capiminor *mp = tty->driver_data; in capinc_tty_open() local
1066 err = tty_port_open(&mp->port, tty, filp); in capinc_tty_open()
1070 handle_minor_recv(mp); in capinc_tty_open()
1076 struct capiminor *mp = tty->driver_data; in capinc_tty_close() local
1078 tty_port_close(&mp->port, tty, filp); in capinc_tty_close()
1084 struct capiminor *mp = tty->driver_data; in capinc_tty_write() local
1089 spin_lock_bh(&mp->outlock); in capinc_tty_write()
1090 skb = mp->outskb; in capinc_tty_write()
1092 mp->outskb = NULL; in capinc_tty_write()
1093 __skb_queue_tail(&mp->outqueue, skb); in capinc_tty_write()
1094 mp->outbytes += skb->len; in capinc_tty_write()
1100 spin_unlock_bh(&mp->outlock); in capinc_tty_write()
1107 __skb_queue_tail(&mp->outqueue, skb); in capinc_tty_write()
1108 mp->outbytes += skb->len; in capinc_tty_write()
1109 spin_unlock_bh(&mp->outlock); in capinc_tty_write()
1111 handle_minor_send(mp); in capinc_tty_write()
1118 struct capiminor *mp = tty->driver_data; in capinc_tty_put_char() local
1125 spin_lock_bh(&mp->outlock); in capinc_tty_put_char()
1126 skb = mp->outskb; in capinc_tty_put_char()
1132 mp->outskb = NULL; in capinc_tty_put_char()
1133 __skb_queue_tail(&mp->outqueue, skb); in capinc_tty_put_char()
1134 mp->outbytes += skb->len; in capinc_tty_put_char()
1142 mp->outskb = skb; in capinc_tty_put_char()
1149 spin_unlock_bh(&mp->outlock); in capinc_tty_put_char()
1152 handle_minor_send(mp); in capinc_tty_put_char()
1159 struct capiminor *mp = tty->driver_data; in capinc_tty_flush_chars() local
1162 spin_lock_bh(&mp->outlock); in capinc_tty_flush_chars()
1163 skb = mp->outskb; in capinc_tty_flush_chars()
1165 mp->outskb = NULL; in capinc_tty_flush_chars()
1166 __skb_queue_tail(&mp->outqueue, skb); in capinc_tty_flush_chars()
1167 mp->outbytes += skb->len; in capinc_tty_flush_chars()
1168 spin_unlock_bh(&mp->outlock); in capinc_tty_flush_chars()
1170 handle_minor_send(mp); in capinc_tty_flush_chars()
1172 spin_unlock_bh(&mp->outlock); in capinc_tty_flush_chars()
1174 handle_minor_recv(mp); in capinc_tty_flush_chars()
1179 struct capiminor *mp = tty->driver_data; in capinc_tty_write_room() local
1182 room = CAPINC_MAX_SENDQUEUE-skb_queue_len(&mp->outqueue); in capinc_tty_write_room()
1190 struct capiminor *mp = tty->driver_data; in capinc_tty_chars_in_buffer() local
1193 mp->outbytes, mp->nack, in capinc_tty_chars_in_buffer()
1194 skb_queue_len(&mp->outqueue), in capinc_tty_chars_in_buffer()
1195 skb_queue_len(&mp->inqueue)); in capinc_tty_chars_in_buffer()
1196 return mp->outbytes; in capinc_tty_chars_in_buffer()
1201 struct capiminor *mp = tty->driver_data; in capinc_tty_throttle() local
1202 mp->ttyinstop = 1; in capinc_tty_throttle()
1207 struct capiminor *mp = tty->driver_data; in capinc_tty_unthrottle() local
1209 mp->ttyinstop = 0; in capinc_tty_unthrottle()
1210 handle_minor_recv(mp); in capinc_tty_unthrottle()
1215 struct capiminor *mp = tty->driver_data; in capinc_tty_stop() local
1217 mp->ttyoutstop = 1; in capinc_tty_stop()
1222 struct capiminor *mp = tty->driver_data; in capinc_tty_start() local
1224 mp->ttyoutstop = 0; in capinc_tty_start()
1225 handle_minor_send(mp); in capinc_tty_start()
1230 struct capiminor *mp = tty->driver_data; in capinc_tty_hangup() local
1232 tty_port_hangup(&mp->port); in capinc_tty_hangup()