| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Shared Transport Line discipline driver Core |
|---|
| 3 | 4 | * This hooks up ST KIM driver and ST LL driver |
|---|
| 4 | 5 | * Copyright (C) 2009-2010 Texas Instruments |
|---|
| 5 | 6 | * 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 | | - * |
|---|
| 20 | 7 | */ |
|---|
| 21 | 8 | |
|---|
| 22 | 9 | #define pr_fmt(fmt) "(stc): " fmt |
|---|
| .. | .. |
|---|
| 31 | 18 | |
|---|
| 32 | 19 | extern void st_kim_recv(void *, const unsigned char *, long); |
|---|
| 33 | 20 | void st_int_recv(void *, const unsigned char *, long); |
|---|
| 34 | | -/* function pointer pointing to either, |
|---|
| 21 | +/* |
|---|
| 22 | + * function pointer pointing to either, |
|---|
| 35 | 23 | * st_kim_recv during registration to receive fw download responses |
|---|
| 36 | 24 | * st_int_recv after registration to receive proto stack responses |
|---|
| 37 | 25 | */ |
|---|
| .. | .. |
|---|
| 73 | 61 | return tty->ops->write_room(tty); |
|---|
| 74 | 62 | } |
|---|
| 75 | 63 | |
|---|
| 76 | | -/* can be called in from |
|---|
| 64 | +/* |
|---|
| 65 | + * can be called in from |
|---|
| 77 | 66 | * -- KIM (during fw download) |
|---|
| 78 | 67 | * -- ST Core (during st_write) |
|---|
| 79 | 68 | * |
|---|
| .. | .. |
|---|
| 113 | 102 | kfree_skb(st_gdata->rx_skb); |
|---|
| 114 | 103 | return; |
|---|
| 115 | 104 | } |
|---|
| 116 | | - /* this cannot fail |
|---|
| 105 | + /* |
|---|
| 106 | + * this cannot fail |
|---|
| 117 | 107 | * this shouldn't take long |
|---|
| 118 | 108 | * - should be just skb_queue_tail for the |
|---|
| 119 | 109 | * protocol stack driver |
|---|
| .. | .. |
|---|
| 134 | 124 | return; |
|---|
| 135 | 125 | } |
|---|
| 136 | 126 | |
|---|
| 137 | | -/** |
|---|
| 138 | | - * st_reg_complete - |
|---|
| 139 | | - * to call registration complete callbacks |
|---|
| 127 | +/* |
|---|
| 128 | + * st_reg_complete - to call registration complete callbacks |
|---|
| 140 | 129 | * of all protocol stack drivers |
|---|
| 141 | 130 | * This function is being called with spin lock held, protocol drivers are |
|---|
| 142 | 131 | * only expected to complete their waits and do nothing more than that. |
|---|
| .. | .. |
|---|
| 169 | 158 | pr_debug("len %d room %d", len, room); |
|---|
| 170 | 159 | |
|---|
| 171 | 160 | if (!len) { |
|---|
| 172 | | - /* Received packet has only packet header and |
|---|
| 161 | + /* |
|---|
| 162 | + * Received packet has only packet header and |
|---|
| 173 | 163 | * has zero length payload. So, ask ST CORE to |
|---|
| 174 | 164 | * forward the packet to protocol driver (BT/FM/GPS) |
|---|
| 175 | 165 | */ |
|---|
| 176 | 166 | st_send_frame(chnl_id, st_gdata); |
|---|
| 177 | 167 | |
|---|
| 178 | 168 | } else if (len > room) { |
|---|
| 179 | | - /* Received packet's payload length is larger. |
|---|
| 169 | + /* |
|---|
| 170 | + * Received packet's payload length is larger. |
|---|
| 180 | 171 | * We can't accommodate it in created skb. |
|---|
| 181 | 172 | */ |
|---|
| 182 | 173 | pr_err("Data length is too large len %d room %d", len, |
|---|
| 183 | 174 | room); |
|---|
| 184 | 175 | kfree_skb(st_gdata->rx_skb); |
|---|
| 185 | 176 | } else { |
|---|
| 186 | | - /* Packet header has non-zero payload length and |
|---|
| 177 | + /* |
|---|
| 178 | + * Packet header has non-zero payload length and |
|---|
| 187 | 179 | * we have enough space in created skb. Lets read |
|---|
| 188 | 180 | * payload data */ |
|---|
| 189 | 181 | st_gdata->rx_state = ST_W4_DATA; |
|---|
| .. | .. |
|---|
| 191 | 183 | return len; |
|---|
| 192 | 184 | } |
|---|
| 193 | 185 | |
|---|
| 194 | | - /* Change ST state to continue to process next |
|---|
| 195 | | - * packet */ |
|---|
| 186 | + /* Change ST state to continue to process next packet */ |
|---|
| 196 | 187 | st_gdata->rx_state = ST_W4_PACKET_TYPE; |
|---|
| 197 | 188 | st_gdata->rx_skb = NULL; |
|---|
| 198 | 189 | st_gdata->rx_count = 0; |
|---|
| .. | .. |
|---|
| 201 | 192 | return 0; |
|---|
| 202 | 193 | } |
|---|
| 203 | 194 | |
|---|
| 204 | | -/** |
|---|
| 195 | +/* |
|---|
| 205 | 196 | * st_wakeup_ack - internal function for action when wake-up ack |
|---|
| 206 | 197 | * received |
|---|
| 207 | 198 | */ |
|---|
| .. | .. |
|---|
| 212 | 203 | unsigned long flags = 0; |
|---|
| 213 | 204 | |
|---|
| 214 | 205 | 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 |
|---|
| 216 | 208 | * chip is awake |
|---|
| 217 | 209 | */ |
|---|
| 218 | 210 | while ((waiting_skb = skb_dequeue(&st_gdata->tx_waitq))) |
|---|
| .. | .. |
|---|
| 226 | 218 | st_tx_wakeup(st_gdata); |
|---|
| 227 | 219 | } |
|---|
| 228 | 220 | |
|---|
| 229 | | -/** |
|---|
| 221 | +/* |
|---|
| 230 | 222 | * st_int_recv - ST's internal receive function. |
|---|
| 231 | 223 | * Decodes received RAW data and forwards to corresponding |
|---|
| 232 | 224 | * client drivers (Bluetooth,FM,GPS..etc). |
|---|
| .. | .. |
|---|
| 275 | 267 | /* Waiting for complete packet ? */ |
|---|
| 276 | 268 | case ST_W4_DATA: |
|---|
| 277 | 269 | 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 | + */ |
|---|
| 280 | 274 | st_send_frame(st_gdata->rx_chnl, st_gdata); |
|---|
| 281 | 275 | |
|---|
| 282 | 276 | st_gdata->rx_state = ST_W4_PACKET_TYPE; |
|---|
| .. | .. |
|---|
| 289 | 283 | &st_gdata->rx_skb->data |
|---|
| 290 | 284 | [proto->offset_len_in_hdr]; |
|---|
| 291 | 285 | 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 */ |
|---|
| 293 | 287 | payload_len = *(unsigned char *)plen; |
|---|
| 294 | 288 | else if (proto->len_size == 2) |
|---|
| 295 | 289 | payload_len = |
|---|
| .. | .. |
|---|
| 307 | 301 | } |
|---|
| 308 | 302 | |
|---|
| 309 | 303 | /* 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 | + */ |
|---|
| 312 | 309 | switch (*ptr) { |
|---|
| 313 | 310 | case LL_SLEEP_IND: |
|---|
| 314 | 311 | case LL_SLEEP_ACK: |
|---|
| 315 | 312 | case LL_WAKE_UP_IND: |
|---|
| 316 | 313 | pr_debug("PM packet"); |
|---|
| 317 | | - /* this takes appropriate action based on |
|---|
| 314 | + /* |
|---|
| 315 | + * this takes appropriate action based on |
|---|
| 318 | 316 | * sleep state received -- |
|---|
| 319 | 317 | */ |
|---|
| 320 | 318 | 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 |
|---|
| 322 | 321 | * and assume chip awake |
|---|
| 323 | 322 | */ |
|---|
| 324 | 323 | spin_unlock_irqrestore(&st_gdata->lock, flags); |
|---|
| .. | .. |
|---|
| 344 | 343 | default: |
|---|
| 345 | 344 | type = *ptr; |
|---|
| 346 | 345 | |
|---|
| 347 | | - /* Default case means non-HCILL packets, |
|---|
| 346 | + /* |
|---|
| 347 | + * Default case means non-HCILL packets, |
|---|
| 348 | 348 | * possibilities are packets for: |
|---|
| 349 | 349 | * (a) valid protocol - Supported Protocols within |
|---|
| 350 | 350 | * the ST_MAX_CHANNELS. |
|---|
| .. | .. |
|---|
| 390 | 390 | return; |
|---|
| 391 | 391 | } |
|---|
| 392 | 392 | |
|---|
| 393 | | -/** |
|---|
| 393 | +/* |
|---|
| 394 | 394 | * st_int_dequeue - internal de-Q function. |
|---|
| 395 | 395 | * If the previous data set was not written |
|---|
| 396 | 396 | * completely, return that skb which has the pending data. |
|---|
| .. | .. |
|---|
| 409 | 409 | return skb_dequeue(&st_gdata->txq); |
|---|
| 410 | 410 | } |
|---|
| 411 | 411 | |
|---|
| 412 | | -/** |
|---|
| 412 | +/* |
|---|
| 413 | 413 | * st_int_enqueue - internal Q-ing function. |
|---|
| 414 | 414 | * Will either Q the skb to txq or the tx_waitq |
|---|
| 415 | 415 | * depending on the ST LL state. |
|---|
| .. | .. |
|---|
| 574 | 574 | /* release lock previously held - re-locked below */ |
|---|
| 575 | 575 | spin_unlock_irqrestore(&st_gdata->lock, flags); |
|---|
| 576 | 576 | |
|---|
| 577 | | - /* this may take a while to complete |
|---|
| 577 | + /* |
|---|
| 578 | + * this may take a while to complete |
|---|
| 578 | 579 | * since it involves BT fw download |
|---|
| 579 | 580 | */ |
|---|
| 580 | 581 | err = st_kim_start(st_gdata->kim_data); |
|---|
| .. | .. |
|---|
| 596 | 597 | clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); |
|---|
| 597 | 598 | st_recv = st_int_recv; |
|---|
| 598 | 599 | |
|---|
| 599 | | - /* this is where all pending registration |
|---|
| 600 | + /* |
|---|
| 601 | + * this is where all pending registration |
|---|
| 600 | 602 | * are signalled to be complete by calling callback functions |
|---|
| 601 | 603 | */ |
|---|
| 602 | 604 | if ((st_gdata->protos_registered != ST_EMPTY) && |
|---|
| .. | .. |
|---|
| 606 | 608 | } |
|---|
| 607 | 609 | clear_bit(ST_REG_PENDING, &st_gdata->st_state); |
|---|
| 608 | 610 | |
|---|
| 609 | | - /* check for already registered once more, |
|---|
| 611 | + /* |
|---|
| 612 | + * check for already registered once more, |
|---|
| 610 | 613 | * since the above check is old |
|---|
| 611 | 614 | */ |
|---|
| 612 | 615 | if (st_gdata->is_registered[new_proto->chnl_id] == true) { |
|---|
| .. | .. |
|---|
| 635 | 638 | } |
|---|
| 636 | 639 | EXPORT_SYMBOL_GPL(st_register); |
|---|
| 637 | 640 | |
|---|
| 638 | | -/* to unregister a protocol - |
|---|
| 641 | +/* |
|---|
| 642 | + * to unregister a protocol - |
|---|
| 639 | 643 | * to be called from protocol stack driver |
|---|
| 640 | 644 | */ |
|---|
| 641 | 645 | long st_unregister(struct st_proto_s *proto) |
|---|
| .. | .. |
|---|
| 721 | 725 | */ |
|---|
| 722 | 726 | static int st_tty_open(struct tty_struct *tty) |
|---|
| 723 | 727 | { |
|---|
| 724 | | - int err = 0; |
|---|
| 725 | 728 | struct st_data_s *st_gdata; |
|---|
| 726 | 729 | pr_info("%s ", __func__); |
|---|
| 727 | 730 | |
|---|
| .. | .. |
|---|
| 744 | 747 | */ |
|---|
| 745 | 748 | st_kim_complete(st_gdata->kim_data); |
|---|
| 746 | 749 | pr_debug("done %s", __func__); |
|---|
| 747 | | - return err; |
|---|
| 750 | + |
|---|
| 751 | + return 0; |
|---|
| 748 | 752 | } |
|---|
| 749 | 753 | |
|---|
| 750 | 754 | static void st_tty_close(struct tty_struct *tty) |
|---|
| 751 | 755 | { |
|---|
| 752 | | - unsigned char i = ST_MAX_CHANNELS; |
|---|
| 753 | | - unsigned long flags = 0; |
|---|
| 756 | + unsigned char i; |
|---|
| 757 | + unsigned long flags; |
|---|
| 754 | 758 | struct st_data_s *st_gdata = tty->disc_data; |
|---|
| 755 | 759 | |
|---|
| 756 | 760 | pr_info("%s ", __func__); |
|---|
| 757 | 761 | |
|---|
| 758 | | - /* TODO: |
|---|
| 762 | + /* |
|---|
| 763 | + * TODO: |
|---|
| 759 | 764 | * if a protocol has been registered & line discipline |
|---|
| 760 | 765 | * un-installed for some reason - what should be done ? |
|---|
| 761 | 766 | */ |
|---|
| .. | .. |
|---|
| 808 | 813 | pr_debug("done %s", __func__); |
|---|
| 809 | 814 | } |
|---|
| 810 | 815 | |
|---|
| 811 | | -/* wake-up function called in from the TTY layer |
|---|
| 816 | +/* |
|---|
| 817 | + * wake-up function called in from the TTY layer |
|---|
| 812 | 818 | * inside the internal wakeup function will be called |
|---|
| 813 | 819 | */ |
|---|
| 814 | 820 | static void st_tty_wakeup(struct tty_struct *tty) |
|---|