• Home
  • Raw
  • Download

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
56 if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) { in st_get_uart_wr_room()
61 return tty_write_room(st_gdata->tty); in st_get_uart_wr_room()
72 int st_int_write(struct st_data_s *st_gdata, in st_int_write() argument
76 if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) { in st_int_write()
80 tty = st_gdata->tty; in st_int_write()
93 static void st_send_frame(unsigned char chnl_id, struct st_data_s *st_gdata) in st_send_frame() argument
98 (st_gdata == NULL || st_gdata->rx_skb == NULL in st_send_frame()
99 || st_gdata->is_registered[chnl_id] == false)) { in st_send_frame()
102 kfree_skb(st_gdata->rx_skb); in st_send_frame()
111 if (likely(st_gdata->list[chnl_id]->recv != NULL)) { in st_send_frame()
113 (st_gdata->list[chnl_id]->recv in st_send_frame()
114 (st_gdata->list[chnl_id]->priv_data, st_gdata->rx_skb) in st_send_frame()
117 kfree_skb(st_gdata->rx_skb); in st_send_frame()
122 kfree_skb(st_gdata->rx_skb); in st_send_frame()
133 static void st_reg_complete(struct st_data_s *st_gdata, int err) in st_reg_complete() argument
138 if (likely(st_gdata != NULL && in st_reg_complete()
139 st_gdata->is_registered[i] == true && in st_reg_complete()
140 st_gdata->list[i]->reg_complete_cb != NULL)) { in st_reg_complete()
141 st_gdata->list[i]->reg_complete_cb in st_reg_complete()
142 (st_gdata->list[i]->priv_data, err); in st_reg_complete()
145 st_gdata->is_registered[i] = false; in st_reg_complete()
146 if (st_gdata->protos_registered) in st_reg_complete()
147 st_gdata->protos_registered--; in st_reg_complete()
153 static inline int st_check_data_len(struct st_data_s *st_gdata, in st_check_data_len() argument
156 int room = skb_tailroom(st_gdata->rx_skb); in st_check_data_len()
166 st_send_frame(chnl_id, st_gdata); in st_check_data_len()
175 kfree_skb(st_gdata->rx_skb); in st_check_data_len()
181 st_gdata->rx_state = ST_W4_DATA; in st_check_data_len()
182 st_gdata->rx_count = len; in st_check_data_len()
187 st_gdata->rx_state = ST_W4_PACKET_TYPE; in st_check_data_len()
188 st_gdata->rx_skb = NULL; in st_check_data_len()
189 st_gdata->rx_count = 0; in st_check_data_len()
190 st_gdata->rx_chnl = 0; in st_check_data_len()
199 static inline void st_wakeup_ack(struct st_data_s *st_gdata, in st_wakeup_ack() argument
205 spin_lock_irqsave(&st_gdata->lock, flags); in st_wakeup_ack()
210 while ((waiting_skb = skb_dequeue(&st_gdata->tx_waitq))) in st_wakeup_ack()
211 skb_queue_tail(&st_gdata->txq, waiting_skb); in st_wakeup_ack()
214 st_ll_sleep_state(st_gdata, (unsigned long)cmd); in st_wakeup_ack()
215 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_wakeup_ack()
218 st_tx_wakeup(st_gdata); in st_wakeup_ack()
238 struct st_data_s *st_gdata = (struct st_data_s *)disc_data; in st_int_recv() local
243 if (unlikely(ptr == NULL) || (st_gdata == NULL)) { in st_int_recv()
249 "rx_count %ld", count, st_gdata->rx_state, in st_int_recv()
250 st_gdata->rx_count); in st_int_recv()
252 spin_lock_irqsave(&st_gdata->lock, flags); in st_int_recv()
255 if (st_gdata->rx_count) { in st_int_recv()
256 len = min_t(unsigned int, st_gdata->rx_count, count); in st_int_recv()
257 skb_put_data(st_gdata->rx_skb, ptr, len); in st_int_recv()
258 st_gdata->rx_count -= len; in st_int_recv()
262 if (st_gdata->rx_count) in st_int_recv()
266 switch (st_gdata->rx_state) { in st_int_recv()
274 st_send_frame(st_gdata->rx_chnl, st_gdata); in st_int_recv()
276 st_gdata->rx_state = ST_W4_PACKET_TYPE; in st_int_recv()
277 st_gdata->rx_skb = NULL; in st_int_recv()
281 proto = st_gdata->list[st_gdata->rx_chnl]; in st_int_recv()
283 &st_gdata->rx_skb->data in st_int_recv()
295 st_check_data_len(st_gdata, proto->chnl_id, in st_int_recv()
318 st_ll_sleep_state(st_gdata, *ptr); in st_int_recv()
323 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_int_recv()
324 if (st_ll_getstate(st_gdata) == ST_LL_AWAKE) in st_int_recv()
325 st_wakeup_ack(st_gdata, LL_WAKE_UP_ACK); in st_int_recv()
326 spin_lock_irqsave(&st_gdata->lock, flags); in st_int_recv()
334 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_int_recv()
336 st_wakeup_ack(st_gdata, *ptr); in st_int_recv()
337 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()
581 err = st_kim_start(st_gdata->kim_data); in st_register()
583 clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); in st_register()
584 if ((st_gdata->protos_registered != ST_EMPTY) && in st_register()
585 (test_bit(ST_REG_PENDING, &st_gdata->st_state))) { in st_register()
587 spin_lock_irqsave(&st_gdata->lock, flags); in st_register()
588 st_reg_complete(st_gdata, err); in st_register()
589 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
590 clear_bit(ST_REG_PENDING, &st_gdata->st_state); in st_register()
595 spin_lock_irqsave(&st_gdata->lock, flags); in st_register()
597 clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); in st_register()
604 if ((st_gdata->protos_registered != ST_EMPTY) && in st_register()
605 (test_bit(ST_REG_PENDING, &st_gdata->st_state))) { in st_register()
607 st_reg_complete(st_gdata, 0); in st_register()
609 clear_bit(ST_REG_PENDING, &st_gdata->st_state); in st_register()
615 if (st_gdata->is_registered[new_proto->chnl_id] == true) { in st_register()
618 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
622 add_channel_to_table(st_gdata, new_proto); in st_register()
623 st_gdata->protos_registered++; in st_register()
625 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
630 add_channel_to_table(st_gdata, new_proto); in st_register()
631 st_gdata->protos_registered++; in st_register()
635 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_register()
649 struct st_data_s *st_gdata; in st_unregister() local
653 st_kim_ref(&st_gdata, 0); in st_unregister()
654 if (!st_gdata || proto->chnl_id >= ST_MAX_CHANNELS) { in st_unregister()
659 spin_lock_irqsave(&st_gdata->lock, flags); in st_unregister()
661 if (st_gdata->is_registered[proto->chnl_id] == false) { in st_unregister()
663 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_unregister()
667 if (st_gdata->protos_registered) in st_unregister()
668 st_gdata->protos_registered--; in st_unregister()
670 remove_channel_from_table(st_gdata, proto); in st_unregister()
671 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_unregister()
673 if ((st_gdata->protos_registered == ST_EMPTY) && in st_unregister()
674 (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) { in st_unregister()
678 if (st_gdata->tty) { in st_unregister()
679 tty_ldisc_flush(st_gdata->tty); in st_unregister()
680 stop_tty(st_gdata->tty); in st_unregister()
684 st_kim_stop(st_gdata->kim_data); in st_unregister()
686 st_ll_disable(st_gdata); in st_unregister()
697 struct st_data_s *st_gdata; in st_write() local
700 st_kim_ref(&st_gdata, 0); in st_write()
701 if (unlikely(skb == NULL || st_gdata == NULL in st_write()
702 || st_gdata->tty == NULL)) { in st_write()
711 st_int_enqueue(st_gdata, skb); in st_write()
713 st_tx_wakeup(st_gdata); in st_write()
728 struct st_data_s *st_gdata; in st_tty_open() local
731 st_kim_ref(&st_gdata, 0); in st_tty_open()
732 st_gdata->tty = tty; in st_tty_open()
733 tty->disc_data = st_gdata; in st_tty_open()
748 st_kim_complete(st_gdata->kim_data); in st_tty_open()
758 struct st_data_s *st_gdata = tty->disc_data; in st_tty_close() local
767 spin_lock_irqsave(&st_gdata->lock, flags); in st_tty_close()
769 if (st_gdata->is_registered[i] == true) in st_tty_close()
771 st_gdata->list[i] = NULL; in st_tty_close()
772 st_gdata->is_registered[i] = false; in st_tty_close()
774 st_gdata->protos_registered = 0; in st_tty_close()
775 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_tty_close()
780 st_kim_complete(st_gdata->kim_data); in st_tty_close()
781 st_gdata->tty = NULL; in st_tty_close()
786 spin_lock_irqsave(&st_gdata->lock, flags); in st_tty_close()
788 skb_queue_purge(&st_gdata->txq); in st_tty_close()
789 skb_queue_purge(&st_gdata->tx_waitq); in st_tty_close()
791 st_gdata->rx_count = 0; in st_tty_close()
792 st_gdata->rx_state = ST_W4_PACKET_TYPE; in st_tty_close()
793 kfree_skb(st_gdata->rx_skb); in st_tty_close()
794 st_gdata->rx_skb = NULL; in st_tty_close()
795 spin_unlock_irqrestore(&st_gdata->lock, flags); in st_tty_close()
822 struct st_data_s *st_gdata = tty->disc_data; in st_tty_wakeup() local
832 schedule_work(&st_gdata->work_write_wakeup); in st_tty_wakeup()
837 struct st_data_s *st_gdata = tty->disc_data; in st_tty_flush_buffer() local
840 kfree_skb(st_gdata->tx_skb); in st_tty_flush_buffer()
841 st_gdata->tx_skb = NULL; in st_tty_flush_buffer()
861 struct st_data_s *st_gdata; in st_core_init() local
872 st_gdata = kzalloc(sizeof(struct st_data_s), GFP_KERNEL); in st_core_init()
873 if (!st_gdata) { in st_core_init()
882 skb_queue_head_init(&st_gdata->txq); in st_core_init()
883 skb_queue_head_init(&st_gdata->tx_waitq); in st_core_init()
886 spin_lock_init(&st_gdata->lock); in st_core_init()
888 err = st_ll_init(st_gdata); in st_core_init()
894 INIT_WORK(&st_gdata->work_write_wakeup, work_fn_write_wakeup); in st_core_init()
896 *core_data = st_gdata; in st_core_init()
899 kfree(st_gdata); in st_core_init()
905 void st_core_exit(struct st_data_s *st_gdata) in st_core_exit() argument
909 err = st_ll_deinit(st_gdata); in st_core_exit()
913 if (st_gdata != NULL) { in st_core_exit()
915 skb_queue_purge(&st_gdata->txq); in st_core_exit()
916 skb_queue_purge(&st_gdata->tx_waitq); in st_core_exit()
917 kfree_skb(st_gdata->rx_skb); in st_core_exit()
918 kfree_skb(st_gdata->tx_skb); in st_core_exit()
922 kfree(st_gdata); in st_core_exit()