1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#define pr_fmt(fmt) "(stc): " fmt
23#include <linux/module.h>
24#include <linux/kernel.h>
25#include <linux/init.h>
26#include <linux/tty.h>
27
28#include <linux/seq_file.h>
29#include <linux/skbuff.h>
30
31#include <linux/ti_wilink_st.h>
32
33
34
35
36
37void (*st_recv) (void*, const unsigned char*, long);
38
39
40static void add_channel_to_table(struct st_data_s *st_gdata,
41 struct st_proto_s *new_proto)
42{
43 pr_info("%s: id %d\n", __func__, new_proto->chnl_id);
44
45 st_gdata->list[new_proto->chnl_id] = new_proto;
46 st_gdata->is_registered[new_proto->chnl_id] = true;
47}
48
49static void remove_channel_from_table(struct st_data_s *st_gdata,
50 struct st_proto_s *proto)
51{
52 pr_info("%s: id %d\n", __func__, proto->chnl_id);
53
54 st_gdata->is_registered[proto->chnl_id] = false;
55}
56
57
58
59
60
61
62
63
64int st_get_uart_wr_room(struct st_data_s *st_gdata)
65{
66 struct tty_struct *tty;
67 if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) {
68 pr_err("tty unavailable to perform write");
69 return -1;
70 }
71 tty = st_gdata->tty;
72 return tty->ops->write_room(tty);
73}
74
75
76
77
78
79
80
81
82int st_int_write(struct st_data_s *st_gdata,
83 const unsigned char *data, int count)
84{
85 struct tty_struct *tty;
86 if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) {
87 pr_err("tty unavailable to perform write");
88 return -EINVAL;
89 }
90 tty = st_gdata->tty;
91#ifdef VERBOSE
92 print_hex_dump(KERN_DEBUG, "<out<", DUMP_PREFIX_NONE,
93 16, 1, data, count, 0);
94#endif
95 return tty->ops->write(tty, data, count);
96
97}
98
99
100
101
102
103void st_send_frame(unsigned char chnl_id, struct st_data_s *st_gdata)
104{
105 pr_debug(" %s(prot:%d) ", __func__, chnl_id);
106
107 if (unlikely
108 (st_gdata == NULL || st_gdata->rx_skb == NULL
109 || st_gdata->is_registered[chnl_id] == false)) {
110 pr_err("chnl_id %d not registered, no data to send?",
111 chnl_id);
112 kfree_skb(st_gdata->rx_skb);
113 return;
114 }
115
116
117
118
119
120 if (likely(st_gdata->list[chnl_id]->recv != NULL)) {
121 if (unlikely
122 (st_gdata->list[chnl_id]->recv
123 (st_gdata->list[chnl_id]->priv_data, st_gdata->rx_skb)
124 != 0)) {
125 pr_err(" proto stack %d's ->recv failed", chnl_id);
126 kfree_skb(st_gdata->rx_skb);
127 return;
128 }
129 } else {
130 pr_err(" proto stack %d's ->recv null", chnl_id);
131 kfree_skb(st_gdata->rx_skb);
132 }
133 return;
134}
135
136
137
138
139
140
141
142
143void st_reg_complete(struct st_data_s *st_gdata, char err)
144{
145 unsigned char i = 0;
146 pr_info(" %s ", __func__);
147 for (i = 0; i < ST_MAX_CHANNELS; i++) {
148 if (likely(st_gdata != NULL &&
149 st_gdata->is_registered[i] == true &&
150 st_gdata->list[i]->reg_complete_cb != NULL)) {
151 st_gdata->list[i]->reg_complete_cb
152 (st_gdata->list[i]->priv_data, err);
153 pr_info("protocol %d's cb sent %d\n", i, err);
154 if (err) {
155 st_gdata->protos_registered--;
156 st_gdata->is_registered[i] = false;
157 }
158 }
159 }
160}
161
162static inline int st_check_data_len(struct st_data_s *st_gdata,
163 unsigned char chnl_id, int len)
164{
165 int room = skb_tailroom(st_gdata->rx_skb);
166
167 pr_debug("len %d room %d", len, room);
168
169 if (!len) {
170
171
172
173
174 st_send_frame(chnl_id, st_gdata);
175
176 } else if (len > room) {
177
178
179
180 pr_err("Data length is too large len %d room %d", len,
181 room);
182 kfree_skb(st_gdata->rx_skb);
183 } else {
184
185
186
187 st_gdata->rx_state = ST_W4_DATA;
188 st_gdata->rx_count = len;
189 return len;
190 }
191
192
193
194 st_gdata->rx_state = ST_W4_PACKET_TYPE;
195 st_gdata->rx_skb = NULL;
196 st_gdata->rx_count = 0;
197 st_gdata->rx_chnl = 0;
198
199 return 0;
200}
201
202
203
204
205
206static inline void st_wakeup_ack(struct st_data_s *st_gdata,
207 unsigned char cmd)
208{
209 struct sk_buff *waiting_skb;
210 unsigned long flags = 0;
211
212 spin_lock_irqsave(&st_gdata->lock, flags);
213
214
215
216 while ((waiting_skb = skb_dequeue(&st_gdata->tx_waitq)))
217 skb_queue_tail(&st_gdata->txq, waiting_skb);
218
219
220 st_ll_sleep_state(st_gdata, (unsigned long)cmd);
221 spin_unlock_irqrestore(&st_gdata->lock, flags);
222
223
224 st_tx_wakeup(st_gdata);
225}
226
227
228
229
230
231
232
233
234
235void st_int_recv(void *disc_data,
236 const unsigned char *data, long count)
237{
238 char *ptr;
239 struct st_proto_s *proto;
240 unsigned short payload_len = 0;
241 int len = 0, type = 0;
242 unsigned char *plen;
243 struct st_data_s *st_gdata = (struct st_data_s *)disc_data;
244 unsigned long flags;
245
246 ptr = (char *)data;
247
248 if (unlikely(ptr == NULL) || (st_gdata == NULL)) {
249 pr_err(" received null from TTY ");
250 return;
251 }
252
253 pr_debug("count %ld rx_state %ld"
254 "rx_count %ld", count, st_gdata->rx_state,
255 st_gdata->rx_count);
256
257 spin_lock_irqsave(&st_gdata->lock, flags);
258
259 while (count) {
260 if (st_gdata->rx_count) {
261 len = min_t(unsigned int, st_gdata->rx_count, count);
262 memcpy(skb_put(st_gdata->rx_skb, len), ptr, len);
263 st_gdata->rx_count -= len;
264 count -= len;
265 ptr += len;
266
267 if (st_gdata->rx_count)
268 continue;
269
270
271 switch (st_gdata->rx_state) {
272
273 case ST_W4_DATA:
274 pr_debug("Complete pkt received");
275
276
277 st_send_frame(st_gdata->rx_chnl, st_gdata);
278
279 st_gdata->rx_state = ST_W4_PACKET_TYPE;
280 st_gdata->rx_skb = NULL;
281 continue;
282
283 case ST_W4_HEADER:
284 proto = st_gdata->list[st_gdata->rx_chnl];
285 plen =
286 &st_gdata->rx_skb->data
287 [proto->offset_len_in_hdr];
288 pr_debug("plen pointing to %x\n", *plen);
289 if (proto->len_size == 1)
290 payload_len = *(unsigned char *)plen;
291 else if (proto->len_size == 2)
292 payload_len =
293 __le16_to_cpu(*(unsigned short *)plen);
294 else
295 pr_info("%s: invalid length "
296 "for id %d\n",
297 __func__, proto->chnl_id);
298 st_check_data_len(st_gdata, proto->chnl_id,
299 payload_len);
300 pr_debug("off %d, pay len %d\n",
301 proto->offset_len_in_hdr, payload_len);
302 continue;
303 }
304 }
305
306
307
308
309 switch (*ptr) {
310 case LL_SLEEP_IND:
311 case LL_SLEEP_ACK:
312 case LL_WAKE_UP_IND:
313 pr_debug("PM packet");
314
315
316
317 st_ll_sleep_state(st_gdata, *ptr);
318
319
320
321 spin_unlock_irqrestore(&st_gdata->lock, flags);
322 if (st_ll_getstate(st_gdata) == ST_LL_AWAKE)
323 st_wakeup_ack(st_gdata, LL_WAKE_UP_ACK);
324 spin_lock_irqsave(&st_gdata->lock, flags);
325
326 ptr++;
327 count--;
328 continue;
329 case LL_WAKE_UP_ACK:
330 pr_debug("PM packet");
331
332 spin_unlock_irqrestore(&st_gdata->lock, flags);
333
334 st_wakeup_ack(st_gdata, *ptr);
335 spin_lock_irqsave(&st_gdata->lock, flags);
336
337 ptr++;
338 count--;
339 continue;
340
341 default:
342 type = *ptr;
343 if (st_gdata->list[type] == NULL) {
344 pr_err("chip/interface misbehavior dropping"
345 " frame starting with 0x%02x", type);
346 goto done;
347
348 }
349 st_gdata->rx_skb = alloc_skb(
350 st_gdata->list[type]->max_frame_size,
351 GFP_ATOMIC);
352 skb_reserve(st_gdata->rx_skb,
353 st_gdata->list[type]->reserve);
354
355 st_gdata->rx_skb->cb[0] = type;
356 st_gdata->rx_skb->cb[1] = 0;
357 st_gdata->rx_chnl = *ptr;
358 st_gdata->rx_state = ST_W4_HEADER;
359 st_gdata->rx_count = st_gdata->list[type]->hdr_len;
360 pr_debug("rx_count %ld\n", st_gdata->rx_count);
361 };
362 ptr++;
363 count--;
364 }
365done:
366 spin_unlock_irqrestore(&st_gdata->lock, flags);
367 pr_debug("done %s", __func__);
368 return;
369}
370
371
372
373
374
375
376
377struct sk_buff *st_int_dequeue(struct st_data_s *st_gdata)
378{
379 struct sk_buff *returning_skb;
380
381 pr_debug("%s", __func__);
382 if (st_gdata->tx_skb != NULL) {
383 returning_skb = st_gdata->tx_skb;
384 st_gdata->tx_skb = NULL;
385 return returning_skb;
386 }
387 return skb_dequeue(&st_gdata->txq);
388}
389
390
391
392
393
394
395
396
397
398
399void st_int_enqueue(struct st_data_s *st_gdata, struct sk_buff *skb)
400{
401 unsigned long flags = 0;
402
403 pr_debug("%s", __func__);
404 spin_lock_irqsave(&st_gdata->lock, flags);
405
406 switch (st_ll_getstate(st_gdata)) {
407 case ST_LL_AWAKE:
408 pr_debug("ST LL is AWAKE, sending normally");
409 skb_queue_tail(&st_gdata->txq, skb);
410 break;
411 case ST_LL_ASLEEP_TO_AWAKE:
412 skb_queue_tail(&st_gdata->tx_waitq, skb);
413 break;
414 case ST_LL_AWAKE_TO_ASLEEP:
415 pr_err("ST LL is illegal state(%ld),"
416 "purging received skb.", st_ll_getstate(st_gdata));
417 kfree_skb(skb);
418 break;
419 case ST_LL_ASLEEP:
420 skb_queue_tail(&st_gdata->tx_waitq, skb);
421 st_ll_wakeup(st_gdata);
422 break;
423 default:
424 pr_err("ST LL is illegal state(%ld),"
425 "purging received skb.", st_ll_getstate(st_gdata));
426 kfree_skb(skb);
427 break;
428 }
429
430 spin_unlock_irqrestore(&st_gdata->lock, flags);
431 pr_debug("done %s", __func__);
432 return;
433}
434
435
436
437
438
439
440
441void st_tx_wakeup(struct st_data_s *st_data)
442{
443 struct sk_buff *skb;
444 unsigned long flags;
445 pr_debug("%s", __func__);
446
447 if (test_and_set_bit(ST_TX_SENDING, &st_data->tx_state)) {
448 pr_debug("ST already sending");
449
450 set_bit(ST_TX_WAKEUP, &st_data->tx_state);
451 return;
452
453
454
455 }
456 do {
457
458 clear_bit(ST_TX_WAKEUP, &st_data->tx_state);
459 while ((skb = st_int_dequeue(st_data))) {
460 int len;
461 spin_lock_irqsave(&st_data->lock, flags);
462
463 set_bit(TTY_DO_WRITE_WAKEUP, &st_data->tty->flags);
464 len = st_int_write(st_data, skb->data, skb->len);
465 skb_pull(skb, len);
466
467 if (skb->len) {
468
469 st_data->tx_skb = skb;
470 spin_unlock_irqrestore(&st_data->lock, flags);
471 break;
472 }
473 kfree_skb(skb);
474 spin_unlock_irqrestore(&st_data->lock, flags);
475 }
476
477 } while (test_bit(ST_TX_WAKEUP, &st_data->tx_state));
478
479
480 clear_bit(ST_TX_SENDING, &st_data->tx_state);
481}
482
483
484
485
486void kim_st_list_protocols(struct st_data_s *st_gdata, void *buf)
487{
488 seq_printf(buf, "[%d]\nBT=%c\nFM=%c\nGPS=%c\n",
489 st_gdata->protos_registered,
490 st_gdata->is_registered[0x04] == true ? 'R' : 'U',
491 st_gdata->is_registered[0x08] == true ? 'R' : 'U',
492 st_gdata->is_registered[0x09] == true ? 'R' : 'U');
493}
494
495
496
497
498
499
500long st_register(struct st_proto_s *new_proto)
501{
502 struct st_data_s *st_gdata;
503 long err = 0;
504 unsigned long flags = 0;
505
506 st_kim_ref(&st_gdata, 0);
507 pr_info("%s(%d) ", __func__, new_proto->chnl_id);
508 if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL
509 || new_proto->reg_complete_cb == NULL) {
510 pr_err("gdata/new_proto/recv or reg_complete_cb not ready");
511 return -EINVAL;
512 }
513
514 if (new_proto->chnl_id >= ST_MAX_CHANNELS) {
515 pr_err("chnl_id %d not supported", new_proto->chnl_id);
516 return -EPROTONOSUPPORT;
517 }
518
519 if (st_gdata->is_registered[new_proto->chnl_id] == true) {
520 pr_err("chnl_id %d already registered", new_proto->chnl_id);
521 return -EALREADY;
522 }
523
524
525 spin_lock_irqsave(&st_gdata->lock, flags);
526
527 if (test_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state)) {
528 pr_info(" ST_REG_IN_PROGRESS:%d ", new_proto->chnl_id);
529
530
531 add_channel_to_table(st_gdata, new_proto);
532 st_gdata->protos_registered++;
533 new_proto->write = st_write;
534
535 set_bit(ST_REG_PENDING, &st_gdata->st_state);
536 spin_unlock_irqrestore(&st_gdata->lock, flags);
537 return -EINPROGRESS;
538 } else if (st_gdata->protos_registered == ST_EMPTY) {
539 pr_info(" chnl_id list empty :%d ", new_proto->chnl_id);
540 set_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
541 st_recv = st_kim_recv;
542
543
544 st_ll_enable(st_gdata);
545
546
547 spin_unlock_irqrestore(&st_gdata->lock, flags);
548
549
550
551
552 err = st_kim_start(st_gdata->kim_data);
553 if (err != 0) {
554 clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
555 if ((st_gdata->protos_registered != ST_EMPTY) &&
556 (test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
557 pr_err(" KIM failure complete callback ");
558 st_reg_complete(st_gdata, err);
559 clear_bit(ST_REG_PENDING, &st_gdata->st_state);
560 }
561 return -EINVAL;
562 }
563
564 spin_lock_irqsave(&st_gdata->lock, flags);
565
566 clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
567 st_recv = st_int_recv;
568
569
570
571
572 if ((st_gdata->protos_registered != ST_EMPTY) &&
573 (test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
574 pr_debug(" call reg complete callback ");
575 st_reg_complete(st_gdata, 0);
576 }
577 clear_bit(ST_REG_PENDING, &st_gdata->st_state);
578
579
580
581
582 if (st_gdata->is_registered[new_proto->chnl_id] == true) {
583 pr_err(" proto %d already registered ",
584 new_proto->chnl_id);
585 spin_unlock_irqrestore(&st_gdata->lock, flags);
586 return -EALREADY;
587 }
588
589 add_channel_to_table(st_gdata, new_proto);
590 st_gdata->protos_registered++;
591 new_proto->write = st_write;
592 spin_unlock_irqrestore(&st_gdata->lock, flags);
593 return err;
594 }
595
596 else {
597 add_channel_to_table(st_gdata, new_proto);
598 st_gdata->protos_registered++;
599 new_proto->write = st_write;
600
601
602 spin_unlock_irqrestore(&st_gdata->lock, flags);
603 return err;
604 }
605 pr_debug("done %s(%d) ", __func__, new_proto->chnl_id);
606}
607EXPORT_SYMBOL_GPL(st_register);
608
609
610
611
612long st_unregister(struct st_proto_s *proto)
613{
614 long err = 0;
615 unsigned long flags = 0;
616 struct st_data_s *st_gdata;
617
618 pr_debug("%s: %d ", __func__, proto->chnl_id);
619
620 st_kim_ref(&st_gdata, 0);
621 if (!st_gdata || proto->chnl_id >= ST_MAX_CHANNELS) {
622 pr_err(" chnl_id %d not supported", proto->chnl_id);
623 return -EPROTONOSUPPORT;
624 }
625
626 spin_lock_irqsave(&st_gdata->lock, flags);
627
628 if (st_gdata->is_registered[proto->chnl_id] == false) {
629 pr_err(" chnl_id %d not registered", proto->chnl_id);
630 spin_unlock_irqrestore(&st_gdata->lock, flags);
631 return -EPROTONOSUPPORT;
632 }
633
634 st_gdata->protos_registered--;
635 remove_channel_from_table(st_gdata, proto);
636 spin_unlock_irqrestore(&st_gdata->lock, flags);
637
638
639 if (st_gdata->protos_registered < ST_EMPTY)
640 st_gdata->protos_registered = ST_EMPTY;
641
642 if ((st_gdata->protos_registered == ST_EMPTY) &&
643 (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
644 pr_info(" all chnl_ids unregistered ");
645
646
647 if (st_gdata->tty) {
648 tty_ldisc_flush(st_gdata->tty);
649 stop_tty(st_gdata->tty);
650 }
651
652
653 st_kim_stop(st_gdata->kim_data);
654
655 st_ll_disable(st_gdata);
656 }
657 return err;
658}
659
660
661
662
663
664long st_write(struct sk_buff *skb)
665{
666 struct st_data_s *st_gdata;
667 long len;
668
669 st_kim_ref(&st_gdata, 0);
670 if (unlikely(skb == NULL || st_gdata == NULL
671 || st_gdata->tty == NULL)) {
672 pr_err("data/tty unavailable to perform write");
673 return -EINVAL;
674 }
675
676 pr_debug("%d to be written", skb->len);
677 len = skb->len;
678
679
680 st_int_enqueue(st_gdata, skb);
681
682 st_tx_wakeup(st_gdata);
683
684
685 return len;
686}
687
688
689EXPORT_SYMBOL_GPL(st_unregister);
690
691
692
693
694
695static int st_tty_open(struct tty_struct *tty)
696{
697 int err = 0;
698 struct st_data_s *st_gdata;
699 pr_info("%s ", __func__);
700
701 st_kim_ref(&st_gdata, 0);
702 st_gdata->tty = tty;
703 tty->disc_data = st_gdata;
704
705
706 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
707
708
709
710 tty->receive_room = 65536;
711
712 tty_ldisc_flush(tty);
713 tty_driver_flush_buffer(tty);
714
715
716
717
718 st_kim_complete(st_gdata->kim_data);
719 pr_debug("done %s", __func__);
720 return err;
721}
722
723static void st_tty_close(struct tty_struct *tty)
724{
725 unsigned char i = ST_MAX_CHANNELS;
726 unsigned long flags = 0;
727 struct st_data_s *st_gdata = tty->disc_data;
728
729 pr_info("%s ", __func__);
730
731
732
733
734
735 spin_lock_irqsave(&st_gdata->lock, flags);
736 for (i = ST_BT; i < ST_MAX_CHANNELS; i++) {
737 if (st_gdata->is_registered[i] == true)
738 pr_err("%d not un-registered", i);
739 st_gdata->list[i] = NULL;
740 st_gdata->is_registered[i] = false;
741 }
742 st_gdata->protos_registered = 0;
743 spin_unlock_irqrestore(&st_gdata->lock, flags);
744
745
746
747
748 st_kim_complete(st_gdata->kim_data);
749 st_gdata->tty = NULL;
750
751 tty_ldisc_flush(tty);
752 tty_driver_flush_buffer(tty);
753
754 spin_lock_irqsave(&st_gdata->lock, flags);
755
756 skb_queue_purge(&st_gdata->txq);
757 skb_queue_purge(&st_gdata->tx_waitq);
758
759 st_gdata->rx_count = 0;
760 st_gdata->rx_state = ST_W4_PACKET_TYPE;
761 kfree_skb(st_gdata->rx_skb);
762 st_gdata->rx_skb = NULL;
763 spin_unlock_irqrestore(&st_gdata->lock, flags);
764
765 pr_debug("%s: done ", __func__);
766}
767
768static void st_tty_receive(struct tty_struct *tty, const unsigned char *data,
769 char *tty_flags, int count)
770{
771#ifdef VERBOSE
772 print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE,
773 16, 1, data, count, 0);
774#endif
775
776
777
778
779
780 st_recv(tty->disc_data, data, count);
781 pr_debug("done %s", __func__);
782}
783
784
785
786
787static void st_tty_wakeup(struct tty_struct *tty)
788{
789 struct st_data_s *st_gdata = tty->disc_data;
790 pr_debug("%s ", __func__);
791
792 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
793
794
795 st_tx_wakeup((void *)st_gdata);
796}
797
798static void st_tty_flush_buffer(struct tty_struct *tty)
799{
800 struct st_data_s *st_gdata = tty->disc_data;
801 pr_debug("%s ", __func__);
802
803 kfree_skb(st_gdata->tx_skb);
804 st_gdata->tx_skb = NULL;
805
806 tty->ops->flush_buffer(tty);
807 return;
808}
809
810static struct tty_ldisc_ops st_ldisc_ops = {
811 .magic = TTY_LDISC_MAGIC,
812 .name = "n_st",
813 .open = st_tty_open,
814 .close = st_tty_close,
815 .receive_buf = st_tty_receive,
816 .write_wakeup = st_tty_wakeup,
817 .flush_buffer = st_tty_flush_buffer,
818 .owner = THIS_MODULE
819};
820
821
822int st_core_init(struct st_data_s **core_data)
823{
824 struct st_data_s *st_gdata;
825 long err;
826
827 err = tty_register_ldisc(N_TI_WL, &st_ldisc_ops);
828 if (err) {
829 pr_err("error registering %d line discipline %ld",
830 N_TI_WL, err);
831 return err;
832 }
833 pr_debug("registered n_shared line discipline");
834
835 st_gdata = kzalloc(sizeof(struct st_data_s), GFP_KERNEL);
836 if (!st_gdata) {
837 pr_err("memory allocation failed");
838 err = tty_unregister_ldisc(N_TI_WL);
839 if (err)
840 pr_err("unable to un-register ldisc %ld", err);
841 err = -ENOMEM;
842 return err;
843 }
844
845
846
847
848 skb_queue_head_init(&st_gdata->txq);
849 skb_queue_head_init(&st_gdata->tx_waitq);
850
851
852 spin_lock_init(&st_gdata->lock);
853
854 err = st_ll_init(st_gdata);
855 if (err) {
856 pr_err("error during st_ll initialization(%ld)", err);
857 kfree(st_gdata);
858 err = tty_unregister_ldisc(N_TI_WL);
859 if (err)
860 pr_err("unable to un-register ldisc");
861 return err;
862 }
863 *core_data = st_gdata;
864 return 0;
865}
866
867void st_core_exit(struct st_data_s *st_gdata)
868{
869 long err;
870
871 err = st_ll_deinit(st_gdata);
872 if (err)
873 pr_err("error during deinit of ST LL %ld", err);
874
875 if (st_gdata != NULL) {
876
877 skb_queue_purge(&st_gdata->txq);
878 skb_queue_purge(&st_gdata->tx_waitq);
879 kfree_skb(st_gdata->rx_skb);
880 kfree_skb(st_gdata->tx_skb);
881
882 err = tty_unregister_ldisc(N_TI_WL);
883 if (err)
884 pr_err("unable to un-register ldisc %ld", err);
885
886 kfree(st_gdata);
887 }
888}
889
890
891