Lines Matching defs:st_gdata
65 int st_int_write(struct st_data_s *st_gdata,
69 if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) {
73 tty = st_gdata->tty;
86 void st_send_frame(enum proto_type protoid, struct st_data_s *st_gdata)
91 (st_gdata == NULL || st_gdata->rx_skb == NULL
92 || st_gdata->list[protoid] == NULL)) {
95 kfree_skb(st_gdata->rx_skb);
103 if (likely(st_gdata->list[protoid]->recv != NULL)) {
105 (st_gdata->list[protoid]->recv
106 (st_gdata->list[protoid]->priv_data, st_gdata->rx_skb)
109 kfree_skb(st_gdata->rx_skb);
114 kfree_skb(st_gdata->rx_skb);
124 void st_reg_complete(struct st_data_s *st_gdata, char err)
129 if (likely(st_gdata != NULL && st_gdata->list[i] != NULL &&
130 st_gdata->list[i]->reg_complete_cb != NULL))
131 st_gdata->list[i]->reg_complete_cb
132 (st_gdata->list[i]->priv_data, err);
136 static inline int st_check_data_len(struct st_data_s *st_gdata,
139 register int room = skb_tailroom(st_gdata->rx_skb);
148 st_send_frame(protoid, st_gdata);
156 kfree_skb(st_gdata->rx_skb);
161 st_gdata->rx_state = ST_BT_W4_DATA;
162 st_gdata->rx_count = len;
168 st_gdata->rx_state = ST_W4_PACKET_TYPE;
169 st_gdata->rx_skb = NULL;
170 st_gdata->rx_count = 0;
179 static inline void st_wakeup_ack(struct st_data_s *st_gdata,
185 spin_lock_irqsave(&st_gdata->lock, flags);
189 while ((waiting_skb = skb_dequeue(&st_gdata->tx_waitq)))
190 skb_queue_tail(&st_gdata->txq, waiting_skb);
193 st_ll_sleep_state(st_gdata, (unsigned long)cmd);
194 spin_unlock_irqrestore(&st_gdata->lock, flags);
197 st_tx_wakeup(st_gdata);
219 struct st_data_s *st_gdata = (struct st_data_s *)disc_data;
223 if (unlikely(ptr == NULL) || (st_gdata == NULL)) {
229 "rx_count %ld", count, st_gdata->rx_state,
230 st_gdata->rx_count);
234 if (st_gdata->rx_count) {
235 len = min_t(unsigned int, st_gdata->rx_count, count);
236 memcpy(skb_put(st_gdata->rx_skb, len), ptr, len);
237 st_gdata->rx_count -= len;
241 if (st_gdata->rx_count)
245 switch (st_gdata->rx_state) {
253 st_send_frame(protoid, st_gdata);
255 st_gdata->rx_state = ST_W4_PACKET_TYPE;
256 st_gdata->rx_skb = NULL;
262 eh = (struct hci_event_hdr *)st_gdata->rx_skb->
268 st_check_data_len(st_gdata, protoid, eh->plen);
273 ah = (struct hci_acl_hdr *)st_gdata->rx_skb->
279 st_check_data_len(st_gdata, protoid, dlen);
284 sh = (struct hci_sco_hdr *)st_gdata->rx_skb->
289 st_check_data_len(st_gdata, protoid, sh->dlen);
292 fm = (struct fm_event_hdr *)st_gdata->rx_skb->
295 st_check_data_len(st_gdata, ST_FM, fm->plen);
300 gps = (struct gps_event_hdr *)st_gdata->rx_skb->
303 st_check_data_len(st_gdata, ST_GPS, gps->plen);
316 st_gdata->rx_state = ST_BT_W4_EVENT_HDR;
317 st_gdata->rx_count = HCI_EVENT_HDR_SIZE;
325 st_gdata->rx_state = ST_BT_W4_ACL_HDR;
326 st_gdata->rx_count = HCI_ACL_HDR_SIZE;
334 st_gdata->rx_state = ST_BT_W4_SCO_HDR;
335 st_gdata->rx_count = HCI_SCO_HDR_SIZE;
344 st_gdata->rx_state = ST_FM_W4_EVENT_HDR;
345 st_gdata->rx_count = FM_EVENT_HDR_SIZE;
354 st_gdata->rx_state = ST_GPS_W4_EVENT_HDR;
355 st_gdata->rx_count = 3; /* GPS_EVENT_HDR_SIZE -1*/
364 st_ll_sleep_state(st_gdata, *ptr);
371 st_wakeup_ack(st_gdata, *ptr);
388 st_gdata->rx_skb =
390 if (!st_gdata->rx_skb) {
392 st_gdata->rx_state = ST_W4_PACKET_TYPE;
393 st_gdata->rx_count = 0;
396 bt_cb(st_gdata->rx_skb)->pkt_type = type;
399 st_gdata->rx_skb =
401 if (!st_gdata->rx_skb) {
403 st_gdata->rx_state = ST_W4_PACKET_TYPE;
404 st_gdata->rx_count = 0;
408 skb_reserve(st_gdata->rx_skb, 1);
409 st_gdata->rx_skb->cb[0] = ST_FM_CH8_PKT;
413 st_gdata->rx_skb =
415 if (!st_gdata->rx_skb) {
417 st_gdata->rx_state = ST_W4_PACKET_TYPE;
418 st_gdata->rx_count = 0;
422 skb_reserve(st_gdata->rx_skb, 1);
423 st_gdata->rx_skb->cb[0] = 0x09; /*ST_GPS_CH9_PKT; */
439 struct sk_buff *st_int_dequeue(struct st_data_s *st_gdata)
444 if (st_gdata->tx_skb != NULL) {
445 returning_skb = st_gdata->tx_skb;
446 st_gdata->tx_skb = NULL;
449 return skb_dequeue(&st_gdata->txq);
461 void st_int_enqueue(struct st_data_s *st_gdata, struct sk_buff *skb)
466 spin_lock_irqsave(&st_gdata->lock, flags);
468 switch (st_ll_getstate(st_gdata)) {
471 skb_queue_tail(&st_gdata->txq, skb);
474 skb_queue_tail(&st_gdata->tx_waitq, skb);
478 "purging received skb.", st_ll_getstate(st_gdata));
482 skb_queue_tail(&st_gdata->tx_waitq, skb);
483 st_ll_wakeup(st_gdata);
487 "purging received skb.", st_ll_getstate(st_gdata));
492 spin_unlock_irqrestore(&st_gdata->lock, flags);
548 void kim_st_list_protocols(struct st_data_s *st_gdata, void *buf)
551 st_gdata->protos_registered,
552 st_gdata->list[ST_BT] != NULL ? 'R' : 'U',
553 st_gdata->list[ST_FM] != NULL ? 'R' : 'U',
554 st_gdata->list[ST_GPS] != NULL ? 'R' : 'U');
564 struct st_data_s *st_gdata;
568 st_kim_ref(&st_gdata, 0);
570 if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL
581 if (st_gdata->list[new_proto->type] != NULL) {
587 spin_lock_irqsave(&st_gdata->lock, flags);
589 if (test_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state)) {
594 st_gdata->list[new_proto->type] = new_proto;
595 st_gdata->protos_registered++;
598 set_bit(ST_REG_PENDING, &st_gdata->st_state);
599 spin_unlock_irqrestore(&st_gdata->lock, flags);
601 } else if (st_gdata->protos_registered == ST_EMPTY) {
603 set_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
607 spin_unlock_irqrestore(&st_gdata->lock, flags);
610 st_ll_enable(st_gdata);
614 err = st_kim_start(st_gdata->kim_data);
616 clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
617 if ((st_gdata->protos_registered != ST_EMPTY) &&
618 (test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
620 st_reg_complete(st_gdata, -1);
630 clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
636 if ((st_gdata->protos_registered != ST_EMPTY) &&
637 (test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
639 st_reg_complete(st_gdata, 0);
641 clear_bit(ST_REG_PENDING, &st_gdata->st_state);
646 if (st_gdata->list[new_proto->type] != NULL) {
652 spin_lock_irqsave(&st_gdata->lock, flags);
653 st_gdata->list[new_proto->type] = new_proto;
654 st_gdata->protos_registered++;
656 spin_unlock_irqrestore(&st_gdata->lock, flags);
677 st_gdata->list[new_proto->type] = new_proto;
678 st_gdata->protos_registered++;
682 spin_unlock_irqrestore(&st_gdata->lock, flags);
696 struct st_data_s *st_gdata;
700 st_kim_ref(&st_gdata, 0);
706 spin_lock_irqsave(&st_gdata->lock, flags);
708 if (st_gdata->list[type] == NULL) {
710 spin_unlock_irqrestore(&st_gdata->lock, flags);
714 st_gdata->protos_registered--;
715 st_gdata->list[type] = NULL;
722 spin_unlock_irqrestore(&st_gdata->lock, flags);
724 if ((st_gdata->protos_registered == ST_EMPTY) &&
725 (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
729 if (st_gdata->tty) {
730 tty_ldisc_flush(st_gdata->tty);
731 stop_tty(st_gdata->tty);
735 st_kim_stop(st_gdata->kim_data);
737 st_ll_disable(st_gdata);
748 struct st_data_s *st_gdata;
754 st_kim_ref(&st_gdata, 0);
755 if (unlikely(skb == NULL || st_gdata == NULL
756 || st_gdata->tty == NULL)) {
774 if (unlikely(st_gdata->list[protoid] == NULL)) {
784 st_int_enqueue(st_gdata, skb);
786 st_tx_wakeup(st_gdata);
802 struct st_data_s *st_gdata;
805 st_kim_ref(&st_gdata, 0);
806 st_gdata->tty = tty;
807 tty->disc_data = st_gdata;
822 st_kim_complete(st_gdata->kim_data);
831 struct st_data_s *st_gdata = tty->disc_data;
839 spin_lock_irqsave(&st_gdata->lock, flags);
841 if (st_gdata->list[i] != NULL)
843 st_gdata->list[i] = NULL;
845 st_gdata->protos_registered = 0;
846 spin_unlock_irqrestore(&st_gdata->lock, flags);
851 st_kim_complete(st_gdata->kim_data);
852 st_gdata->tty = NULL;
857 spin_lock_irqsave(&st_gdata->lock, flags);
859 skb_queue_purge(&st_gdata->txq);
860 skb_queue_purge(&st_gdata->tx_waitq);
862 st_gdata->rx_count = 0;
863 st_gdata->rx_state = ST_W4_PACKET_TYPE;
864 kfree_skb(st_gdata->rx_skb);
865 st_gdata->rx_skb = NULL;
866 spin_unlock_irqrestore(&st_gdata->lock, flags);
893 struct st_data_s *st_gdata = tty->disc_data;
899 st_tx_wakeup((void *)st_gdata);
904 struct st_data_s *st_gdata = tty->disc_data;
907 kfree_skb(st_gdata->tx_skb);
908 st_gdata->tx_skb = NULL;
917 struct st_data_s *st_gdata;
946 st_gdata = kzalloc(sizeof(struct st_data_s), GFP_KERNEL);
947 if (!st_gdata) {
960 skb_queue_head_init(&st_gdata->txq);
961 skb_queue_head_init(&st_gdata->tx_waitq);
964 spin_lock_init(&st_gdata->lock);
967 st_gdata->ldisc_ops = st_ldisc_ops;
970 err = st_ll_init(st_gdata);
973 kfree(st_gdata);
980 *core_data = st_gdata;
984 void st_core_exit(struct st_data_s *st_gdata)
988 err = st_ll_deinit(st_gdata);
991 if (st_gdata != NULL) {
993 skb_queue_purge(&st_gdata->txq);
994 skb_queue_purge(&st_gdata->tx_waitq);
995 kfree_skb(st_gdata->rx_skb);
996 kfree_skb(st_gdata->tx_skb);
1001 kfree(st_gdata->ldisc_ops);
1003 kfree(st_gdata);