Lines Matching refs:st_gdata
30 static void add_channel_to_table(struct st_data_s *st_gdata, in add_channel_to_table() argument
35 st_gdata->list[new_proto->chnl_id] = new_proto; in add_channel_to_table()
36 st_gdata->is_registered[new_proto->chnl_id] = true; in add_channel_to_table()
39 static void remove_channel_from_table(struct st_data_s *st_gdata, in remove_channel_from_table() argument
44 st_gdata->is_registered[proto->chnl_id] = false; in remove_channel_from_table()
54 int st_get_uart_wr_room(struct st_data_s *st_gdata) in st_get_uart_wr_room() argument
57 if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) { in st_get_uart_wr_room()
61 tty = st_gdata->tty; in st_get_uart_wr_room()
73 int st_int_write(struct st_data_s *st_gdata, in st_int_write() argument
77 if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) { in st_int_write()
81 tty = st_gdata->tty; in st_int_write()
94 static void st_send_frame(unsigned char chnl_id, struct st_data_s *st_gdata) in st_send_frame() argument
99 (st_gdata == NULL || st_gdata->rx_skb == NULL in st_send_frame()
100 || st_gdata->is_registered[chnl_id] == false)) { in st_send_frame()
103 kfree_skb(st_gdata->rx_skb); in st_send_frame()
112 if (likely(st_gdata->list[chnl_id]->recv != NULL)) { in st_send_frame()
114 (st_gdata->list[chnl_id]->recv in st_send_frame()
115 (st_gdata->list[chnl_id]->priv_data, st_gdata->rx_skb) in st_send_frame()
118 kfree_skb(st_gdata->rx_skb); in st_send_frame()
123 kfree_skb(st_gdata->rx_skb); in st_send_frame()
134 static void st_reg_complete(struct st_data_s *st_gdata, int err) in st_reg_complete() argument
139 if (likely(st_gdata != NULL && in st_reg_complete()
140 st_gdata->is_registered[i] == true && in st_reg_complete()
141 st_gdata->list[i]->reg_complete_cb != NULL)) { in st_reg_complete()
142 st_gdata->list[i]->reg_complete_cb in st_reg_complete()
143 (st_gdata->list[i]->priv_data, err); in st_reg_complete()
146 st_gdata->is_registered[i] = false; in st_reg_complete()
147 if (st_gdata->protos_registered) in st_reg_complete()
148 st_gdata->protos_registered--; in st_reg_complete()
154 static inline int st_check_data_len(struct st_data_s *st_gdata, in st_check_data_len() argument
157 int room = skb_tailroom(st_gdata->rx_skb); in st_check_data_len()
167 st_send_frame(chnl_id, st_gdata); in st_check_data_len()
176 kfree_skb(st_gdata->rx_skb); in st_check_data_len()
182 st_gdata->rx_state = ST_W4_DATA; in st_check_data_len()
183 st_gdata->rx_count = len; in st_check_data_len()
188 st_gdata->rx_state = ST_W4_PACKET_TYPE; in st_check_data_len()
189 st_gdata->rx_skb = NULL; in st_check_data_len()
190 st_gdata->rx_count = 0; in st_check_data_len()
191 st_gdata->rx_chnl = 0; in st_check_data_len()
200 static inline void st_wakeup_ack(struct st_data_s *st_gdata, in st_wakeup_ack() argument
206 spin_lock_irqsave(&st_gdata->lock, flags); in st_wakeup_ack()
211 while ((waiting_skb = skb_dequeue(&st_gdata->tx_waitq))) in st_wakeup_ack()
212 skb_queue_tail(&st_gdata->txq, waiting_skb); in st_wakeup_ack()
215 st_ll_sleep_state(st_gdata, (unsigned long)cmd); in st_wakeup_ack()
216 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_wakeup_ack()
219 st_tx_wakeup(st_gdata); in st_wakeup_ack()
239 struct st_data_s *st_gdata = (struct st_data_s *)disc_data; in st_int_recv() local
244 if (unlikely(ptr == NULL) || (st_gdata == NULL)) { in st_int_recv()
250 "rx_count %ld", count, st_gdata->rx_state, in st_int_recv()
251 st_gdata->rx_count); in st_int_recv()
253 spin_lock_irqsave(&st_gdata->lock, flags); in st_int_recv()
256 if (st_gdata->rx_count) { in st_int_recv()
257 len = min_t(unsigned int, st_gdata->rx_count, count); in st_int_recv()
258 skb_put_data(st_gdata->rx_skb, ptr, len); in st_int_recv()
259 st_gdata->rx_count -= len; in st_int_recv()
263 if (st_gdata->rx_count) in st_int_recv()
267 switch (st_gdata->rx_state) { in st_int_recv()
275 st_send_frame(st_gdata->rx_chnl, st_gdata); in st_int_recv()
277 st_gdata->rx_state = ST_W4_PACKET_TYPE; in st_int_recv()
278 st_gdata->rx_skb = NULL; in st_int_recv()
282 proto = st_gdata->list[st_gdata->rx_chnl]; in st_int_recv()
284 &st_gdata->rx_skb->data in st_int_recv()
296 st_check_data_len(st_gdata, proto->chnl_id, in st_int_recv()
319 st_ll_sleep_state(st_gdata, *ptr); in st_int_recv()
324 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_int_recv()
325 if (st_ll_getstate(st_gdata) == ST_LL_AWAKE) in st_int_recv()
326 st_wakeup_ack(st_gdata, LL_WAKE_UP_ACK); in st_int_recv()
327 spin_lock_irqsave(&st_gdata->lock, flags); in st_int_recv()
335 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_int_recv()
337 st_wakeup_ack(st_gdata, *ptr); in st_int_recv()
338 spin_lock_irqsave(&st_gdata->lock, flags); in st_int_recv()
360 (st_gdata->list[type] == NULL)) { in st_int_recv()
367 st_gdata->rx_skb = alloc_skb( in st_int_recv()
368 st_gdata->list[type]->max_frame_size, in st_int_recv()
370 if (st_gdata->rx_skb == NULL) { in st_int_recv()
375 skb_reserve(st_gdata->rx_skb, in st_int_recv()
376 st_gdata->list[type]->reserve); in st_int_recv()
378 st_gdata->rx_skb->cb[0] = type; /*pkt_type*/ in st_int_recv()
379 st_gdata->rx_skb->cb[1] = 0; /*incoming*/ in st_int_recv()
380 st_gdata->rx_chnl = *ptr; in st_int_recv()
381 st_gdata->rx_state = ST_W4_HEADER; in st_int_recv()
382 st_gdata->rx_count = st_gdata->list[type]->hdr_len; in st_int_recv()
383 pr_debug("rx_count %ld\n", st_gdata->rx_count); in st_int_recv()
389 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_int_recv()
400 static struct sk_buff *st_int_dequeue(struct st_data_s *st_gdata) in st_int_dequeue() argument
405 if (st_gdata->tx_skb != NULL) { in st_int_dequeue()
406 returning_skb = st_gdata->tx_skb; in st_int_dequeue()
407 st_gdata->tx_skb = NULL; in st_int_dequeue()
410 return skb_dequeue(&st_gdata->txq); in st_int_dequeue()
422 static void st_int_enqueue(struct st_data_s *st_gdata, struct sk_buff *skb) in st_int_enqueue() argument
427 spin_lock_irqsave(&st_gdata->lock, flags); in st_int_enqueue()
429 switch (st_ll_getstate(st_gdata)) { in st_int_enqueue()
432 skb_queue_tail(&st_gdata->txq, skb); in st_int_enqueue()
435 skb_queue_tail(&st_gdata->tx_waitq, skb); in st_int_enqueue()
439 "purging received skb.", st_ll_getstate(st_gdata)); in st_int_enqueue()
443 skb_queue_tail(&st_gdata->tx_waitq, skb); in st_int_enqueue()
444 st_ll_wakeup(st_gdata); in st_int_enqueue()
448 "purging received skb.", st_ll_getstate(st_gdata)); in st_int_enqueue()
453 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_int_enqueue()
466 struct st_data_s *st_gdata = container_of(work, struct st_data_s, in work_fn_write_wakeup() local
469 st_tx_wakeup((void *)st_gdata); in work_fn_write_wakeup()
516 void kim_st_list_protocols(struct st_data_s *st_gdata, void *buf) in kim_st_list_protocols() argument
519 st_gdata->protos_registered, in kim_st_list_protocols()
520 st_gdata->is_registered[0x04] == true ? 'R' : 'U', in kim_st_list_protocols()
521 st_gdata->is_registered[0x08] == true ? 'R' : 'U', in kim_st_list_protocols()
522 st_gdata->is_registered[0x09] == true ? 'R' : 'U'); in kim_st_list_protocols()
532 struct st_data_s *st_gdata; in st_register() local
536 st_kim_ref(&st_gdata, 0); in st_register()
537 if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL in st_register()
548 if (st_gdata->is_registered[new_proto->chnl_id] == true) { in st_register()
554 spin_lock_irqsave(&st_gdata->lock, flags); in st_register()
556 if (test_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state)) { in st_register()
560 add_channel_to_table(st_gdata, new_proto); in st_register()
561 st_gdata->protos_registered++; in st_register()
564 set_bit(ST_REG_PENDING, &st_gdata->st_state); in st_register()
565 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
567 } else if (st_gdata->protos_registered == ST_EMPTY) { in st_register()
569 set_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); in st_register()
573 st_ll_enable(st_gdata); in st_register()
576 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
582 err = st_kim_start(st_gdata->kim_data); in st_register()
584 clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); in st_register()
585 if ((st_gdata->protos_registered != ST_EMPTY) && in st_register()
586 (test_bit(ST_REG_PENDING, &st_gdata->st_state))) { in st_register()
588 spin_lock_irqsave(&st_gdata->lock, flags); in st_register()
589 st_reg_complete(st_gdata, err); in st_register()
590 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
591 clear_bit(ST_REG_PENDING, &st_gdata->st_state); in st_register()
596 spin_lock_irqsave(&st_gdata->lock, flags); in st_register()
598 clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); in st_register()
605 if ((st_gdata->protos_registered != ST_EMPTY) && in st_register()
606 (test_bit(ST_REG_PENDING, &st_gdata->st_state))) { in st_register()
608 st_reg_complete(st_gdata, 0); in st_register()
610 clear_bit(ST_REG_PENDING, &st_gdata->st_state); in st_register()
616 if (st_gdata->is_registered[new_proto->chnl_id] == true) { in st_register()
619 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
623 add_channel_to_table(st_gdata, new_proto); in st_register()
624 st_gdata->protos_registered++; in st_register()
626 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
631 add_channel_to_table(st_gdata, new_proto); in st_register()
632 st_gdata->protos_registered++; in st_register()
636 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
650 struct st_data_s *st_gdata; in st_unregister() local
654 st_kim_ref(&st_gdata, 0); in st_unregister()
655 if (!st_gdata || proto->chnl_id >= ST_MAX_CHANNELS) { in st_unregister()
660 spin_lock_irqsave(&st_gdata->lock, flags); in st_unregister()
662 if (st_gdata->is_registered[proto->chnl_id] == false) { in st_unregister()
664 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_unregister()
668 if (st_gdata->protos_registered) in st_unregister()
669 st_gdata->protos_registered--; in st_unregister()
671 remove_channel_from_table(st_gdata, proto); in st_unregister()
672 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_unregister()
674 if ((st_gdata->protos_registered == ST_EMPTY) && in st_unregister()
675 (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) { in st_unregister()
679 if (st_gdata->tty) { in st_unregister()
680 tty_ldisc_flush(st_gdata->tty); in st_unregister()
681 stop_tty(st_gdata->tty); in st_unregister()
685 st_kim_stop(st_gdata->kim_data); in st_unregister()
687 st_ll_disable(st_gdata); in st_unregister()
698 struct st_data_s *st_gdata; in st_write() local
701 st_kim_ref(&st_gdata, 0); in st_write()
702 if (unlikely(skb == NULL || st_gdata == NULL in st_write()
703 || st_gdata->tty == NULL)) { in st_write()
712 st_int_enqueue(st_gdata, skb); in st_write()
714 st_tx_wakeup(st_gdata); in st_write()
729 struct st_data_s *st_gdata; in st_tty_open() local
732 st_kim_ref(&st_gdata, 0); in st_tty_open()
733 st_gdata->tty = tty; in st_tty_open()
734 tty->disc_data = st_gdata; in st_tty_open()
749 st_kim_complete(st_gdata->kim_data); in st_tty_open()
759 struct st_data_s *st_gdata = tty->disc_data; in st_tty_close() local
768 spin_lock_irqsave(&st_gdata->lock, flags); in st_tty_close()
770 if (st_gdata->is_registered[i] == true) in st_tty_close()
772 st_gdata->list[i] = NULL; in st_tty_close()
773 st_gdata->is_registered[i] = false; in st_tty_close()
775 st_gdata->protos_registered = 0; in st_tty_close()
776 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_tty_close()
781 st_kim_complete(st_gdata->kim_data); in st_tty_close()
782 st_gdata->tty = NULL; in st_tty_close()
787 spin_lock_irqsave(&st_gdata->lock, flags); in st_tty_close()
789 skb_queue_purge(&st_gdata->txq); in st_tty_close()
790 skb_queue_purge(&st_gdata->tx_waitq); in st_tty_close()
792 st_gdata->rx_count = 0; in st_tty_close()
793 st_gdata->rx_state = ST_W4_PACKET_TYPE; in st_tty_close()
794 kfree_skb(st_gdata->rx_skb); in st_tty_close()
795 st_gdata->rx_skb = NULL; in st_tty_close()
796 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_tty_close()
823 struct st_data_s *st_gdata = tty->disc_data; in st_tty_wakeup() local
833 schedule_work(&st_gdata->work_write_wakeup); in st_tty_wakeup()
838 struct st_data_s *st_gdata = tty->disc_data; in st_tty_flush_buffer() local
841 kfree_skb(st_gdata->tx_skb); in st_tty_flush_buffer()
842 st_gdata->tx_skb = NULL; in st_tty_flush_buffer()
862 struct st_data_s *st_gdata; in st_core_init() local
873 st_gdata = kzalloc(sizeof(struct st_data_s), GFP_KERNEL); in st_core_init()
874 if (!st_gdata) { in st_core_init()
886 skb_queue_head_init(&st_gdata->txq); in st_core_init()
887 skb_queue_head_init(&st_gdata->tx_waitq); in st_core_init()
890 spin_lock_init(&st_gdata->lock); in st_core_init()
892 err = st_ll_init(st_gdata); in st_core_init()
895 kfree(st_gdata); in st_core_init()
902 INIT_WORK(&st_gdata->work_write_wakeup, work_fn_write_wakeup); in st_core_init()
904 *core_data = st_gdata; in st_core_init()
908 void st_core_exit(struct st_data_s *st_gdata) in st_core_exit() argument
912 err = st_ll_deinit(st_gdata); in st_core_exit()
916 if (st_gdata != NULL) { in st_core_exit()
918 skb_queue_purge(&st_gdata->txq); in st_core_exit()
919 skb_queue_purge(&st_gdata->tx_waitq); in st_core_exit()
920 kfree_skb(st_gdata->rx_skb); in st_core_exit()
921 kfree_skb(st_gdata->tx_skb); in st_core_exit()
927 kfree(st_gdata); in st_core_exit()