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