asyncdata.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /*
  2. * Common data handling layer for ser_gigaset and usb_gigaset
  3. *
  4. * Copyright (c) 2005 by Tilman Schmidt <tilman@imap.cc>,
  5. * Hansjoerg Lipp <hjlipp@web.de>,
  6. * Stefan Eilers.
  7. *
  8. * =====================================================================
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. * =====================================================================
  14. */
  15. #include "gigaset.h"
  16. #include <linux/crc-ccitt.h>
  17. #include <linux/bitrev.h>
  18. /* check if byte must be stuffed/escaped
  19. * I'm not sure which data should be encoded.
  20. * Therefore I will go the hard way and encode every value
  21. * less than 0x20, the flag sequence and the control escape char.
  22. */
  23. static inline int muststuff(unsigned char c)
  24. {
  25. if (c < PPP_TRANS) return 1;
  26. if (c == PPP_FLAG) return 1;
  27. if (c == PPP_ESCAPE) return 1;
  28. /* other possible candidates: */
  29. /* 0x91: XON with parity set */
  30. /* 0x93: XOFF with parity set */
  31. return 0;
  32. }
  33. /* == data input =========================================================== */
  34. /* process a block of received bytes in command mode
  35. * (mstate != MS_LOCKED && (inputstate & INS_command))
  36. * Append received bytes to the command response buffer and forward them
  37. * line by line to the response handler. Exit whenever a mode/state change
  38. * might have occurred.
  39. * Note: Received lines may be terminated by CR, LF, or CR LF, which will be
  40. * removed before passing the line to the response handler.
  41. * Return value:
  42. * number of processed bytes
  43. */
  44. static unsigned cmd_loop(unsigned numbytes, struct inbuf_t *inbuf)
  45. {
  46. unsigned char *src = inbuf->data + inbuf->head;
  47. struct cardstate *cs = inbuf->cs;
  48. unsigned cbytes = cs->cbytes;
  49. unsigned procbytes = 0;
  50. unsigned char c;
  51. while (procbytes < numbytes) {
  52. c = *src++;
  53. procbytes++;
  54. switch (c) {
  55. case '\n':
  56. if (cbytes == 0 && cs->respdata[0] == '\r') {
  57. /* collapse LF with preceding CR */
  58. cs->respdata[0] = 0;
  59. break;
  60. }
  61. /* --v-- fall through --v-- */
  62. case '\r':
  63. /* end of message line, pass to response handler */
  64. if (cbytes >= MAX_RESP_SIZE) {
  65. dev_warn(cs->dev, "response too large (%d)\n",
  66. cbytes);
  67. cbytes = MAX_RESP_SIZE;
  68. }
  69. cs->cbytes = cbytes;
  70. gigaset_dbg_buffer(DEBUG_TRANSCMD, "received response",
  71. cbytes, cs->respdata);
  72. gigaset_handle_modem_response(cs);
  73. cbytes = 0;
  74. /* store EOL byte for CRLF collapsing */
  75. cs->respdata[0] = c;
  76. /* cs->dle may have changed */
  77. if (cs->dle && !(inbuf->inputstate & INS_DLE_command))
  78. inbuf->inputstate &= ~INS_command;
  79. /* return for reevaluating state */
  80. goto exit;
  81. case DLE_FLAG:
  82. if (inbuf->inputstate & INS_DLE_char) {
  83. /* quoted DLE: clear quote flag */
  84. inbuf->inputstate &= ~INS_DLE_char;
  85. } else if (cs->dle ||
  86. (inbuf->inputstate & INS_DLE_command)) {
  87. /* DLE escape, pass up for handling */
  88. inbuf->inputstate |= INS_DLE_char;
  89. goto exit;
  90. }
  91. /* quoted or not in DLE mode: treat as regular data */
  92. /* --v-- fall through --v-- */
  93. default:
  94. /* append to line buffer if possible */
  95. if (cbytes < MAX_RESP_SIZE)
  96. cs->respdata[cbytes] = c;
  97. cbytes++;
  98. }
  99. }
  100. exit:
  101. cs->cbytes = cbytes;
  102. return procbytes;
  103. }
  104. /* process a block of received bytes in lock mode
  105. * All received bytes are passed unmodified to the tty i/f.
  106. * Return value:
  107. * number of processed bytes
  108. */
  109. static unsigned lock_loop(unsigned numbytes, struct inbuf_t *inbuf)
  110. {
  111. unsigned char *src = inbuf->data + inbuf->head;
  112. gigaset_dbg_buffer(DEBUG_LOCKCMD, "received response", numbytes, src);
  113. gigaset_if_receive(inbuf->cs, src, numbytes);
  114. return numbytes;
  115. }
  116. /* set up next receive skb for data mode
  117. */
  118. static void new_rcv_skb(struct bc_state *bcs)
  119. {
  120. struct cardstate *cs = bcs->cs;
  121. unsigned short hw_hdr_len = cs->hw_hdr_len;
  122. if (bcs->ignore) {
  123. bcs->skb = NULL;
  124. return;
  125. }
  126. bcs->skb = dev_alloc_skb(SBUFSIZE + hw_hdr_len);
  127. if (bcs->skb == NULL) {
  128. dev_warn(cs->dev, "could not allocate new skb\n");
  129. return;
  130. }
  131. skb_reserve(bcs->skb, hw_hdr_len);
  132. }
  133. /* process a block of received bytes in HDLC data mode
  134. * (mstate != MS_LOCKED && !(inputstate & INS_command) && proto2 == L2_HDLC)
  135. * Collect HDLC frames, undoing byte stuffing and watching for DLE escapes.
  136. * When a frame is complete, check the FCS and pass valid frames to the LL.
  137. * If DLE is encountered, return immediately to let the caller handle it.
  138. * Return value:
  139. * number of processed bytes
  140. */
  141. static unsigned hdlc_loop(unsigned numbytes, struct inbuf_t *inbuf)
  142. {
  143. struct cardstate *cs = inbuf->cs;
  144. struct bc_state *bcs = cs->bcs;
  145. int inputstate = bcs->inputstate;
  146. __u16 fcs = bcs->fcs;
  147. struct sk_buff *skb = bcs->skb;
  148. unsigned char *src = inbuf->data + inbuf->head;
  149. unsigned procbytes = 0;
  150. unsigned char c;
  151. if (inputstate & INS_byte_stuff) {
  152. if (!numbytes)
  153. return 0;
  154. inputstate &= ~INS_byte_stuff;
  155. goto byte_stuff;
  156. }
  157. while (procbytes < numbytes) {
  158. c = *src++;
  159. procbytes++;
  160. if (c == DLE_FLAG) {
  161. if (inputstate & INS_DLE_char) {
  162. /* quoted DLE: clear quote flag */
  163. inputstate &= ~INS_DLE_char;
  164. } else if (cs->dle || (inputstate & INS_DLE_command)) {
  165. /* DLE escape, pass up for handling */
  166. inputstate |= INS_DLE_char;
  167. break;
  168. }
  169. }
  170. if (c == PPP_ESCAPE) {
  171. /* byte stuffing indicator: pull in next byte */
  172. if (procbytes >= numbytes) {
  173. /* end of buffer, save for later processing */
  174. inputstate |= INS_byte_stuff;
  175. break;
  176. }
  177. byte_stuff:
  178. c = *src++;
  179. procbytes++;
  180. if (c == DLE_FLAG) {
  181. if (inputstate & INS_DLE_char) {
  182. /* quoted DLE: clear quote flag */
  183. inputstate &= ~INS_DLE_char;
  184. } else if (cs->dle ||
  185. (inputstate & INS_DLE_command)) {
  186. /* DLE escape, pass up for handling */
  187. inputstate |=
  188. INS_DLE_char | INS_byte_stuff;
  189. break;
  190. }
  191. }
  192. c ^= PPP_TRANS;
  193. #ifdef CONFIG_GIGASET_DEBUG
  194. if (!muststuff(c))
  195. gig_dbg(DEBUG_HDLC, "byte stuffed: 0x%02x", c);
  196. #endif
  197. } else if (c == PPP_FLAG) {
  198. /* end of frame: process content if any */
  199. if (inputstate & INS_have_data) {
  200. gig_dbg(DEBUG_HDLC,
  201. "7e----------------------------");
  202. /* check and pass received frame */
  203. if (!skb) {
  204. /* skipped frame */
  205. gigaset_isdn_rcv_err(bcs);
  206. } else if (skb->len < 2) {
  207. /* frame too short for FCS */
  208. dev_warn(cs->dev,
  209. "short frame (%d)\n",
  210. skb->len);
  211. gigaset_isdn_rcv_err(bcs);
  212. dev_kfree_skb_any(skb);
  213. } else if (fcs != PPP_GOODFCS) {
  214. /* frame check error */
  215. dev_err(cs->dev,
  216. "Checksum failed, %u bytes corrupted!\n",
  217. skb->len);
  218. gigaset_isdn_rcv_err(bcs);
  219. dev_kfree_skb_any(skb);
  220. } else {
  221. /* good frame */
  222. __skb_trim(skb, skb->len - 2);
  223. gigaset_skb_rcvd(bcs, skb);
  224. }
  225. /* prepare reception of next frame */
  226. inputstate &= ~INS_have_data;
  227. new_rcv_skb(bcs);
  228. skb = bcs->skb;
  229. } else {
  230. /* empty frame (7E 7E) */
  231. #ifdef CONFIG_GIGASET_DEBUG
  232. ++bcs->emptycount;
  233. #endif
  234. if (!skb) {
  235. /* skipped (?) */
  236. gigaset_isdn_rcv_err(bcs);
  237. new_rcv_skb(bcs);
  238. skb = bcs->skb;
  239. }
  240. }
  241. fcs = PPP_INITFCS;
  242. continue;
  243. #ifdef CONFIG_GIGASET_DEBUG
  244. } else if (muststuff(c)) {
  245. /* Should not happen. Possible after ZDLE=1<CR><LF>. */
  246. gig_dbg(DEBUG_HDLC, "not byte stuffed: 0x%02x", c);
  247. #endif
  248. }
  249. /* regular data byte, append to skb */
  250. #ifdef CONFIG_GIGASET_DEBUG
  251. if (!(inputstate & INS_have_data)) {
  252. gig_dbg(DEBUG_HDLC, "7e (%d x) ================",
  253. bcs->emptycount);
  254. bcs->emptycount = 0;
  255. }
  256. #endif
  257. inputstate |= INS_have_data;
  258. if (skb) {
  259. if (skb->len == SBUFSIZE) {
  260. dev_warn(cs->dev, "received packet too long\n");
  261. dev_kfree_skb_any(skb);
  262. /* skip remainder of packet */
  263. bcs->skb = skb = NULL;
  264. } else {
  265. *__skb_put(skb, 1) = c;
  266. fcs = crc_ccitt_byte(fcs, c);
  267. }
  268. }
  269. }
  270. bcs->inputstate = inputstate;
  271. bcs->fcs = fcs;
  272. return procbytes;
  273. }
  274. /* process a block of received bytes in transparent data mode
  275. * (mstate != MS_LOCKED && !(inputstate & INS_command) && proto2 != L2_HDLC)
  276. * Invert bytes, undoing byte stuffing and watching for DLE escapes.
  277. * If DLE is encountered, return immediately to let the caller handle it.
  278. * Return value:
  279. * number of processed bytes
  280. */
  281. static unsigned iraw_loop(unsigned numbytes, struct inbuf_t *inbuf)
  282. {
  283. struct cardstate *cs = inbuf->cs;
  284. struct bc_state *bcs = cs->bcs;
  285. int inputstate = bcs->inputstate;
  286. struct sk_buff *skb = bcs->skb;
  287. unsigned char *src = inbuf->data + inbuf->head;
  288. unsigned procbytes = 0;
  289. unsigned char c;
  290. if (!skb) {
  291. /* skip this block */
  292. new_rcv_skb(bcs);
  293. return numbytes;
  294. }
  295. while (procbytes < numbytes && skb->len < SBUFSIZE) {
  296. c = *src++;
  297. procbytes++;
  298. if (c == DLE_FLAG) {
  299. if (inputstate & INS_DLE_char) {
  300. /* quoted DLE: clear quote flag */
  301. inputstate &= ~INS_DLE_char;
  302. } else if (cs->dle || (inputstate & INS_DLE_command)) {
  303. /* DLE escape, pass up for handling */
  304. inputstate |= INS_DLE_char;
  305. break;
  306. }
  307. }
  308. /* regular data byte: append to current skb */
  309. inputstate |= INS_have_data;
  310. *__skb_put(skb, 1) = bitrev8(c);
  311. }
  312. /* pass data up */
  313. if (inputstate & INS_have_data) {
  314. gigaset_skb_rcvd(bcs, skb);
  315. inputstate &= ~INS_have_data;
  316. new_rcv_skb(bcs);
  317. }
  318. bcs->inputstate = inputstate;
  319. return procbytes;
  320. }
  321. /* process DLE escapes
  322. * Called whenever a DLE sequence might be encountered in the input stream.
  323. * Either processes the entire DLE sequence or, if that isn't possible,
  324. * notes the fact that an initial DLE has been received in the INS_DLE_char
  325. * inputstate flag and resumes processing of the sequence on the next call.
  326. */
  327. static void handle_dle(struct inbuf_t *inbuf)
  328. {
  329. struct cardstate *cs = inbuf->cs;
  330. if (cs->mstate == MS_LOCKED)
  331. return; /* no DLE processing in lock mode */
  332. if (!(inbuf->inputstate & INS_DLE_char)) {
  333. /* no DLE pending */
  334. if (inbuf->data[inbuf->head] == DLE_FLAG &&
  335. (cs->dle || inbuf->inputstate & INS_DLE_command)) {
  336. /* start of DLE sequence */
  337. inbuf->head++;
  338. if (inbuf->head == inbuf->tail ||
  339. inbuf->head == RBUFSIZE) {
  340. /* end of buffer, save for later processing */
  341. inbuf->inputstate |= INS_DLE_char;
  342. return;
  343. }
  344. } else {
  345. /* regular data byte */
  346. return;
  347. }
  348. }
  349. /* consume pending DLE */
  350. inbuf->inputstate &= ~INS_DLE_char;
  351. switch (inbuf->data[inbuf->head]) {
  352. case 'X': /* begin of event message */
  353. if (inbuf->inputstate & INS_command)
  354. dev_notice(cs->dev,
  355. "received <DLE>X in command mode\n");
  356. inbuf->inputstate |= INS_command | INS_DLE_command;
  357. inbuf->head++; /* byte consumed */
  358. break;
  359. case '.': /* end of event message */
  360. if (!(inbuf->inputstate & INS_DLE_command))
  361. dev_notice(cs->dev,
  362. "received <DLE>. without <DLE>X\n");
  363. inbuf->inputstate &= ~INS_DLE_command;
  364. /* return to data mode if in DLE mode */
  365. if (cs->dle)
  366. inbuf->inputstate &= ~INS_command;
  367. inbuf->head++; /* byte consumed */
  368. break;
  369. case DLE_FLAG: /* DLE in data stream */
  370. /* mark as quoted */
  371. inbuf->inputstate |= INS_DLE_char;
  372. if (!(cs->dle || inbuf->inputstate & INS_DLE_command))
  373. dev_notice(cs->dev,
  374. "received <DLE><DLE> not in DLE mode\n");
  375. break; /* quoted byte left in buffer */
  376. default:
  377. dev_notice(cs->dev, "received <DLE><%02x>\n",
  378. inbuf->data[inbuf->head]);
  379. /* quoted byte left in buffer */
  380. }
  381. }
  382. /**
  383. * gigaset_m10x_input() - process a block of data received from the device
  384. * @inbuf: received data and device descriptor structure.
  385. *
  386. * Called by hardware module {ser,usb}_gigaset with a block of received
  387. * bytes. Separates the bytes received over the serial data channel into
  388. * user data and command replies (locked/unlocked) according to the
  389. * current state of the interface.
  390. */
  391. void gigaset_m10x_input(struct inbuf_t *inbuf)
  392. {
  393. struct cardstate *cs = inbuf->cs;
  394. unsigned numbytes, procbytes;
  395. gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", inbuf->head, inbuf->tail);
  396. while (inbuf->head != inbuf->tail) {
  397. /* check for DLE escape */
  398. handle_dle(inbuf);
  399. /* process a contiguous block of bytes */
  400. numbytes = (inbuf->head > inbuf->tail ?
  401. RBUFSIZE : inbuf->tail) - inbuf->head;
  402. gig_dbg(DEBUG_INTR, "processing %u bytes", numbytes);
  403. /*
  404. * numbytes may be 0 if handle_dle() ate the last byte.
  405. * This does no harm, *_loop() will just return 0 immediately.
  406. */
  407. if (cs->mstate == MS_LOCKED)
  408. procbytes = lock_loop(numbytes, inbuf);
  409. else if (inbuf->inputstate & INS_command)
  410. procbytes = cmd_loop(numbytes, inbuf);
  411. else if (cs->bcs->proto2 == L2_HDLC)
  412. procbytes = hdlc_loop(numbytes, inbuf);
  413. else
  414. procbytes = iraw_loop(numbytes, inbuf);
  415. inbuf->head += procbytes;
  416. /* check for buffer wraparound */
  417. if (inbuf->head >= RBUFSIZE)
  418. inbuf->head = 0;
  419. gig_dbg(DEBUG_INTR, "head set to %u", inbuf->head);
  420. }
  421. }
  422. EXPORT_SYMBOL_GPL(gigaset_m10x_input);
  423. /* == data output ========================================================== */
  424. /*
  425. * Encode a data packet into an octet stuffed HDLC frame with FCS,
  426. * opening and closing flags, preserving headroom data.
  427. * parameters:
  428. * skb skb containing original packet (freed upon return)
  429. * Return value:
  430. * pointer to newly allocated skb containing the result frame
  431. * and the original link layer header, NULL on error
  432. */
  433. static struct sk_buff *HDLC_Encode(struct sk_buff *skb)
  434. {
  435. struct sk_buff *hdlc_skb;
  436. __u16 fcs;
  437. unsigned char c;
  438. unsigned char *cp;
  439. int len;
  440. unsigned int stuf_cnt;
  441. stuf_cnt = 0;
  442. fcs = PPP_INITFCS;
  443. cp = skb->data;
  444. len = skb->len;
  445. while (len--) {
  446. if (muststuff(*cp))
  447. stuf_cnt++;
  448. fcs = crc_ccitt_byte(fcs, *cp++);
  449. }
  450. fcs ^= 0xffff; /* complement */
  451. /* size of new buffer: original size + number of stuffing bytes
  452. * + 2 bytes FCS + 2 stuffing bytes for FCS (if needed) + 2 flag bytes
  453. * + room for link layer header
  454. */
  455. hdlc_skb = dev_alloc_skb(skb->len + stuf_cnt + 6 + skb->mac_len);
  456. if (!hdlc_skb) {
  457. dev_kfree_skb_any(skb);
  458. return NULL;
  459. }
  460. /* Copy link layer header into new skb */
  461. skb_reset_mac_header(hdlc_skb);
  462. skb_reserve(hdlc_skb, skb->mac_len);
  463. memcpy(skb_mac_header(hdlc_skb), skb_mac_header(skb), skb->mac_len);
  464. hdlc_skb->mac_len = skb->mac_len;
  465. /* Add flag sequence in front of everything.. */
  466. *(skb_put(hdlc_skb, 1)) = PPP_FLAG;
  467. /* Perform byte stuffing while copying data. */
  468. while (skb->len--) {
  469. if (muststuff(*skb->data)) {
  470. *(skb_put(hdlc_skb, 1)) = PPP_ESCAPE;
  471. *(skb_put(hdlc_skb, 1)) = (*skb->data++) ^ PPP_TRANS;
  472. } else
  473. *(skb_put(hdlc_skb, 1)) = *skb->data++;
  474. }
  475. /* Finally add FCS (byte stuffed) and flag sequence */
  476. c = (fcs & 0x00ff); /* least significant byte first */
  477. if (muststuff(c)) {
  478. *(skb_put(hdlc_skb, 1)) = PPP_ESCAPE;
  479. c ^= PPP_TRANS;
  480. }
  481. *(skb_put(hdlc_skb, 1)) = c;
  482. c = ((fcs >> 8) & 0x00ff);
  483. if (muststuff(c)) {
  484. *(skb_put(hdlc_skb, 1)) = PPP_ESCAPE;
  485. c ^= PPP_TRANS;
  486. }
  487. *(skb_put(hdlc_skb, 1)) = c;
  488. *(skb_put(hdlc_skb, 1)) = PPP_FLAG;
  489. dev_kfree_skb_any(skb);
  490. return hdlc_skb;
  491. }
  492. /*
  493. * Encode a data packet into an octet stuffed raw bit inverted frame,
  494. * preserving headroom data.
  495. * parameters:
  496. * skb skb containing original packet (freed upon return)
  497. * Return value:
  498. * pointer to newly allocated skb containing the result frame
  499. * and the original link layer header, NULL on error
  500. */
  501. static struct sk_buff *iraw_encode(struct sk_buff *skb)
  502. {
  503. struct sk_buff *iraw_skb;
  504. unsigned char c;
  505. unsigned char *cp;
  506. int len;
  507. /* size of new buffer (worst case = every byte must be stuffed):
  508. * 2 * original size + room for link layer header
  509. */
  510. iraw_skb = dev_alloc_skb(2*skb->len + skb->mac_len);
  511. if (!iraw_skb) {
  512. dev_kfree_skb_any(skb);
  513. return NULL;
  514. }
  515. /* copy link layer header into new skb */
  516. skb_reset_mac_header(iraw_skb);
  517. skb_reserve(iraw_skb, skb->mac_len);
  518. memcpy(skb_mac_header(iraw_skb), skb_mac_header(skb), skb->mac_len);
  519. iraw_skb->mac_len = skb->mac_len;
  520. /* copy and stuff data */
  521. cp = skb->data;
  522. len = skb->len;
  523. while (len--) {
  524. c = bitrev8(*cp++);
  525. if (c == DLE_FLAG)
  526. *(skb_put(iraw_skb, 1)) = c;
  527. *(skb_put(iraw_skb, 1)) = c;
  528. }
  529. dev_kfree_skb_any(skb);
  530. return iraw_skb;
  531. }
  532. /**
  533. * gigaset_m10x_send_skb() - queue an skb for sending
  534. * @bcs: B channel descriptor structure.
  535. * @skb: data to send.
  536. *
  537. * Called by LL to encode and queue an skb for sending, and start
  538. * transmission if necessary.
  539. * Once the payload data has been transmitted completely, gigaset_skb_sent()
  540. * will be called with the skb's link layer header preserved.
  541. *
  542. * Return value:
  543. * number of bytes accepted for sending (skb->len) if ok,
  544. * error code < 0 (eg. -ENOMEM) on error
  545. */
  546. int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb)
  547. {
  548. struct cardstate *cs = bcs->cs;
  549. unsigned len = skb->len;
  550. unsigned long flags;
  551. if (bcs->proto2 == L2_HDLC)
  552. skb = HDLC_Encode(skb);
  553. else
  554. skb = iraw_encode(skb);
  555. if (!skb) {
  556. dev_err(cs->dev,
  557. "unable to allocate memory for encoding!\n");
  558. return -ENOMEM;
  559. }
  560. skb_queue_tail(&bcs->squeue, skb);
  561. spin_lock_irqsave(&cs->lock, flags);
  562. if (cs->connected)
  563. tasklet_schedule(&cs->write_tasklet);
  564. spin_unlock_irqrestore(&cs->lock, flags);
  565. return len; /* ok so far */
  566. }
  567. EXPORT_SYMBOL_GPL(gigaset_m10x_send_skb);