digital_technology.c 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306
  1. /*
  2. * NFC Digital Protocol stack
  3. * Copyright (c) 2013, Intel Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. */
  15. #define pr_fmt(fmt) "digital: %s: " fmt, __func__
  16. #include "digital.h"
  17. #define DIGITAL_CMD_SENS_REQ 0x26
  18. #define DIGITAL_CMD_ALL_REQ 0x52
  19. #define DIGITAL_CMD_SEL_REQ_CL1 0x93
  20. #define DIGITAL_CMD_SEL_REQ_CL2 0x95
  21. #define DIGITAL_CMD_SEL_REQ_CL3 0x97
  22. #define DIGITAL_SDD_REQ_SEL_PAR 0x20
  23. #define DIGITAL_SDD_RES_CT 0x88
  24. #define DIGITAL_SDD_RES_LEN 5
  25. #define DIGITAL_SEL_RES_LEN 1
  26. #define DIGITAL_SEL_RES_NFCID1_COMPLETE(sel_res) (!((sel_res) & 0x04))
  27. #define DIGITAL_SEL_RES_IS_T2T(sel_res) (!((sel_res) & 0x60))
  28. #define DIGITAL_SEL_RES_IS_T4T(sel_res) ((sel_res) & 0x20)
  29. #define DIGITAL_SEL_RES_IS_NFC_DEP(sel_res) ((sel_res) & 0x40)
  30. #define DIGITAL_SENS_RES_IS_T1T(sens_res) (((sens_res) & 0x0C00) == 0x0C00)
  31. #define DIGITAL_SENS_RES_IS_VALID(sens_res) \
  32. ((!((sens_res) & 0x001F) && (((sens_res) & 0x0C00) == 0x0C00)) || \
  33. (((sens_res) & 0x001F) && ((sens_res) & 0x0C00) != 0x0C00))
  34. #define DIGITAL_MIFARE_READ_RES_LEN 16
  35. #define DIGITAL_MIFARE_ACK_RES 0x0A
  36. #define DIGITAL_CMD_SENSB_REQ 0x05
  37. #define DIGITAL_SENSB_ADVANCED BIT(5)
  38. #define DIGITAL_SENSB_EXTENDED BIT(4)
  39. #define DIGITAL_SENSB_ALLB_REQ BIT(3)
  40. #define DIGITAL_SENSB_N(n) ((n) & 0x7)
  41. #define DIGITAL_CMD_SENSB_RES 0x50
  42. #define DIGITAL_CMD_ATTRIB_REQ 0x1D
  43. #define DIGITAL_ATTRIB_P1_TR0_DEFAULT (0x0 << 6)
  44. #define DIGITAL_ATTRIB_P1_TR1_DEFAULT (0x0 << 4)
  45. #define DIGITAL_ATTRIB_P1_SUPRESS_EOS BIT(3)
  46. #define DIGITAL_ATTRIB_P1_SUPRESS_SOS BIT(2)
  47. #define DIGITAL_ATTRIB_P2_LISTEN_POLL_1 (0x0 << 6)
  48. #define DIGITAL_ATTRIB_P2_POLL_LISTEN_1 (0x0 << 4)
  49. #define DIGITAL_ATTRIB_P2_MAX_FRAME_256 0x8
  50. #define DIGITAL_ATTRIB_P4_DID(n) ((n) & 0xf)
  51. #define DIGITAL_CMD_SENSF_REQ 0x00
  52. #define DIGITAL_CMD_SENSF_RES 0x01
  53. #define DIGITAL_SENSF_RES_MIN_LENGTH 17
  54. #define DIGITAL_SENSF_RES_RD_AP_B1 0x00
  55. #define DIGITAL_SENSF_RES_RD_AP_B2 0x8F
  56. #define DIGITAL_SENSF_REQ_RC_NONE 0
  57. #define DIGITAL_SENSF_REQ_RC_SC 1
  58. #define DIGITAL_SENSF_REQ_RC_AP 2
  59. #define DIGITAL_CMD_ISO15693_INVENTORY_REQ 0x01
  60. #define DIGITAL_ISO15693_REQ_FLAG_DATA_RATE BIT(1)
  61. #define DIGITAL_ISO15693_REQ_FLAG_INVENTORY BIT(2)
  62. #define DIGITAL_ISO15693_REQ_FLAG_NB_SLOTS BIT(5)
  63. #define DIGITAL_ISO15693_RES_FLAG_ERROR BIT(0)
  64. #define DIGITAL_ISO15693_RES_IS_VALID(flags) \
  65. (!((flags) & DIGITAL_ISO15693_RES_FLAG_ERROR))
  66. #define DIGITAL_ISO_DEP_I_PCB 0x02
  67. #define DIGITAL_ISO_DEP_PNI(pni) ((pni) & 0x01)
  68. #define DIGITAL_ISO_DEP_PCB_TYPE(pcb) ((pcb) & 0xC0)
  69. #define DIGITAL_ISO_DEP_I_BLOCK 0x00
  70. #define DIGITAL_ISO_DEP_BLOCK_HAS_DID(pcb) ((pcb) & 0x08)
  71. static const u8 digital_ats_fsc[] = {
  72. 16, 24, 32, 40, 48, 64, 96, 128,
  73. };
  74. #define DIGITAL_ATS_FSCI(t0) ((t0) & 0x0F)
  75. #define DIGITAL_SENSB_FSCI(pi2) (((pi2) & 0xF0) >> 4)
  76. #define DIGITAL_ATS_MAX_FSC 256
  77. #define DIGITAL_RATS_BYTE1 0xE0
  78. #define DIGITAL_RATS_PARAM 0x80
  79. struct digital_sdd_res {
  80. u8 nfcid1[4];
  81. u8 bcc;
  82. } __packed;
  83. struct digital_sel_req {
  84. u8 sel_cmd;
  85. u8 b2;
  86. u8 nfcid1[4];
  87. u8 bcc;
  88. } __packed;
  89. struct digital_sensb_req {
  90. u8 cmd;
  91. u8 afi;
  92. u8 param;
  93. } __packed;
  94. struct digital_sensb_res {
  95. u8 cmd;
  96. u8 nfcid0[4];
  97. u8 app_data[4];
  98. u8 proto_info[3];
  99. } __packed;
  100. struct digital_attrib_req {
  101. u8 cmd;
  102. u8 nfcid0[4];
  103. u8 param1;
  104. u8 param2;
  105. u8 param3;
  106. u8 param4;
  107. } __packed;
  108. struct digital_attrib_res {
  109. u8 mbli_did;
  110. } __packed;
  111. struct digital_sensf_req {
  112. u8 cmd;
  113. u8 sc1;
  114. u8 sc2;
  115. u8 rc;
  116. u8 tsn;
  117. } __packed;
  118. struct digital_sensf_res {
  119. u8 cmd;
  120. u8 nfcid2[8];
  121. u8 pad0[2];
  122. u8 pad1[3];
  123. u8 mrti_check;
  124. u8 mrti_update;
  125. u8 pad2;
  126. u8 rd[2];
  127. } __packed;
  128. struct digital_iso15693_inv_req {
  129. u8 flags;
  130. u8 cmd;
  131. u8 mask_len;
  132. u64 mask;
  133. } __packed;
  134. struct digital_iso15693_inv_res {
  135. u8 flags;
  136. u8 dsfid;
  137. u64 uid;
  138. } __packed;
  139. static int digital_in_send_sdd_req(struct nfc_digital_dev *ddev,
  140. struct nfc_target *target);
  141. int digital_in_iso_dep_pull_sod(struct nfc_digital_dev *ddev,
  142. struct sk_buff *skb)
  143. {
  144. u8 pcb;
  145. u8 block_type;
  146. if (skb->len < 1)
  147. return -EIO;
  148. pcb = *skb->data;
  149. block_type = DIGITAL_ISO_DEP_PCB_TYPE(pcb);
  150. /* No support fo R-block nor S-block */
  151. if (block_type != DIGITAL_ISO_DEP_I_BLOCK) {
  152. pr_err("ISO_DEP R-block and S-block not supported\n");
  153. return -EIO;
  154. }
  155. if (DIGITAL_ISO_DEP_BLOCK_HAS_DID(pcb)) {
  156. pr_err("DID field in ISO_DEP PCB not supported\n");
  157. return -EIO;
  158. }
  159. skb_pull(skb, 1);
  160. return 0;
  161. }
  162. int digital_in_iso_dep_push_sod(struct nfc_digital_dev *ddev,
  163. struct sk_buff *skb)
  164. {
  165. /*
  166. * Chaining not supported so skb->len + 1 PCB byte + 2 CRC bytes must
  167. * not be greater than remote FSC
  168. */
  169. if (skb->len + 3 > ddev->target_fsc)
  170. return -EIO;
  171. skb_push(skb, 1);
  172. *skb->data = DIGITAL_ISO_DEP_I_PCB | ddev->curr_nfc_dep_pni;
  173. ddev->curr_nfc_dep_pni =
  174. DIGITAL_ISO_DEP_PNI(ddev->curr_nfc_dep_pni + 1);
  175. return 0;
  176. }
  177. static void digital_in_recv_ats(struct nfc_digital_dev *ddev, void *arg,
  178. struct sk_buff *resp)
  179. {
  180. struct nfc_target *target = arg;
  181. u8 fsdi;
  182. int rc;
  183. if (IS_ERR(resp)) {
  184. rc = PTR_ERR(resp);
  185. resp = NULL;
  186. goto exit;
  187. }
  188. if (resp->len < 2) {
  189. rc = -EIO;
  190. goto exit;
  191. }
  192. fsdi = DIGITAL_ATS_FSCI(resp->data[1]);
  193. if (fsdi >= 8)
  194. ddev->target_fsc = DIGITAL_ATS_MAX_FSC;
  195. else
  196. ddev->target_fsc = digital_ats_fsc[fsdi];
  197. ddev->curr_nfc_dep_pni = 0;
  198. rc = digital_target_found(ddev, target, NFC_PROTO_ISO14443);
  199. exit:
  200. dev_kfree_skb(resp);
  201. kfree(target);
  202. if (rc)
  203. digital_poll_next_tech(ddev);
  204. }
  205. static int digital_in_send_rats(struct nfc_digital_dev *ddev,
  206. struct nfc_target *target)
  207. {
  208. int rc;
  209. struct sk_buff *skb;
  210. skb = digital_skb_alloc(ddev, 2);
  211. if (!skb)
  212. return -ENOMEM;
  213. skb_put_u8(skb, DIGITAL_RATS_BYTE1);
  214. skb_put_u8(skb, DIGITAL_RATS_PARAM);
  215. rc = digital_in_send_cmd(ddev, skb, 30, digital_in_recv_ats,
  216. target);
  217. if (rc)
  218. kfree_skb(skb);
  219. return rc;
  220. }
  221. static void digital_in_recv_sel_res(struct nfc_digital_dev *ddev, void *arg,
  222. struct sk_buff *resp)
  223. {
  224. struct nfc_target *target = arg;
  225. int rc;
  226. u8 sel_res;
  227. u8 nfc_proto;
  228. if (IS_ERR(resp)) {
  229. rc = PTR_ERR(resp);
  230. resp = NULL;
  231. goto exit;
  232. }
  233. if (!DIGITAL_DRV_CAPS_IN_CRC(ddev)) {
  234. rc = digital_skb_check_crc_a(resp);
  235. if (rc) {
  236. PROTOCOL_ERR("4.4.1.3");
  237. goto exit;
  238. }
  239. }
  240. if (resp->len != DIGITAL_SEL_RES_LEN) {
  241. rc = -EIO;
  242. goto exit;
  243. }
  244. sel_res = resp->data[0];
  245. if (!DIGITAL_SEL_RES_NFCID1_COMPLETE(sel_res)) {
  246. rc = digital_in_send_sdd_req(ddev, target);
  247. if (rc)
  248. goto exit;
  249. goto exit_free_skb;
  250. }
  251. target->sel_res = sel_res;
  252. if (DIGITAL_SEL_RES_IS_T2T(sel_res)) {
  253. nfc_proto = NFC_PROTO_MIFARE;
  254. } else if (DIGITAL_SEL_RES_IS_NFC_DEP(sel_res)) {
  255. nfc_proto = NFC_PROTO_NFC_DEP;
  256. } else if (DIGITAL_SEL_RES_IS_T4T(sel_res)) {
  257. rc = digital_in_send_rats(ddev, target);
  258. if (rc)
  259. goto exit;
  260. /*
  261. * Skip target_found and don't free it for now. This will be
  262. * done when receiving the ATS
  263. */
  264. goto exit_free_skb;
  265. } else {
  266. rc = -EOPNOTSUPP;
  267. goto exit;
  268. }
  269. rc = digital_target_found(ddev, target, nfc_proto);
  270. exit:
  271. kfree(target);
  272. exit_free_skb:
  273. dev_kfree_skb(resp);
  274. if (rc)
  275. digital_poll_next_tech(ddev);
  276. }
  277. static int digital_in_send_sel_req(struct nfc_digital_dev *ddev,
  278. struct nfc_target *target,
  279. struct digital_sdd_res *sdd_res)
  280. {
  281. struct sk_buff *skb;
  282. struct digital_sel_req *sel_req;
  283. u8 sel_cmd;
  284. int rc;
  285. skb = digital_skb_alloc(ddev, sizeof(struct digital_sel_req));
  286. if (!skb)
  287. return -ENOMEM;
  288. skb_put(skb, sizeof(struct digital_sel_req));
  289. sel_req = (struct digital_sel_req *)skb->data;
  290. if (target->nfcid1_len <= 4)
  291. sel_cmd = DIGITAL_CMD_SEL_REQ_CL1;
  292. else if (target->nfcid1_len < 10)
  293. sel_cmd = DIGITAL_CMD_SEL_REQ_CL2;
  294. else
  295. sel_cmd = DIGITAL_CMD_SEL_REQ_CL3;
  296. sel_req->sel_cmd = sel_cmd;
  297. sel_req->b2 = 0x70;
  298. memcpy(sel_req->nfcid1, sdd_res->nfcid1, 4);
  299. sel_req->bcc = sdd_res->bcc;
  300. if (DIGITAL_DRV_CAPS_IN_CRC(ddev)) {
  301. rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
  302. NFC_DIGITAL_FRAMING_NFCA_STANDARD_WITH_CRC_A);
  303. if (rc)
  304. goto exit;
  305. } else {
  306. digital_skb_add_crc_a(skb);
  307. }
  308. rc = digital_in_send_cmd(ddev, skb, 30, digital_in_recv_sel_res,
  309. target);
  310. exit:
  311. if (rc)
  312. kfree_skb(skb);
  313. return rc;
  314. }
  315. static void digital_in_recv_sdd_res(struct nfc_digital_dev *ddev, void *arg,
  316. struct sk_buff *resp)
  317. {
  318. struct nfc_target *target = arg;
  319. struct digital_sdd_res *sdd_res;
  320. int rc;
  321. u8 offset, size;
  322. u8 i, bcc;
  323. if (IS_ERR(resp)) {
  324. rc = PTR_ERR(resp);
  325. resp = NULL;
  326. goto exit;
  327. }
  328. if (resp->len < DIGITAL_SDD_RES_LEN) {
  329. PROTOCOL_ERR("4.7.2.8");
  330. rc = -EINVAL;
  331. goto exit;
  332. }
  333. sdd_res = (struct digital_sdd_res *)resp->data;
  334. for (i = 0, bcc = 0; i < 4; i++)
  335. bcc ^= sdd_res->nfcid1[i];
  336. if (bcc != sdd_res->bcc) {
  337. PROTOCOL_ERR("4.7.2.6");
  338. rc = -EINVAL;
  339. goto exit;
  340. }
  341. if (sdd_res->nfcid1[0] == DIGITAL_SDD_RES_CT) {
  342. offset = 1;
  343. size = 3;
  344. } else {
  345. offset = 0;
  346. size = 4;
  347. }
  348. memcpy(target->nfcid1 + target->nfcid1_len, sdd_res->nfcid1 + offset,
  349. size);
  350. target->nfcid1_len += size;
  351. rc = digital_in_send_sel_req(ddev, target, sdd_res);
  352. exit:
  353. dev_kfree_skb(resp);
  354. if (rc) {
  355. kfree(target);
  356. digital_poll_next_tech(ddev);
  357. }
  358. }
  359. static int digital_in_send_sdd_req(struct nfc_digital_dev *ddev,
  360. struct nfc_target *target)
  361. {
  362. int rc;
  363. struct sk_buff *skb;
  364. u8 sel_cmd;
  365. rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
  366. NFC_DIGITAL_FRAMING_NFCA_STANDARD);
  367. if (rc)
  368. return rc;
  369. skb = digital_skb_alloc(ddev, 2);
  370. if (!skb)
  371. return -ENOMEM;
  372. if (target->nfcid1_len == 0)
  373. sel_cmd = DIGITAL_CMD_SEL_REQ_CL1;
  374. else if (target->nfcid1_len == 3)
  375. sel_cmd = DIGITAL_CMD_SEL_REQ_CL2;
  376. else
  377. sel_cmd = DIGITAL_CMD_SEL_REQ_CL3;
  378. skb_put_u8(skb, sel_cmd);
  379. skb_put_u8(skb, DIGITAL_SDD_REQ_SEL_PAR);
  380. return digital_in_send_cmd(ddev, skb, 30, digital_in_recv_sdd_res,
  381. target);
  382. }
  383. static void digital_in_recv_sens_res(struct nfc_digital_dev *ddev, void *arg,
  384. struct sk_buff *resp)
  385. {
  386. struct nfc_target *target = NULL;
  387. int rc;
  388. if (IS_ERR(resp)) {
  389. rc = PTR_ERR(resp);
  390. resp = NULL;
  391. goto exit;
  392. }
  393. if (resp->len < sizeof(u16)) {
  394. rc = -EIO;
  395. goto exit;
  396. }
  397. target = kzalloc(sizeof(struct nfc_target), GFP_KERNEL);
  398. if (!target) {
  399. rc = -ENOMEM;
  400. goto exit;
  401. }
  402. target->sens_res = __le16_to_cpu(*(__le16 *)resp->data);
  403. if (!DIGITAL_SENS_RES_IS_VALID(target->sens_res)) {
  404. PROTOCOL_ERR("4.6.3.3");
  405. rc = -EINVAL;
  406. goto exit;
  407. }
  408. if (DIGITAL_SENS_RES_IS_T1T(target->sens_res))
  409. rc = digital_target_found(ddev, target, NFC_PROTO_JEWEL);
  410. else
  411. rc = digital_in_send_sdd_req(ddev, target);
  412. exit:
  413. dev_kfree_skb(resp);
  414. if (rc) {
  415. kfree(target);
  416. digital_poll_next_tech(ddev);
  417. }
  418. }
  419. int digital_in_send_sens_req(struct nfc_digital_dev *ddev, u8 rf_tech)
  420. {
  421. struct sk_buff *skb;
  422. int rc;
  423. rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH,
  424. NFC_DIGITAL_RF_TECH_106A);
  425. if (rc)
  426. return rc;
  427. rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
  428. NFC_DIGITAL_FRAMING_NFCA_SHORT);
  429. if (rc)
  430. return rc;
  431. skb = digital_skb_alloc(ddev, 1);
  432. if (!skb)
  433. return -ENOMEM;
  434. skb_put_u8(skb, DIGITAL_CMD_SENS_REQ);
  435. rc = digital_in_send_cmd(ddev, skb, 30, digital_in_recv_sens_res, NULL);
  436. if (rc)
  437. kfree_skb(skb);
  438. return rc;
  439. }
  440. int digital_in_recv_mifare_res(struct sk_buff *resp)
  441. {
  442. /* Successful READ command response is 16 data bytes + 2 CRC bytes long.
  443. * Since the driver can't differentiate a ACK/NACK response from a valid
  444. * READ response, the CRC calculation must be handled at digital level
  445. * even if the driver supports it for this technology.
  446. */
  447. if (resp->len == DIGITAL_MIFARE_READ_RES_LEN + DIGITAL_CRC_LEN) {
  448. if (digital_skb_check_crc_a(resp)) {
  449. PROTOCOL_ERR("9.4.1.2");
  450. return -EIO;
  451. }
  452. return 0;
  453. }
  454. /* ACK response (i.e. successful WRITE). */
  455. if (resp->len == 1 && resp->data[0] == DIGITAL_MIFARE_ACK_RES) {
  456. resp->data[0] = 0;
  457. return 0;
  458. }
  459. /* NACK and any other responses are treated as error. */
  460. return -EIO;
  461. }
  462. static void digital_in_recv_attrib_res(struct nfc_digital_dev *ddev, void *arg,
  463. struct sk_buff *resp)
  464. {
  465. struct nfc_target *target = arg;
  466. struct digital_attrib_res *attrib_res;
  467. int rc;
  468. if (IS_ERR(resp)) {
  469. rc = PTR_ERR(resp);
  470. resp = NULL;
  471. goto exit;
  472. }
  473. if (resp->len < sizeof(*attrib_res)) {
  474. PROTOCOL_ERR("12.6.2");
  475. rc = -EIO;
  476. goto exit;
  477. }
  478. attrib_res = (struct digital_attrib_res *)resp->data;
  479. if (attrib_res->mbli_did & 0x0f) {
  480. PROTOCOL_ERR("12.6.2.1");
  481. rc = -EIO;
  482. goto exit;
  483. }
  484. rc = digital_target_found(ddev, target, NFC_PROTO_ISO14443_B);
  485. exit:
  486. dev_kfree_skb(resp);
  487. kfree(target);
  488. if (rc)
  489. digital_poll_next_tech(ddev);
  490. }
  491. static int digital_in_send_attrib_req(struct nfc_digital_dev *ddev,
  492. struct nfc_target *target,
  493. struct digital_sensb_res *sensb_res)
  494. {
  495. struct digital_attrib_req *attrib_req;
  496. struct sk_buff *skb;
  497. int rc;
  498. skb = digital_skb_alloc(ddev, sizeof(*attrib_req));
  499. if (!skb)
  500. return -ENOMEM;
  501. attrib_req = skb_put(skb, sizeof(*attrib_req));
  502. attrib_req->cmd = DIGITAL_CMD_ATTRIB_REQ;
  503. memcpy(attrib_req->nfcid0, sensb_res->nfcid0,
  504. sizeof(attrib_req->nfcid0));
  505. attrib_req->param1 = DIGITAL_ATTRIB_P1_TR0_DEFAULT |
  506. DIGITAL_ATTRIB_P1_TR1_DEFAULT;
  507. attrib_req->param2 = DIGITAL_ATTRIB_P2_LISTEN_POLL_1 |
  508. DIGITAL_ATTRIB_P2_POLL_LISTEN_1 |
  509. DIGITAL_ATTRIB_P2_MAX_FRAME_256;
  510. attrib_req->param3 = sensb_res->proto_info[1] & 0x07;
  511. attrib_req->param4 = DIGITAL_ATTRIB_P4_DID(0);
  512. rc = digital_in_send_cmd(ddev, skb, 30, digital_in_recv_attrib_res,
  513. target);
  514. if (rc)
  515. kfree_skb(skb);
  516. return rc;
  517. }
  518. static void digital_in_recv_sensb_res(struct nfc_digital_dev *ddev, void *arg,
  519. struct sk_buff *resp)
  520. {
  521. struct nfc_target *target = NULL;
  522. struct digital_sensb_res *sensb_res;
  523. u8 fsci;
  524. int rc;
  525. if (IS_ERR(resp)) {
  526. rc = PTR_ERR(resp);
  527. resp = NULL;
  528. goto exit;
  529. }
  530. if (resp->len != sizeof(*sensb_res)) {
  531. PROTOCOL_ERR("5.6.2.1");
  532. rc = -EIO;
  533. goto exit;
  534. }
  535. sensb_res = (struct digital_sensb_res *)resp->data;
  536. if (sensb_res->cmd != DIGITAL_CMD_SENSB_RES) {
  537. PROTOCOL_ERR("5.6.2");
  538. rc = -EIO;
  539. goto exit;
  540. }
  541. if (!(sensb_res->proto_info[1] & BIT(0))) {
  542. PROTOCOL_ERR("5.6.2.12");
  543. rc = -EIO;
  544. goto exit;
  545. }
  546. if (sensb_res->proto_info[1] & BIT(3)) {
  547. PROTOCOL_ERR("5.6.2.16");
  548. rc = -EIO;
  549. goto exit;
  550. }
  551. fsci = DIGITAL_SENSB_FSCI(sensb_res->proto_info[1]);
  552. if (fsci >= 8)
  553. ddev->target_fsc = DIGITAL_ATS_MAX_FSC;
  554. else
  555. ddev->target_fsc = digital_ats_fsc[fsci];
  556. target = kzalloc(sizeof(struct nfc_target), GFP_KERNEL);
  557. if (!target) {
  558. rc = -ENOMEM;
  559. goto exit;
  560. }
  561. rc = digital_in_send_attrib_req(ddev, target, sensb_res);
  562. exit:
  563. dev_kfree_skb(resp);
  564. if (rc) {
  565. kfree(target);
  566. digital_poll_next_tech(ddev);
  567. }
  568. }
  569. int digital_in_send_sensb_req(struct nfc_digital_dev *ddev, u8 rf_tech)
  570. {
  571. struct digital_sensb_req *sensb_req;
  572. struct sk_buff *skb;
  573. int rc;
  574. rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH,
  575. NFC_DIGITAL_RF_TECH_106B);
  576. if (rc)
  577. return rc;
  578. rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
  579. NFC_DIGITAL_FRAMING_NFCB);
  580. if (rc)
  581. return rc;
  582. skb = digital_skb_alloc(ddev, sizeof(*sensb_req));
  583. if (!skb)
  584. return -ENOMEM;
  585. sensb_req = skb_put(skb, sizeof(*sensb_req));
  586. sensb_req->cmd = DIGITAL_CMD_SENSB_REQ;
  587. sensb_req->afi = 0x00; /* All families and sub-families */
  588. sensb_req->param = DIGITAL_SENSB_N(0);
  589. rc = digital_in_send_cmd(ddev, skb, 30, digital_in_recv_sensb_res,
  590. NULL);
  591. if (rc)
  592. kfree_skb(skb);
  593. return rc;
  594. }
  595. static void digital_in_recv_sensf_res(struct nfc_digital_dev *ddev, void *arg,
  596. struct sk_buff *resp)
  597. {
  598. int rc;
  599. u8 proto;
  600. struct nfc_target target;
  601. struct digital_sensf_res *sensf_res;
  602. if (IS_ERR(resp)) {
  603. rc = PTR_ERR(resp);
  604. resp = NULL;
  605. goto exit;
  606. }
  607. if (resp->len < DIGITAL_SENSF_RES_MIN_LENGTH) {
  608. rc = -EIO;
  609. goto exit;
  610. }
  611. if (!DIGITAL_DRV_CAPS_IN_CRC(ddev)) {
  612. rc = digital_skb_check_crc_f(resp);
  613. if (rc) {
  614. PROTOCOL_ERR("6.4.1.8");
  615. goto exit;
  616. }
  617. }
  618. skb_pull(resp, 1);
  619. memset(&target, 0, sizeof(struct nfc_target));
  620. sensf_res = (struct digital_sensf_res *)resp->data;
  621. memcpy(target.sensf_res, sensf_res, resp->len);
  622. target.sensf_res_len = resp->len;
  623. memcpy(target.nfcid2, sensf_res->nfcid2, NFC_NFCID2_MAXSIZE);
  624. target.nfcid2_len = NFC_NFCID2_MAXSIZE;
  625. if (target.nfcid2[0] == DIGITAL_SENSF_NFCID2_NFC_DEP_B1 &&
  626. target.nfcid2[1] == DIGITAL_SENSF_NFCID2_NFC_DEP_B2)
  627. proto = NFC_PROTO_NFC_DEP;
  628. else
  629. proto = NFC_PROTO_FELICA;
  630. rc = digital_target_found(ddev, &target, proto);
  631. exit:
  632. dev_kfree_skb(resp);
  633. if (rc)
  634. digital_poll_next_tech(ddev);
  635. }
  636. int digital_in_send_sensf_req(struct nfc_digital_dev *ddev, u8 rf_tech)
  637. {
  638. struct digital_sensf_req *sensf_req;
  639. struct sk_buff *skb;
  640. int rc;
  641. u8 size;
  642. rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH, rf_tech);
  643. if (rc)
  644. return rc;
  645. rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
  646. NFC_DIGITAL_FRAMING_NFCF);
  647. if (rc)
  648. return rc;
  649. size = sizeof(struct digital_sensf_req);
  650. skb = digital_skb_alloc(ddev, size);
  651. if (!skb)
  652. return -ENOMEM;
  653. skb_put(skb, size);
  654. sensf_req = (struct digital_sensf_req *)skb->data;
  655. sensf_req->cmd = DIGITAL_CMD_SENSF_REQ;
  656. sensf_req->sc1 = 0xFF;
  657. sensf_req->sc2 = 0xFF;
  658. sensf_req->rc = 0;
  659. sensf_req->tsn = 0;
  660. *(u8 *)skb_push(skb, 1) = size + 1;
  661. if (!DIGITAL_DRV_CAPS_IN_CRC(ddev))
  662. digital_skb_add_crc_f(skb);
  663. rc = digital_in_send_cmd(ddev, skb, 30, digital_in_recv_sensf_res,
  664. NULL);
  665. if (rc)
  666. kfree_skb(skb);
  667. return rc;
  668. }
  669. static void digital_in_recv_iso15693_inv_res(struct nfc_digital_dev *ddev,
  670. void *arg, struct sk_buff *resp)
  671. {
  672. struct digital_iso15693_inv_res *res;
  673. struct nfc_target *target = NULL;
  674. int rc;
  675. if (IS_ERR(resp)) {
  676. rc = PTR_ERR(resp);
  677. resp = NULL;
  678. goto out_free_skb;
  679. }
  680. if (resp->len != sizeof(*res)) {
  681. rc = -EIO;
  682. goto out_free_skb;
  683. }
  684. res = (struct digital_iso15693_inv_res *)resp->data;
  685. if (!DIGITAL_ISO15693_RES_IS_VALID(res->flags)) {
  686. PROTOCOL_ERR("ISO15693 - 10.3.1");
  687. rc = -EINVAL;
  688. goto out_free_skb;
  689. }
  690. target = kzalloc(sizeof(*target), GFP_KERNEL);
  691. if (!target) {
  692. rc = -ENOMEM;
  693. goto out_free_skb;
  694. }
  695. target->is_iso15693 = 1;
  696. target->iso15693_dsfid = res->dsfid;
  697. memcpy(target->iso15693_uid, &res->uid, sizeof(target->iso15693_uid));
  698. rc = digital_target_found(ddev, target, NFC_PROTO_ISO15693);
  699. kfree(target);
  700. out_free_skb:
  701. dev_kfree_skb(resp);
  702. if (rc)
  703. digital_poll_next_tech(ddev);
  704. }
  705. int digital_in_send_iso15693_inv_req(struct nfc_digital_dev *ddev, u8 rf_tech)
  706. {
  707. struct digital_iso15693_inv_req *req;
  708. struct sk_buff *skb;
  709. int rc;
  710. rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH,
  711. NFC_DIGITAL_RF_TECH_ISO15693);
  712. if (rc)
  713. return rc;
  714. rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
  715. NFC_DIGITAL_FRAMING_ISO15693_INVENTORY);
  716. if (rc)
  717. return rc;
  718. skb = digital_skb_alloc(ddev, sizeof(*req));
  719. if (!skb)
  720. return -ENOMEM;
  721. skb_put(skb, sizeof(*req) - sizeof(req->mask)); /* No mask */
  722. req = (struct digital_iso15693_inv_req *)skb->data;
  723. /* Single sub-carrier, high data rate, no AFI, single slot
  724. * Inventory command
  725. */
  726. req->flags = DIGITAL_ISO15693_REQ_FLAG_DATA_RATE |
  727. DIGITAL_ISO15693_REQ_FLAG_INVENTORY |
  728. DIGITAL_ISO15693_REQ_FLAG_NB_SLOTS;
  729. req->cmd = DIGITAL_CMD_ISO15693_INVENTORY_REQ;
  730. req->mask_len = 0;
  731. rc = digital_in_send_cmd(ddev, skb, 30,
  732. digital_in_recv_iso15693_inv_res, NULL);
  733. if (rc)
  734. kfree_skb(skb);
  735. return rc;
  736. }
  737. static int digital_tg_send_sel_res(struct nfc_digital_dev *ddev)
  738. {
  739. struct sk_buff *skb;
  740. int rc;
  741. skb = digital_skb_alloc(ddev, 1);
  742. if (!skb)
  743. return -ENOMEM;
  744. skb_put_u8(skb, DIGITAL_SEL_RES_NFC_DEP);
  745. if (!DIGITAL_DRV_CAPS_TG_CRC(ddev))
  746. digital_skb_add_crc_a(skb);
  747. rc = digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
  748. NFC_DIGITAL_FRAMING_NFCA_ANTICOL_COMPLETE);
  749. if (rc) {
  750. kfree_skb(skb);
  751. return rc;
  752. }
  753. rc = digital_tg_send_cmd(ddev, skb, 300, digital_tg_recv_atr_req,
  754. NULL);
  755. if (rc)
  756. kfree_skb(skb);
  757. return rc;
  758. }
  759. static void digital_tg_recv_sel_req(struct nfc_digital_dev *ddev, void *arg,
  760. struct sk_buff *resp)
  761. {
  762. int rc;
  763. if (IS_ERR(resp)) {
  764. rc = PTR_ERR(resp);
  765. resp = NULL;
  766. goto exit;
  767. }
  768. if (!DIGITAL_DRV_CAPS_TG_CRC(ddev)) {
  769. rc = digital_skb_check_crc_a(resp);
  770. if (rc) {
  771. PROTOCOL_ERR("4.4.1.3");
  772. goto exit;
  773. }
  774. }
  775. /* Silently ignore SEL_REQ content and send a SEL_RES for NFC-DEP */
  776. rc = digital_tg_send_sel_res(ddev);
  777. exit:
  778. if (rc)
  779. digital_poll_next_tech(ddev);
  780. dev_kfree_skb(resp);
  781. }
  782. static int digital_tg_send_sdd_res(struct nfc_digital_dev *ddev)
  783. {
  784. struct sk_buff *skb;
  785. struct digital_sdd_res *sdd_res;
  786. int rc, i;
  787. skb = digital_skb_alloc(ddev, sizeof(struct digital_sdd_res));
  788. if (!skb)
  789. return -ENOMEM;
  790. skb_put(skb, sizeof(struct digital_sdd_res));
  791. sdd_res = (struct digital_sdd_res *)skb->data;
  792. sdd_res->nfcid1[0] = 0x08;
  793. get_random_bytes(sdd_res->nfcid1 + 1, 3);
  794. sdd_res->bcc = 0;
  795. for (i = 0; i < 4; i++)
  796. sdd_res->bcc ^= sdd_res->nfcid1[i];
  797. rc = digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
  798. NFC_DIGITAL_FRAMING_NFCA_STANDARD_WITH_CRC_A);
  799. if (rc) {
  800. kfree_skb(skb);
  801. return rc;
  802. }
  803. rc = digital_tg_send_cmd(ddev, skb, 300, digital_tg_recv_sel_req,
  804. NULL);
  805. if (rc)
  806. kfree_skb(skb);
  807. return rc;
  808. }
  809. static void digital_tg_recv_sdd_req(struct nfc_digital_dev *ddev, void *arg,
  810. struct sk_buff *resp)
  811. {
  812. u8 *sdd_req;
  813. int rc;
  814. if (IS_ERR(resp)) {
  815. rc = PTR_ERR(resp);
  816. resp = NULL;
  817. goto exit;
  818. }
  819. sdd_req = resp->data;
  820. if (resp->len < 2 || sdd_req[0] != DIGITAL_CMD_SEL_REQ_CL1 ||
  821. sdd_req[1] != DIGITAL_SDD_REQ_SEL_PAR) {
  822. rc = -EINVAL;
  823. goto exit;
  824. }
  825. rc = digital_tg_send_sdd_res(ddev);
  826. exit:
  827. if (rc)
  828. digital_poll_next_tech(ddev);
  829. dev_kfree_skb(resp);
  830. }
  831. static int digital_tg_send_sens_res(struct nfc_digital_dev *ddev)
  832. {
  833. struct sk_buff *skb;
  834. u8 *sens_res;
  835. int rc;
  836. skb = digital_skb_alloc(ddev, 2);
  837. if (!skb)
  838. return -ENOMEM;
  839. sens_res = skb_put(skb, 2);
  840. sens_res[0] = (DIGITAL_SENS_RES_NFC_DEP >> 8) & 0xFF;
  841. sens_res[1] = DIGITAL_SENS_RES_NFC_DEP & 0xFF;
  842. rc = digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
  843. NFC_DIGITAL_FRAMING_NFCA_STANDARD);
  844. if (rc) {
  845. kfree_skb(skb);
  846. return rc;
  847. }
  848. rc = digital_tg_send_cmd(ddev, skb, 300, digital_tg_recv_sdd_req,
  849. NULL);
  850. if (rc)
  851. kfree_skb(skb);
  852. return rc;
  853. }
  854. void digital_tg_recv_sens_req(struct nfc_digital_dev *ddev, void *arg,
  855. struct sk_buff *resp)
  856. {
  857. u8 sens_req;
  858. int rc;
  859. if (IS_ERR(resp)) {
  860. rc = PTR_ERR(resp);
  861. resp = NULL;
  862. goto exit;
  863. }
  864. sens_req = resp->data[0];
  865. if (!resp->len || (sens_req != DIGITAL_CMD_SENS_REQ &&
  866. sens_req != DIGITAL_CMD_ALL_REQ)) {
  867. rc = -EINVAL;
  868. goto exit;
  869. }
  870. rc = digital_tg_send_sens_res(ddev);
  871. exit:
  872. if (rc)
  873. digital_poll_next_tech(ddev);
  874. dev_kfree_skb(resp);
  875. }
  876. static void digital_tg_recv_atr_or_sensf_req(struct nfc_digital_dev *ddev,
  877. void *arg, struct sk_buff *resp)
  878. {
  879. if (!IS_ERR(resp) && (resp->len >= 2) &&
  880. (resp->data[1] == DIGITAL_CMD_SENSF_REQ))
  881. digital_tg_recv_sensf_req(ddev, arg, resp);
  882. else
  883. digital_tg_recv_atr_req(ddev, arg, resp);
  884. return;
  885. }
  886. static int digital_tg_send_sensf_res(struct nfc_digital_dev *ddev,
  887. struct digital_sensf_req *sensf_req)
  888. {
  889. struct sk_buff *skb;
  890. u8 size;
  891. int rc;
  892. struct digital_sensf_res *sensf_res;
  893. size = sizeof(struct digital_sensf_res);
  894. if (sensf_req->rc == DIGITAL_SENSF_REQ_RC_NONE)
  895. size -= sizeof(sensf_res->rd);
  896. skb = digital_skb_alloc(ddev, size);
  897. if (!skb)
  898. return -ENOMEM;
  899. skb_put(skb, size);
  900. sensf_res = (struct digital_sensf_res *)skb->data;
  901. memset(sensf_res, 0, size);
  902. sensf_res->cmd = DIGITAL_CMD_SENSF_RES;
  903. sensf_res->nfcid2[0] = DIGITAL_SENSF_NFCID2_NFC_DEP_B1;
  904. sensf_res->nfcid2[1] = DIGITAL_SENSF_NFCID2_NFC_DEP_B2;
  905. get_random_bytes(&sensf_res->nfcid2[2], 6);
  906. switch (sensf_req->rc) {
  907. case DIGITAL_SENSF_REQ_RC_SC:
  908. sensf_res->rd[0] = sensf_req->sc1;
  909. sensf_res->rd[1] = sensf_req->sc2;
  910. break;
  911. case DIGITAL_SENSF_REQ_RC_AP:
  912. sensf_res->rd[0] = DIGITAL_SENSF_RES_RD_AP_B1;
  913. sensf_res->rd[1] = DIGITAL_SENSF_RES_RD_AP_B2;
  914. break;
  915. }
  916. *(u8 *)skb_push(skb, sizeof(u8)) = size + 1;
  917. if (!DIGITAL_DRV_CAPS_TG_CRC(ddev))
  918. digital_skb_add_crc_f(skb);
  919. rc = digital_tg_send_cmd(ddev, skb, 300,
  920. digital_tg_recv_atr_or_sensf_req, NULL);
  921. if (rc)
  922. kfree_skb(skb);
  923. return rc;
  924. }
  925. void digital_tg_recv_sensf_req(struct nfc_digital_dev *ddev, void *arg,
  926. struct sk_buff *resp)
  927. {
  928. struct digital_sensf_req *sensf_req;
  929. int rc;
  930. if (IS_ERR(resp)) {
  931. rc = PTR_ERR(resp);
  932. resp = NULL;
  933. goto exit;
  934. }
  935. if (!DIGITAL_DRV_CAPS_TG_CRC(ddev)) {
  936. rc = digital_skb_check_crc_f(resp);
  937. if (rc) {
  938. PROTOCOL_ERR("6.4.1.8");
  939. goto exit;
  940. }
  941. }
  942. if (resp->len != sizeof(struct digital_sensf_req) + 1) {
  943. rc = -EINVAL;
  944. goto exit;
  945. }
  946. skb_pull(resp, 1);
  947. sensf_req = (struct digital_sensf_req *)resp->data;
  948. if (sensf_req->cmd != DIGITAL_CMD_SENSF_REQ) {
  949. rc = -EINVAL;
  950. goto exit;
  951. }
  952. rc = digital_tg_send_sensf_res(ddev, sensf_req);
  953. exit:
  954. if (rc)
  955. digital_poll_next_tech(ddev);
  956. dev_kfree_skb(resp);
  957. }
  958. static int digital_tg_config_nfca(struct nfc_digital_dev *ddev)
  959. {
  960. int rc;
  961. rc = digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH,
  962. NFC_DIGITAL_RF_TECH_106A);
  963. if (rc)
  964. return rc;
  965. return digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
  966. NFC_DIGITAL_FRAMING_NFCA_NFC_DEP);
  967. }
  968. int digital_tg_listen_nfca(struct nfc_digital_dev *ddev, u8 rf_tech)
  969. {
  970. int rc;
  971. rc = digital_tg_config_nfca(ddev);
  972. if (rc)
  973. return rc;
  974. return digital_tg_listen(ddev, 300, digital_tg_recv_sens_req, NULL);
  975. }
  976. static int digital_tg_config_nfcf(struct nfc_digital_dev *ddev, u8 rf_tech)
  977. {
  978. int rc;
  979. rc = digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH, rf_tech);
  980. if (rc)
  981. return rc;
  982. return digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
  983. NFC_DIGITAL_FRAMING_NFCF_NFC_DEP);
  984. }
  985. int digital_tg_listen_nfcf(struct nfc_digital_dev *ddev, u8 rf_tech)
  986. {
  987. int rc;
  988. rc = digital_tg_config_nfcf(ddev, rf_tech);
  989. if (rc)
  990. return rc;
  991. return digital_tg_listen(ddev, 300, digital_tg_recv_sensf_req, NULL);
  992. }
  993. void digital_tg_recv_md_req(struct nfc_digital_dev *ddev, void *arg,
  994. struct sk_buff *resp)
  995. {
  996. u8 rf_tech;
  997. int rc;
  998. if (IS_ERR(resp)) {
  999. resp = NULL;
  1000. goto exit_free_skb;
  1001. }
  1002. rc = ddev->ops->tg_get_rf_tech(ddev, &rf_tech);
  1003. if (rc)
  1004. goto exit_free_skb;
  1005. switch (rf_tech) {
  1006. case NFC_DIGITAL_RF_TECH_106A:
  1007. rc = digital_tg_config_nfca(ddev);
  1008. if (rc)
  1009. goto exit_free_skb;
  1010. digital_tg_recv_sens_req(ddev, arg, resp);
  1011. break;
  1012. case NFC_DIGITAL_RF_TECH_212F:
  1013. case NFC_DIGITAL_RF_TECH_424F:
  1014. rc = digital_tg_config_nfcf(ddev, rf_tech);
  1015. if (rc)
  1016. goto exit_free_skb;
  1017. digital_tg_recv_sensf_req(ddev, arg, resp);
  1018. break;
  1019. default:
  1020. goto exit_free_skb;
  1021. }
  1022. return;
  1023. exit_free_skb:
  1024. digital_poll_next_tech(ddev);
  1025. dev_kfree_skb(resp);
  1026. }