Lines Matching refs:st_gdata
41 static void add_channel_to_table(struct st_data_s *st_gdata, in add_channel_to_table() argument
46 st_gdata->list[new_proto->chnl_id] = new_proto; in add_channel_to_table()
47 st_gdata->is_registered[new_proto->chnl_id] = true; in add_channel_to_table()
50 static void remove_channel_from_table(struct st_data_s *st_gdata, in remove_channel_from_table() argument
55 st_gdata->is_registered[proto->chnl_id] = false; in remove_channel_from_table()
65 int st_get_uart_wr_room(struct st_data_s *st_gdata) in st_get_uart_wr_room() argument
68 if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) { in st_get_uart_wr_room()
72 tty = st_gdata->tty; in st_get_uart_wr_room()
83 int st_int_write(struct st_data_s *st_gdata, in st_int_write() argument
87 if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) { in st_int_write()
91 tty = st_gdata->tty; in st_int_write()
104 static void st_send_frame(unsigned char chnl_id, struct st_data_s *st_gdata) in st_send_frame() argument
109 (st_gdata == NULL || st_gdata->rx_skb == NULL in st_send_frame()
110 || st_gdata->is_registered[chnl_id] == false)) { in st_send_frame()
113 kfree_skb(st_gdata->rx_skb); in st_send_frame()
121 if (likely(st_gdata->list[chnl_id]->recv != NULL)) { in st_send_frame()
123 (st_gdata->list[chnl_id]->recv in st_send_frame()
124 (st_gdata->list[chnl_id]->priv_data, st_gdata->rx_skb) in st_send_frame()
127 kfree_skb(st_gdata->rx_skb); in st_send_frame()
132 kfree_skb(st_gdata->rx_skb); in st_send_frame()
144 static void st_reg_complete(struct st_data_s *st_gdata, int err) in st_reg_complete() argument
149 if (likely(st_gdata != NULL && in st_reg_complete()
150 st_gdata->is_registered[i] == true && in st_reg_complete()
151 st_gdata->list[i]->reg_complete_cb != NULL)) { in st_reg_complete()
152 st_gdata->list[i]->reg_complete_cb in st_reg_complete()
153 (st_gdata->list[i]->priv_data, err); in st_reg_complete()
156 st_gdata->is_registered[i] = false; in st_reg_complete()
157 if (st_gdata->protos_registered) in st_reg_complete()
158 st_gdata->protos_registered--; in st_reg_complete()
164 static inline int st_check_data_len(struct st_data_s *st_gdata, in st_check_data_len() argument
167 int room = skb_tailroom(st_gdata->rx_skb); in st_check_data_len()
176 st_send_frame(chnl_id, st_gdata); in st_check_data_len()
184 kfree_skb(st_gdata->rx_skb); in st_check_data_len()
189 st_gdata->rx_state = ST_W4_DATA; in st_check_data_len()
190 st_gdata->rx_count = len; in st_check_data_len()
196 st_gdata->rx_state = ST_W4_PACKET_TYPE; in st_check_data_len()
197 st_gdata->rx_skb = NULL; in st_check_data_len()
198 st_gdata->rx_count = 0; in st_check_data_len()
199 st_gdata->rx_chnl = 0; in st_check_data_len()
208 static inline void st_wakeup_ack(struct st_data_s *st_gdata, in st_wakeup_ack() argument
214 spin_lock_irqsave(&st_gdata->lock, flags); in st_wakeup_ack()
218 while ((waiting_skb = skb_dequeue(&st_gdata->tx_waitq))) in st_wakeup_ack()
219 skb_queue_tail(&st_gdata->txq, waiting_skb); in st_wakeup_ack()
222 st_ll_sleep_state(st_gdata, (unsigned long)cmd); in st_wakeup_ack()
223 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_wakeup_ack()
226 st_tx_wakeup(st_gdata); in st_wakeup_ack()
246 struct st_data_s *st_gdata = (struct st_data_s *)disc_data; in st_int_recv() local
251 if (unlikely(ptr == NULL) || (st_gdata == NULL)) { in st_int_recv()
257 "rx_count %ld", count, st_gdata->rx_state, in st_int_recv()
258 st_gdata->rx_count); in st_int_recv()
260 spin_lock_irqsave(&st_gdata->lock, flags); in st_int_recv()
263 if (st_gdata->rx_count) { in st_int_recv()
264 len = min_t(unsigned int, st_gdata->rx_count, count); in st_int_recv()
265 skb_put_data(st_gdata->rx_skb, ptr, len); in st_int_recv()
266 st_gdata->rx_count -= len; in st_int_recv()
270 if (st_gdata->rx_count) in st_int_recv()
274 switch (st_gdata->rx_state) { in st_int_recv()
280 st_send_frame(st_gdata->rx_chnl, st_gdata); in st_int_recv()
282 st_gdata->rx_state = ST_W4_PACKET_TYPE; in st_int_recv()
283 st_gdata->rx_skb = NULL; in st_int_recv()
287 proto = st_gdata->list[st_gdata->rx_chnl]; in st_int_recv()
289 &st_gdata->rx_skb->data in st_int_recv()
301 st_check_data_len(st_gdata, proto->chnl_id, in st_int_recv()
320 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()
359 (st_gdata->list[type] == NULL)) { in st_int_recv()
366 st_gdata->rx_skb = alloc_skb( in st_int_recv()
367 st_gdata->list[type]->max_frame_size, in st_int_recv()
369 if (st_gdata->rx_skb == NULL) { in st_int_recv()
374 skb_reserve(st_gdata->rx_skb, in st_int_recv()
375 st_gdata->list[type]->reserve); in st_int_recv()
377 st_gdata->rx_skb->cb[0] = type; /*pkt_type*/ in st_int_recv()
378 st_gdata->rx_skb->cb[1] = 0; /*incoming*/ in st_int_recv()
379 st_gdata->rx_chnl = *ptr; in st_int_recv()
380 st_gdata->rx_state = ST_W4_HEADER; in st_int_recv()
381 st_gdata->rx_count = st_gdata->list[type]->hdr_len; in st_int_recv()
382 pr_debug("rx_count %ld\n", st_gdata->rx_count); in st_int_recv()
388 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_int_recv()
399 static struct sk_buff *st_int_dequeue(struct st_data_s *st_gdata) in st_int_dequeue() argument
404 if (st_gdata->tx_skb != NULL) { in st_int_dequeue()
405 returning_skb = st_gdata->tx_skb; in st_int_dequeue()
406 st_gdata->tx_skb = NULL; in st_int_dequeue()
409 return skb_dequeue(&st_gdata->txq); in st_int_dequeue()
421 static void st_int_enqueue(struct st_data_s *st_gdata, struct sk_buff *skb) in st_int_enqueue() argument
426 spin_lock_irqsave(&st_gdata->lock, flags); in st_int_enqueue()
428 switch (st_ll_getstate(st_gdata)) { in st_int_enqueue()
431 skb_queue_tail(&st_gdata->txq, skb); in st_int_enqueue()
434 skb_queue_tail(&st_gdata->tx_waitq, skb); in st_int_enqueue()
438 "purging received skb.", st_ll_getstate(st_gdata)); in st_int_enqueue()
442 skb_queue_tail(&st_gdata->tx_waitq, skb); in st_int_enqueue()
443 st_ll_wakeup(st_gdata); in st_int_enqueue()
447 "purging received skb.", st_ll_getstate(st_gdata)); in st_int_enqueue()
452 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_int_enqueue()
465 struct st_data_s *st_gdata = container_of(work, struct st_data_s, in work_fn_write_wakeup() local
468 st_tx_wakeup((void *)st_gdata); in work_fn_write_wakeup()
515 void kim_st_list_protocols(struct st_data_s *st_gdata, void *buf) in kim_st_list_protocols() argument
518 st_gdata->protos_registered, in kim_st_list_protocols()
519 st_gdata->is_registered[0x04] == true ? 'R' : 'U', in kim_st_list_protocols()
520 st_gdata->is_registered[0x08] == true ? 'R' : 'U', in kim_st_list_protocols()
521 st_gdata->is_registered[0x09] == true ? 'R' : 'U'); in kim_st_list_protocols()
531 struct st_data_s *st_gdata; in st_register() local
535 st_kim_ref(&st_gdata, 0); in st_register()
536 if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL in st_register()
547 if (st_gdata->is_registered[new_proto->chnl_id] == true) { in st_register()
553 spin_lock_irqsave(&st_gdata->lock, flags); in st_register()
555 if (test_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state)) { in st_register()
559 add_channel_to_table(st_gdata, new_proto); in st_register()
560 st_gdata->protos_registered++; in st_register()
563 set_bit(ST_REG_PENDING, &st_gdata->st_state); in st_register()
564 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
566 } else if (st_gdata->protos_registered == ST_EMPTY) { in st_register()
568 set_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); in st_register()
572 st_ll_enable(st_gdata); in st_register()
575 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
580 err = st_kim_start(st_gdata->kim_data); in st_register()
582 clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); in st_register()
583 if ((st_gdata->protos_registered != ST_EMPTY) && in st_register()
584 (test_bit(ST_REG_PENDING, &st_gdata->st_state))) { in st_register()
586 spin_lock_irqsave(&st_gdata->lock, flags); in st_register()
587 st_reg_complete(st_gdata, err); in st_register()
588 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
589 clear_bit(ST_REG_PENDING, &st_gdata->st_state); in st_register()
594 spin_lock_irqsave(&st_gdata->lock, flags); in st_register()
596 clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); in st_register()
602 if ((st_gdata->protos_registered != ST_EMPTY) && in st_register()
603 (test_bit(ST_REG_PENDING, &st_gdata->st_state))) { in st_register()
605 st_reg_complete(st_gdata, 0); in st_register()
607 clear_bit(ST_REG_PENDING, &st_gdata->st_state); in st_register()
612 if (st_gdata->is_registered[new_proto->chnl_id] == true) { in st_register()
615 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
619 add_channel_to_table(st_gdata, new_proto); in st_register()
620 st_gdata->protos_registered++; in st_register()
622 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
627 add_channel_to_table(st_gdata, new_proto); in st_register()
628 st_gdata->protos_registered++; in st_register()
632 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
645 struct st_data_s *st_gdata; in st_unregister() local
649 st_kim_ref(&st_gdata, 0); in st_unregister()
650 if (!st_gdata || proto->chnl_id >= ST_MAX_CHANNELS) { in st_unregister()
655 spin_lock_irqsave(&st_gdata->lock, flags); in st_unregister()
657 if (st_gdata->is_registered[proto->chnl_id] == false) { in st_unregister()
659 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_unregister()
663 if (st_gdata->protos_registered) in st_unregister()
664 st_gdata->protos_registered--; in st_unregister()
666 remove_channel_from_table(st_gdata, proto); in st_unregister()
667 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_unregister()
669 if ((st_gdata->protos_registered == ST_EMPTY) && in st_unregister()
670 (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) { in st_unregister()
674 if (st_gdata->tty) { in st_unregister()
675 tty_ldisc_flush(st_gdata->tty); in st_unregister()
676 stop_tty(st_gdata->tty); in st_unregister()
680 st_kim_stop(st_gdata->kim_data); in st_unregister()
682 st_ll_disable(st_gdata); in st_unregister()
693 struct st_data_s *st_gdata; in st_write() local
696 st_kim_ref(&st_gdata, 0); in st_write()
697 if (unlikely(skb == NULL || st_gdata == NULL in st_write()
698 || st_gdata->tty == NULL)) { in st_write()
707 st_int_enqueue(st_gdata, skb); in st_write()
709 st_tx_wakeup(st_gdata); in st_write()
725 struct st_data_s *st_gdata; in st_tty_open() local
728 st_kim_ref(&st_gdata, 0); in st_tty_open()
729 st_gdata->tty = tty; in st_tty_open()
730 tty->disc_data = st_gdata; in st_tty_open()
745 st_kim_complete(st_gdata->kim_data); in st_tty_open()
754 struct st_data_s *st_gdata = tty->disc_data; in st_tty_close() local
762 spin_lock_irqsave(&st_gdata->lock, flags); in st_tty_close()
764 if (st_gdata->is_registered[i] == true) in st_tty_close()
766 st_gdata->list[i] = NULL; in st_tty_close()
767 st_gdata->is_registered[i] = false; in st_tty_close()
769 st_gdata->protos_registered = 0; in st_tty_close()
770 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_tty_close()
775 st_kim_complete(st_gdata->kim_data); in st_tty_close()
776 st_gdata->tty = NULL; in st_tty_close()
781 spin_lock_irqsave(&st_gdata->lock, flags); in st_tty_close()
783 skb_queue_purge(&st_gdata->txq); in st_tty_close()
784 skb_queue_purge(&st_gdata->tx_waitq); in st_tty_close()
786 st_gdata->rx_count = 0; in st_tty_close()
787 st_gdata->rx_state = ST_W4_PACKET_TYPE; in st_tty_close()
788 kfree_skb(st_gdata->rx_skb); in st_tty_close()
789 st_gdata->rx_skb = NULL; in st_tty_close()
790 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_tty_close()
816 struct st_data_s *st_gdata = tty->disc_data; in st_tty_wakeup() local
826 schedule_work(&st_gdata->work_write_wakeup); in st_tty_wakeup()
831 struct st_data_s *st_gdata = tty->disc_data; in st_tty_flush_buffer() local
834 kfree_skb(st_gdata->tx_skb); in st_tty_flush_buffer()
835 st_gdata->tx_skb = NULL; in st_tty_flush_buffer()
855 struct st_data_s *st_gdata; in st_core_init() local
866 st_gdata = kzalloc(sizeof(struct st_data_s), GFP_KERNEL); in st_core_init()
867 if (!st_gdata) { in st_core_init()
879 skb_queue_head_init(&st_gdata->txq); in st_core_init()
880 skb_queue_head_init(&st_gdata->tx_waitq); in st_core_init()
883 spin_lock_init(&st_gdata->lock); in st_core_init()
885 err = st_ll_init(st_gdata); in st_core_init()
888 kfree(st_gdata); in st_core_init()
895 INIT_WORK(&st_gdata->work_write_wakeup, work_fn_write_wakeup); in st_core_init()
897 *core_data = st_gdata; in st_core_init()
901 void st_core_exit(struct st_data_s *st_gdata) in st_core_exit() argument
905 err = st_ll_deinit(st_gdata); in st_core_exit()
909 if (st_gdata != NULL) { in st_core_exit()
911 skb_queue_purge(&st_gdata->txq); in st_core_exit()
912 skb_queue_purge(&st_gdata->tx_waitq); in st_core_exit()
913 kfree_skb(st_gdata->rx_skb); in st_core_exit()
914 kfree_skb(st_gdata->tx_skb); in st_core_exit()
920 kfree(st_gdata); in st_core_exit()