Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 1 | /* Serial communications layer, based on HDLC */ |
| 2 | |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 3 | /* (C) 2010,2017 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 4 | * |
| 5 | * All Rights Reserved |
| 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 as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include <stdint.h> |
| 24 | #include <stdio.h> |
| 25 | #include <errno.h> |
| 26 | |
| 27 | #include <osmocom/core/msgb.h> |
| 28 | |
| 29 | #ifdef HOST_BUILD |
| 30 | |
| 31 | # define SERCOMM_RX_MSG_SIZE 2048 |
| 32 | # ifndef ARRAY_SIZE |
| 33 | # define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) |
| 34 | # endif |
| 35 | # include <sercomm.h> |
| 36 | |
| 37 | static inline void sercomm_lock(unsigned long __attribute__((unused)) *flags) {} |
| 38 | static inline void sercomm_unlock(unsigned long __attribute__((unused)) *flags) {} |
| 39 | |
| 40 | #else |
| 41 | |
| 42 | # define SERCOMM_RX_MSG_SIZE 256 |
| 43 | # include <debug.h> |
| 44 | # include <osmocom/core/linuxlist.h> |
| 45 | # include <asm/system.h> |
| 46 | |
| 47 | static inline void sercomm_lock(unsigned long *flags) |
| 48 | { |
| 49 | local_firq_save(*flags); |
| 50 | } |
| 51 | |
| 52 | static inline void sercomm_unlock(unsigned long *flags) |
| 53 | { |
| 54 | local_irq_restore(*flags); |
| 55 | } |
| 56 | |
| 57 | # include <comm/sercomm.h> |
| 58 | # include <uart.h> |
| 59 | |
| 60 | #endif |
| 61 | |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 62 | enum rx_state { |
| 63 | RX_ST_WAIT_START, |
| 64 | RX_ST_ADDR, |
| 65 | RX_ST_CTRL, |
| 66 | RX_ST_DATA, |
| 67 | RX_ST_ESCAPE, |
| 68 | }; |
| 69 | |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 70 | |
| 71 | #ifndef HOST_BUILD |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 72 | void sercomm_bind_uart(struct sercomm_inst *sercomm, int uart) |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 73 | { |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 74 | sercomm->uart_id = uart; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 75 | } |
| 76 | |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 77 | int sercomm_get_uart(struct sercomm_inst *sercomm) |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 78 | { |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 79 | return sercomm->uart_id; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 80 | } |
| 81 | #endif |
| 82 | |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 83 | void sercomm_init(struct sercomm_inst *sercomm) |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 84 | { |
| 85 | unsigned int i; |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 86 | for (i = 0; i < ARRAY_SIZE(sercomm->tx.dlci_queues); i++) |
| 87 | INIT_LLIST_HEAD(&sercomm->tx.dlci_queues[i]); |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 88 | |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 89 | sercomm->rx.msg = NULL; |
| 90 | sercomm->initialized = 1; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 91 | |
| 92 | /* set up the echo dlci */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 93 | sercomm_register_rx_cb(sercomm, SC_DLCI_ECHO, &sercomm_sendmsg); |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 94 | } |
| 95 | |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 96 | int sercomm_initialized(struct sercomm_inst *sercomm) |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 97 | { |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 98 | return sercomm->initialized; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | /* user interface for transmitting messages for a given DLCI */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 102 | void sercomm_sendmsg(struct sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg) |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 103 | { |
| 104 | unsigned long flags; |
| 105 | uint8_t *hdr; |
| 106 | |
| 107 | /* prepend address + control octet */ |
| 108 | hdr = msgb_push(msg, 2); |
| 109 | hdr[0] = dlci; |
| 110 | hdr[1] = HDLC_C_UI; |
| 111 | |
| 112 | /* This functiion can be called from any context: FIQ, IRQ |
| 113 | * and supervisor context. Proper locking is important! */ |
| 114 | sercomm_lock(&flags); |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 115 | msgb_enqueue(&sercomm->tx.dlci_queues[dlci], msg); |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 116 | sercomm_unlock(&flags); |
| 117 | |
| 118 | #ifndef HOST_BUILD |
| 119 | /* tell UART that we have something to send */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 120 | uart_irq_enable(sercomm->uart_id, UART_IRQ_TX_EMPTY, 1); |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 121 | #endif |
| 122 | } |
| 123 | |
| 124 | /* how deep is the Tx queue for a given DLCI */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 125 | unsigned int sercomm_tx_queue_depth(struct sercomm_inst *sercomm, uint8_t dlci) |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 126 | { |
| 127 | struct llist_head *le; |
| 128 | unsigned int num = 0; |
| 129 | |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 130 | llist_for_each(le, &sercomm->tx.dlci_queues[dlci]) { |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 131 | num++; |
| 132 | } |
| 133 | |
| 134 | return num; |
| 135 | } |
| 136 | |
| 137 | #ifndef HOST_BUILD |
| 138 | /* wait until everything has been transmitted, then grab the lock and |
| 139 | * change the baud rate as requested */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 140 | void sercomm_change_speed(struct sercomm_inst *sercomm, enum uart_baudrate bdrt) |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 141 | { |
| 142 | unsigned int i, count; |
| 143 | unsigned long flags; |
| 144 | |
| 145 | while (1) { |
| 146 | /* count the number of pending messages */ |
| 147 | count = 0; |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 148 | for (i = 0; i < ARRAY_SIZE(sercomm->tx.dlci_queues); i++) |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 149 | count += sercomm_tx_queue_depth(i); |
| 150 | /* if we still have any in the queue, restart */ |
| 151 | if (count == 0) |
| 152 | break; |
| 153 | } |
| 154 | |
| 155 | while (1) { |
| 156 | /* no messages in the queue, grab the lock to ensure it |
| 157 | * stays that way */ |
| 158 | sercomm_lock(&flags); |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 159 | if (!sercomm->tx.msg && !sercomm->tx.next_char) { |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 160 | /* change speed */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 161 | uart_baudrate(sercomm->uart_id, bdrt); |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 162 | sercomm_unlock(&flags); |
| 163 | break; |
| 164 | } |
| 165 | sercomm_unlock(&flags); |
| 166 | } |
| 167 | } |
| 168 | #endif |
| 169 | |
| 170 | /* fetch one octet of to-be-transmitted serial data */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 171 | int sercomm_drv_pull(struct sercomm_inst *sercomm, uint8_t *ch) |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 172 | { |
| 173 | unsigned long flags; |
| 174 | |
| 175 | /* we may be called from interrupt context, but we stiff need to lock |
| 176 | * because sercomm could be accessed from a FIQ context ... */ |
| 177 | |
| 178 | sercomm_lock(&flags); |
| 179 | |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 180 | if (!sercomm->tx.msg) { |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 181 | unsigned int i; |
| 182 | /* dequeue a new message from the queues */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 183 | for (i = 0; i < ARRAY_SIZE(sercomm->tx.dlci_queues); i++) { |
| 184 | sercomm->tx.msg = msgb_dequeue(&sercomm->tx.dlci_queues[i]); |
| 185 | if (sercomm->tx.msg) |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 186 | break; |
| 187 | } |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 188 | if (sercomm->tx.msg) { |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 189 | /* start of a new message, send start flag octet */ |
| 190 | *ch = HDLC_FLAG; |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 191 | sercomm->tx.next_char = sercomm->tx.msg->data; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 192 | sercomm_unlock(&flags); |
| 193 | return 1; |
| 194 | } else { |
| 195 | /* no more data avilable */ |
| 196 | sercomm_unlock(&flags); |
| 197 | return 0; |
| 198 | } |
| 199 | } |
| 200 | |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 201 | if (sercomm->tx.state == RX_ST_ESCAPE) { |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 202 | /* we've already transmitted the ESCAPE octet, |
| 203 | * we now need to transmit the escaped data */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 204 | *ch = *sercomm->tx.next_char++; |
| 205 | sercomm->tx.state = RX_ST_DATA; |
| 206 | } else if (sercomm->tx.next_char >= sercomm->tx.msg->tail) { |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 207 | /* last character has already been transmitted, |
| 208 | * send end-of-message octet */ |
| 209 | *ch = HDLC_FLAG; |
| 210 | /* we've reached the end of the message buffer */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 211 | msgb_free(sercomm->tx.msg); |
| 212 | sercomm->tx.msg = NULL; |
| 213 | sercomm->tx.next_char = NULL; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 214 | /* escaping for the two control octets */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 215 | } else if (*sercomm->tx.next_char == HDLC_FLAG || |
| 216 | *sercomm->tx.next_char == HDLC_ESCAPE || |
| 217 | *sercomm->tx.next_char == 0x00) { |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 218 | /* send an escape octet */ |
| 219 | *ch = HDLC_ESCAPE; |
| 220 | /* invert bit 5 of the next octet to be sent */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 221 | *sercomm->tx.next_char ^= (1 << 5); |
| 222 | sercomm->tx.state = RX_ST_ESCAPE; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 223 | } else { |
| 224 | /* standard case, simply send next octet */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 225 | *ch = *sercomm->tx.next_char++; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | sercomm_unlock(&flags); |
| 229 | return 1; |
| 230 | } |
| 231 | |
| 232 | /* register a handler for a given DLCI */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 233 | int sercomm_register_rx_cb(struct sercomm_inst *sercomm, uint8_t dlci, dlci_cb_t cb) |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 234 | { |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 235 | if (dlci >= ARRAY_SIZE(sercomm->rx.dlci_handler)) |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 236 | return -EINVAL; |
| 237 | |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 238 | if (sercomm->rx.dlci_handler[dlci]) |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 239 | return -EBUSY; |
| 240 | |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 241 | sercomm->rx.dlci_handler[dlci] = cb; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | /* dispatch an incoming message once it is completely received */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 246 | static void dispatch_rx_msg(struct sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg) |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 247 | { |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 248 | if (dlci >= ARRAY_SIZE(sercomm->rx.dlci_handler) || |
| 249 | !sercomm->rx.dlci_handler[dlci]) { |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 250 | msgb_free(msg); |
| 251 | return; |
| 252 | } |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 253 | sercomm->rx.dlci_handler[dlci](sercomm, dlci, msg); |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | /* the driver has received one byte, pass it into sercomm layer */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 257 | int sercomm_drv_rx_char(struct sercomm_inst *sercomm, uint8_t ch) |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 258 | { |
| 259 | uint8_t *ptr; |
| 260 | |
| 261 | /* we are always called from interrupt context in this function, |
| 262 | * which means that any data structures we use need to be for |
| 263 | * our exclusive access */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 264 | if (!sercomm->rx.msg) |
| 265 | sercomm->rx.msg = sercomm_alloc_msgb(SERCOMM_RX_MSG_SIZE); |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 266 | |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 267 | if (msgb_tailroom(sercomm->rx.msg) == 0) { |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 268 | //cons_puts("sercomm_drv_rx_char() overflow!\n"); |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 269 | msgb_free(sercomm->rx.msg); |
| 270 | sercomm->rx.msg = sercomm_alloc_msgb(SERCOMM_RX_MSG_SIZE); |
| 271 | sercomm->rx.state = RX_ST_WAIT_START; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 272 | return 0; |
| 273 | } |
| 274 | |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 275 | switch (sercomm->rx.state) { |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 276 | case RX_ST_WAIT_START: |
| 277 | if (ch != HDLC_FLAG) |
| 278 | break; |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 279 | sercomm->rx.state = RX_ST_ADDR; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 280 | break; |
| 281 | case RX_ST_ADDR: |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 282 | sercomm->rx.dlci = ch; |
| 283 | sercomm->rx.state = RX_ST_CTRL; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 284 | break; |
| 285 | case RX_ST_CTRL: |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 286 | sercomm->rx.ctrl = ch; |
| 287 | sercomm->rx.state = RX_ST_DATA; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 288 | break; |
| 289 | case RX_ST_DATA: |
| 290 | if (ch == HDLC_ESCAPE) { |
| 291 | /* drop the escape octet, but change state */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 292 | sercomm->rx.state = RX_ST_ESCAPE; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 293 | break; |
| 294 | } else if (ch == HDLC_FLAG) { |
| 295 | /* message is finished */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 296 | dispatch_rx_msg(sercomm, sercomm->rx.dlci, sercomm->rx.msg); |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 297 | /* allocate new buffer */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 298 | sercomm->rx.msg = NULL; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 299 | /* start all over again */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 300 | sercomm->rx.state = RX_ST_WAIT_START; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 301 | |
| 302 | /* do not add the control char */ |
| 303 | break; |
| 304 | } |
| 305 | /* default case: store the octet */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 306 | ptr = msgb_put(sercomm->rx.msg, 1); |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 307 | *ptr = ch; |
| 308 | break; |
| 309 | case RX_ST_ESCAPE: |
| 310 | /* store bif-5-inverted octet in buffer */ |
| 311 | ch ^= (1 << 5); |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 312 | ptr = msgb_put(sercomm->rx.msg, 1); |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 313 | *ptr = ch; |
| 314 | /* transition back to normal DATA state */ |
Harald Welte | cc95f4b | 2017-04-30 21:39:33 +0200 | [diff] [blame^] | 315 | sercomm->rx.state = RX_ST_DATA; |
Harald Welte | c68af6a | 2017-04-30 21:21:52 +0200 | [diff] [blame] | 316 | break; |
| 317 | } |
| 318 | |
| 319 | return 1; |
| 320 | } |