Lines Matching full:mp

145 static int capiminor_add_ack(struct capiminor *mp, u16 datahandle)  in capiminor_add_ack()  argument
156 spin_lock_bh(&mp->ackqlock); in capiminor_add_ack()
157 list_add_tail(&n->list, &mp->ackqueue); in capiminor_add_ack()
158 mp->nack++; in capiminor_add_ack()
159 spin_unlock_bh(&mp->ackqlock); in capiminor_add_ack()
163 static int capiminor_del_ack(struct capiminor *mp, u16 datahandle) in capiminor_del_ack() argument
167 spin_lock_bh(&mp->ackqlock); in capiminor_del_ack()
168 list_for_each_entry_safe(p, tmp, &mp->ackqueue, list) { in capiminor_del_ack()
171 mp->nack--; in capiminor_del_ack()
172 spin_unlock_bh(&mp->ackqlock); in capiminor_del_ack()
177 spin_unlock_bh(&mp->ackqlock); in capiminor_del_ack()
181 static void capiminor_del_all_ack(struct capiminor *mp) in capiminor_del_all_ack() argument
185 list_for_each_entry_safe(p, tmp, &mp->ackqueue, list) { in capiminor_del_all_ack()
188 mp->nack--; in capiminor_del_all_ack()
197 struct capiminor *mp = container_of(port, struct capiminor, port); in capiminor_destroy() local
199 kfree_skb(mp->outskb); in capiminor_destroy()
200 skb_queue_purge(&mp->inqueue); in capiminor_destroy()
201 skb_queue_purge(&mp->outqueue); in capiminor_destroy()
202 capiminor_del_all_ack(mp); in capiminor_destroy()
203 kfree(mp); in capiminor_destroy()
212 struct capiminor *mp; in capiminor_alloc() local
216 mp = kzalloc(sizeof(*mp), GFP_KERNEL); in capiminor_alloc()
217 if (!mp) { in capiminor_alloc()
222 mp->ap = ap; in capiminor_alloc()
223 mp->ncci = ncci; in capiminor_alloc()
224 INIT_LIST_HEAD(&mp->ackqueue); in capiminor_alloc()
225 spin_lock_init(&mp->ackqlock); in capiminor_alloc()
227 skb_queue_head_init(&mp->inqueue); in capiminor_alloc()
228 skb_queue_head_init(&mp->outqueue); in capiminor_alloc()
229 spin_lock_init(&mp->outlock); in capiminor_alloc()
231 tty_port_init(&mp->port); in capiminor_alloc()
232 mp->port.ops = &capiminor_port_ops; in capiminor_alloc()
238 capiminors[minor] = mp; in capiminor_alloc()
248 mp->minor = minor; in capiminor_alloc()
250 dev = tty_port_register_device(&mp->port, capinc_tty_driver, minor, in capiminor_alloc()
255 return mp; in capiminor_alloc()
263 tty_port_put(&mp->port); in capiminor_alloc()
269 struct capiminor *mp; in capiminor_get() local
272 mp = capiminors[minor]; in capiminor_get()
273 if (mp) in capiminor_get()
274 tty_port_get(&mp->port); in capiminor_get()
277 return mp; in capiminor_get()
280 static inline void capiminor_put(struct capiminor *mp) in capiminor_put() argument
282 tty_port_put(&mp->port); in capiminor_put()
285 static void capiminor_free(struct capiminor *mp) in capiminor_free() argument
287 tty_unregister_device(capinc_tty_driver, mp->minor); in capiminor_free()
290 capiminors[mp->minor] = NULL; in capiminor_free()
293 capiminor_put(mp); in capiminor_free()
306 struct capiminor *mp = np->minorp; in capincci_free_minor() local
309 if (mp) { in capincci_free_minor()
310 tty = tty_port_tty_get(&mp->port); in capincci_free_minor()
316 capiminor_free(mp); in capincci_free_minor()
322 struct capiminor *mp = np->minorp; in capincci_minor_opencount() local
326 if (mp) { in capincci_minor_opencount()
327 tty = tty_port_tty_get(&mp->port); in capincci_minor_opencount()
387 gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb) in gen_data_b3_resp_for() argument
395 capimsg_setu16(s, 2, mp->ap->applid); in gen_data_b3_resp_for()
398 capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid)); in gen_data_b3_resp_for()
399 capimsg_setu32(s, 8, mp->ncci); in gen_data_b3_resp_for()
405 static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) in handle_recv_skb() argument
414 tty = tty_port_tty_get(&mp->port); in handle_recv_skb()
433 if (mp->ttyinstop) { in handle_recv_skb()
443 nskb = gen_data_b3_resp_for(mp, skb); in handle_recv_skb()
451 errcode = capi20_put_message(mp->ap, nskb); in handle_recv_skb()
479 static void handle_minor_recv(struct capiminor *mp) in handle_minor_recv() argument
483 while ((skb = skb_dequeue(&mp->inqueue)) != NULL) in handle_minor_recv()
484 if (handle_recv_skb(mp, skb) < 0) { in handle_minor_recv()
485 skb_queue_head(&mp->inqueue, skb); in handle_minor_recv()
490 static void handle_minor_send(struct capiminor *mp) in handle_minor_send() argument
498 tty = tty_port_tty_get(&mp->port); in handle_minor_send()
502 if (mp->ttyoutstop) { in handle_minor_send()
509 spin_lock_bh(&mp->outlock); in handle_minor_send()
510 skb = __skb_dequeue(&mp->outqueue); in handle_minor_send()
512 spin_unlock_bh(&mp->outlock); in handle_minor_send()
516 mp->outbytes -= len; in handle_minor_send()
517 spin_unlock_bh(&mp->outlock); in handle_minor_send()
519 datahandle = atomic_inc_return(&mp->datahandle); in handle_minor_send()
523 capimsg_setu16(skb->data, 2, mp->ap->applid); in handle_minor_send()
526 capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid)); in handle_minor_send()
527 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */ in handle_minor_send()
533 if (capiminor_add_ack(mp, datahandle) < 0) { in handle_minor_send()
536 spin_lock_bh(&mp->outlock); in handle_minor_send()
537 __skb_queue_head(&mp->outqueue, skb); in handle_minor_send()
538 mp->outbytes += len; in handle_minor_send()
539 spin_unlock_bh(&mp->outlock); in handle_minor_send()
543 errcode = capi20_put_message(mp->ap, skb); in handle_minor_send()
549 capiminor_del_ack(mp, datahandle); in handle_minor_send()
554 spin_lock_bh(&mp->outlock); in handle_minor_send()
555 __skb_queue_head(&mp->outqueue, skb); in handle_minor_send()
556 mp->outbytes += len; in handle_minor_send()
557 spin_unlock_bh(&mp->outlock); in handle_minor_send()
576 struct capiminor *mp; in capi_recv_message() local
611 mp = np->minorp; in capi_recv_message()
612 if (!mp) { in capi_recv_message()
621 skb_queue_tail(&mp->inqueue, skb); in capi_recv_message()
623 handle_minor_recv(mp); in capi_recv_message()
632 capiminor_del_ack(mp, datahandle); in capi_recv_message()
633 tty_port_tty_wakeup(&mp->port); in capi_recv_message()
634 handle_minor_send(mp); in capi_recv_message()
920 struct capiminor *mp; in capi_ioctl() local
930 mp = nccip->minorp; in capi_ioctl()
931 if (mp) in capi_ioctl()
932 unit = mp->minor; in capi_ioctl()
1043 struct capiminor *mp = capiminor_get(tty->index); in capinc_tty_install() local
1047 tty->driver_data = mp; in capinc_tty_install()
1049 capiminor_put(mp); in capinc_tty_install()
1055 struct capiminor *mp = tty->driver_data; in capinc_tty_cleanup() local
1057 capiminor_put(mp); in capinc_tty_cleanup()
1062 struct capiminor *mp = tty->driver_data; in capinc_tty_open() local
1065 err = tty_port_open(&mp->port, tty, filp); in capinc_tty_open()
1069 handle_minor_recv(mp); in capinc_tty_open()
1075 struct capiminor *mp = tty->driver_data; in capinc_tty_close() local
1077 tty_port_close(&mp->port, tty, filp); in capinc_tty_close()
1083 struct capiminor *mp = tty->driver_data; in capinc_tty_write() local
1088 spin_lock_bh(&mp->outlock); in capinc_tty_write()
1089 skb = mp->outskb; in capinc_tty_write()
1091 mp->outskb = NULL; in capinc_tty_write()
1092 __skb_queue_tail(&mp->outqueue, skb); in capinc_tty_write()
1093 mp->outbytes += skb->len; in capinc_tty_write()
1099 spin_unlock_bh(&mp->outlock); in capinc_tty_write()
1106 __skb_queue_tail(&mp->outqueue, skb); in capinc_tty_write()
1107 mp->outbytes += skb->len; in capinc_tty_write()
1108 spin_unlock_bh(&mp->outlock); in capinc_tty_write()
1110 handle_minor_send(mp); in capinc_tty_write()
1117 struct capiminor *mp = tty->driver_data; in capinc_tty_put_char() local
1124 spin_lock_bh(&mp->outlock); in capinc_tty_put_char()
1125 skb = mp->outskb; in capinc_tty_put_char()
1131 mp->outskb = NULL; in capinc_tty_put_char()
1132 __skb_queue_tail(&mp->outqueue, skb); in capinc_tty_put_char()
1133 mp->outbytes += skb->len; in capinc_tty_put_char()
1141 mp->outskb = skb; in capinc_tty_put_char()
1148 spin_unlock_bh(&mp->outlock); in capinc_tty_put_char()
1151 handle_minor_send(mp); in capinc_tty_put_char()
1158 struct capiminor *mp = tty->driver_data; in capinc_tty_flush_chars() local
1161 spin_lock_bh(&mp->outlock); in capinc_tty_flush_chars()
1162 skb = mp->outskb; in capinc_tty_flush_chars()
1164 mp->outskb = NULL; in capinc_tty_flush_chars()
1165 __skb_queue_tail(&mp->outqueue, skb); in capinc_tty_flush_chars()
1166 mp->outbytes += skb->len; in capinc_tty_flush_chars()
1167 spin_unlock_bh(&mp->outlock); in capinc_tty_flush_chars()
1169 handle_minor_send(mp); in capinc_tty_flush_chars()
1171 spin_unlock_bh(&mp->outlock); in capinc_tty_flush_chars()
1173 handle_minor_recv(mp); in capinc_tty_flush_chars()
1178 struct capiminor *mp = tty->driver_data; in capinc_tty_write_room() local
1181 room = CAPINC_MAX_SENDQUEUE-skb_queue_len(&mp->outqueue); in capinc_tty_write_room()
1189 struct capiminor *mp = tty->driver_data; in capinc_tty_chars_in_buffer() local
1192 mp->outbytes, mp->nack, in capinc_tty_chars_in_buffer()
1193 skb_queue_len(&mp->outqueue), in capinc_tty_chars_in_buffer()
1194 skb_queue_len(&mp->inqueue)); in capinc_tty_chars_in_buffer()
1195 return mp->outbytes; in capinc_tty_chars_in_buffer()
1200 struct capiminor *mp = tty->driver_data; in capinc_tty_throttle() local
1201 mp->ttyinstop = 1; in capinc_tty_throttle()
1206 struct capiminor *mp = tty->driver_data; in capinc_tty_unthrottle() local
1208 mp->ttyinstop = 0; in capinc_tty_unthrottle()
1209 handle_minor_recv(mp); in capinc_tty_unthrottle()
1214 struct capiminor *mp = tty->driver_data; in capinc_tty_stop() local
1216 mp->ttyoutstop = 1; in capinc_tty_stop()
1221 struct capiminor *mp = tty->driver_data; in capinc_tty_start() local
1223 mp->ttyoutstop = 0; in capinc_tty_start()
1224 handle_minor_send(mp); in capinc_tty_start()
1229 struct capiminor *mp = tty->driver_data; in capinc_tty_hangup() local
1231 tty_port_hangup(&mp->port); in capinc_tty_hangup()