hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/misc/ti-st/st_core.c
....@@ -1,22 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Shared Transport Line discipline driver Core
34 * This hooks up ST KIM driver and ST LL driver
45 * Copyright (C) 2009-2010 Texas Instruments
56 * Author: Pavan Savoy <pavan_savoy@ti.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
- *
207 */
218
229 #define pr_fmt(fmt) "(stc): " fmt
....@@ -31,7 +18,8 @@
3118
3219 extern void st_kim_recv(void *, const unsigned char *, long);
3320 void st_int_recv(void *, const unsigned char *, long);
34
-/* function pointer pointing to either,
21
+/*
22
+ * function pointer pointing to either,
3523 * st_kim_recv during registration to receive fw download responses
3624 * st_int_recv after registration to receive proto stack responses
3725 */
....@@ -73,7 +61,8 @@
7361 return tty->ops->write_room(tty);
7462 }
7563
76
-/* can be called in from
64
+/*
65
+ * can be called in from
7766 * -- KIM (during fw download)
7867 * -- ST Core (during st_write)
7968 *
....@@ -113,7 +102,8 @@
113102 kfree_skb(st_gdata->rx_skb);
114103 return;
115104 }
116
- /* this cannot fail
105
+ /*
106
+ * this cannot fail
117107 * this shouldn't take long
118108 * - should be just skb_queue_tail for the
119109 * protocol stack driver
....@@ -134,9 +124,8 @@
134124 return;
135125 }
136126
137
-/**
138
- * st_reg_complete -
139
- * to call registration complete callbacks
127
+/*
128
+ * st_reg_complete - to call registration complete callbacks
140129 * of all protocol stack drivers
141130 * This function is being called with spin lock held, protocol drivers are
142131 * only expected to complete their waits and do nothing more than that.
....@@ -169,21 +158,24 @@
169158 pr_debug("len %d room %d", len, room);
170159
171160 if (!len) {
172
- /* Received packet has only packet header and
161
+ /*
162
+ * Received packet has only packet header and
173163 * has zero length payload. So, ask ST CORE to
174164 * forward the packet to protocol driver (BT/FM/GPS)
175165 */
176166 st_send_frame(chnl_id, st_gdata);
177167
178168 } else if (len > room) {
179
- /* Received packet's payload length is larger.
169
+ /*
170
+ * Received packet's payload length is larger.
180171 * We can't accommodate it in created skb.
181172 */
182173 pr_err("Data length is too large len %d room %d", len,
183174 room);
184175 kfree_skb(st_gdata->rx_skb);
185176 } else {
186
- /* Packet header has non-zero payload length and
177
+ /*
178
+ * Packet header has non-zero payload length and
187179 * we have enough space in created skb. Lets read
188180 * payload data */
189181 st_gdata->rx_state = ST_W4_DATA;
....@@ -191,8 +183,7 @@
191183 return len;
192184 }
193185
194
- /* Change ST state to continue to process next
195
- * packet */
186
+ /* Change ST state to continue to process next packet */
196187 st_gdata->rx_state = ST_W4_PACKET_TYPE;
197188 st_gdata->rx_skb = NULL;
198189 st_gdata->rx_count = 0;
....@@ -201,7 +192,7 @@
201192 return 0;
202193 }
203194
204
-/**
195
+/*
205196 * st_wakeup_ack - internal function for action when wake-up ack
206197 * received
207198 */
....@@ -212,7 +203,8 @@
212203 unsigned long flags = 0;
213204
214205 spin_lock_irqsave(&st_gdata->lock, flags);
215
- /* de-Q from waitQ and Q in txQ now that the
206
+ /*
207
+ * de-Q from waitQ and Q in txQ now that the
216208 * chip is awake
217209 */
218210 while ((waiting_skb = skb_dequeue(&st_gdata->tx_waitq)))
....@@ -226,7 +218,7 @@
226218 st_tx_wakeup(st_gdata);
227219 }
228220
229
-/**
221
+/*
230222 * st_int_recv - ST's internal receive function.
231223 * Decodes received RAW data and forwards to corresponding
232224 * client drivers (Bluetooth,FM,GPS..etc).
....@@ -275,8 +267,10 @@
275267 /* Waiting for complete packet ? */
276268 case ST_W4_DATA:
277269 pr_debug("Complete pkt received");
278
- /* Ask ST CORE to forward
279
- * the packet to protocol driver */
270
+ /*
271
+ * Ask ST CORE to forward
272
+ * the packet to protocol driver
273
+ */
280274 st_send_frame(st_gdata->rx_chnl, st_gdata);
281275
282276 st_gdata->rx_state = ST_W4_PACKET_TYPE;
....@@ -289,7 +283,7 @@
289283 &st_gdata->rx_skb->data
290284 [proto->offset_len_in_hdr];
291285 pr_debug("plen pointing to %x\n", *plen);
292
- if (proto->len_size == 1)/* 1 byte len field */
286
+ if (proto->len_size == 1) /* 1 byte len field */
293287 payload_len = *(unsigned char *)plen;
294288 else if (proto->len_size == 2)
295289 payload_len =
....@@ -307,18 +301,23 @@
307301 }
308302
309303 /* end of if rx_count */
310
- /* Check first byte of packet and identify module
311
- * owner (BT/FM/GPS) */
304
+
305
+ /*
306
+ * Check first byte of packet and identify module
307
+ * owner (BT/FM/GPS)
308
+ */
312309 switch (*ptr) {
313310 case LL_SLEEP_IND:
314311 case LL_SLEEP_ACK:
315312 case LL_WAKE_UP_IND:
316313 pr_debug("PM packet");
317
- /* this takes appropriate action based on
314
+ /*
315
+ * this takes appropriate action based on
318316 * sleep state received --
319317 */
320318 st_ll_sleep_state(st_gdata, *ptr);
321
- /* if WAKEUP_IND collides copy from waitq to txq
319
+ /*
320
+ * if WAKEUP_IND collides copy from waitq to txq
322321 * and assume chip awake
323322 */
324323 spin_unlock_irqrestore(&st_gdata->lock, flags);
....@@ -344,7 +343,8 @@
344343 default:
345344 type = *ptr;
346345
347
- /* Default case means non-HCILL packets,
346
+ /*
347
+ * Default case means non-HCILL packets,
348348 * possibilities are packets for:
349349 * (a) valid protocol - Supported Protocols within
350350 * the ST_MAX_CHANNELS.
....@@ -390,7 +390,7 @@
390390 return;
391391 }
392392
393
-/**
393
+/*
394394 * st_int_dequeue - internal de-Q function.
395395 * If the previous data set was not written
396396 * completely, return that skb which has the pending data.
....@@ -409,7 +409,7 @@
409409 return skb_dequeue(&st_gdata->txq);
410410 }
411411
412
-/**
412
+/*
413413 * st_int_enqueue - internal Q-ing function.
414414 * Will either Q the skb to txq or the tx_waitq
415415 * depending on the ST LL state.
....@@ -574,7 +574,8 @@
574574 /* release lock previously held - re-locked below */
575575 spin_unlock_irqrestore(&st_gdata->lock, flags);
576576
577
- /* this may take a while to complete
577
+ /*
578
+ * this may take a while to complete
578579 * since it involves BT fw download
579580 */
580581 err = st_kim_start(st_gdata->kim_data);
....@@ -596,7 +597,8 @@
596597 clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
597598 st_recv = st_int_recv;
598599
599
- /* this is where all pending registration
600
+ /*
601
+ * this is where all pending registration
600602 * are signalled to be complete by calling callback functions
601603 */
602604 if ((st_gdata->protos_registered != ST_EMPTY) &&
....@@ -606,7 +608,8 @@
606608 }
607609 clear_bit(ST_REG_PENDING, &st_gdata->st_state);
608610
609
- /* check for already registered once more,
611
+ /*
612
+ * check for already registered once more,
610613 * since the above check is old
611614 */
612615 if (st_gdata->is_registered[new_proto->chnl_id] == true) {
....@@ -635,7 +638,8 @@
635638 }
636639 EXPORT_SYMBOL_GPL(st_register);
637640
638
-/* to unregister a protocol -
641
+/*
642
+ * to unregister a protocol -
639643 * to be called from protocol stack driver
640644 */
641645 long st_unregister(struct st_proto_s *proto)
....@@ -721,7 +725,6 @@
721725 */
722726 static int st_tty_open(struct tty_struct *tty)
723727 {
724
- int err = 0;
725728 struct st_data_s *st_gdata;
726729 pr_info("%s ", __func__);
727730
....@@ -744,18 +747,20 @@
744747 */
745748 st_kim_complete(st_gdata->kim_data);
746749 pr_debug("done %s", __func__);
747
- return err;
750
+
751
+ return 0;
748752 }
749753
750754 static void st_tty_close(struct tty_struct *tty)
751755 {
752
- unsigned char i = ST_MAX_CHANNELS;
753
- unsigned long flags = 0;
756
+ unsigned char i;
757
+ unsigned long flags;
754758 struct st_data_s *st_gdata = tty->disc_data;
755759
756760 pr_info("%s ", __func__);
757761
758
- /* TODO:
762
+ /*
763
+ * TODO:
759764 * if a protocol has been registered & line discipline
760765 * un-installed for some reason - what should be done ?
761766 */
....@@ -808,7 +813,8 @@
808813 pr_debug("done %s", __func__);
809814 }
810815
811
-/* wake-up function called in from the TTY layer
816
+/*
817
+ * wake-up function called in from the TTY layer
812818 * inside the internal wakeup function will be called
813819 */
814820 static void st_tty_wakeup(struct tty_struct *tty)