digital_technology.c 27 KB

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