aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-08-05 16:18:20 -0400
committerDavid S. Miller <davem@davemloft.net>2014-08-05 16:18:20 -0400
commitaef4f5b6db654e512ebcccab2a6e50424c05d2f9 (patch)
tree4daaee5ac85d1128233a45908dac5212f38ec7aa /net/nfc
parent61ab9efddf51cbc0d57356a4d650785cf5721fbe (diff)
parentdc6be9f54a4ecb0a09765d1f515ed947d86b7528 (diff)
Merge tag 'master-2014-07-31' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next
Conflicts: net/6lowpan/iphc.c Minor conflicts in iphc.c were changes overlapping with some style cleanups. John W. Linville says: ==================== Please pull this last(?) batch of wireless change intended for the 3.17 stream... For the NFC bits, Samuel says: "This is a rather quiet one, we have: - A new driver from ST Microelectronics for their NCI ST21NFCB, including device tree support. - p2p support for the ST21NFCA driver - A few fixes an enhancements for the NFC digital laye" For the Atheros bits, Kalle says: "Michal and Janusz did some important RX aggregation fixes, basically we were missing RX reordering altogether. The 10.1 firmware doesn't support Ad-Hoc mode and Michal fixed ath10k so that it doesn't advertise Ad-Hoc support with that firmware. Also he implemented a workaround for a KVM issue." For the Bluetooth bits, Gustavo and Johan say: "To quote Gustavo from his previous request: 'Some last minute fixes for -next. We have a fix for a use after free in RFCOMM, another fix to an issue with ADV_DIRECT_IND and one for ADV_IND with auto-connection handling. Last, we added support for reading the codec and MWS setting for controllers that support these features.' Additionally there are fixes to LE scanning, an update to conform to the 4.1 core specification as well as fixes for tracking the page scan state. All of these fixes are important for 3.17." And, "We've got: - 6lowpan fixes/cleanups - A couple crash fixes, one for the Marvell HCI driver and another in LE SMP. - Fix for an incorrect connected state check - Fix for the bondable requirement during pairing (an issue which had crept in because of using "pairable" when in fact the actual meaning was "bondable" (these have different meanings in Bluetooth)" Along with those are some late-breaking hardware support patches in brcmfmac and b43 as well as a stray ath9k patch. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/nfc')
-rw-r--r--net/nfc/digital.h3
-rw-r--r--net/nfc/digital_core.c27
-rw-r--r--net/nfc/digital_dep.c11
-rw-r--r--net/nfc/digital_technology.c96
-rw-r--r--net/nfc/hci/core.c7
-rw-r--r--net/nfc/nci/ntf.c4
6 files changed, 128 insertions, 20 deletions
diff --git a/net/nfc/digital.h b/net/nfc/digital.h
index 71ad7eefddd4..3c39c72eb038 100644
--- a/net/nfc/digital.h
+++ b/net/nfc/digital.h
@@ -29,6 +29,7 @@
29#define DIGITAL_CMD_TG_SEND 1 29#define DIGITAL_CMD_TG_SEND 1
30#define DIGITAL_CMD_TG_LISTEN 2 30#define DIGITAL_CMD_TG_LISTEN 2
31#define DIGITAL_CMD_TG_LISTEN_MDAA 3 31#define DIGITAL_CMD_TG_LISTEN_MDAA 3
32#define DIGITAL_CMD_TG_LISTEN_MD 4
32 33
33#define DIGITAL_MAX_HEADER_LEN 7 34#define DIGITAL_MAX_HEADER_LEN 7
34#define DIGITAL_CRC_LEN 2 35#define DIGITAL_CRC_LEN 2
@@ -121,6 +122,8 @@ int digital_tg_send_dep_res(struct nfc_digital_dev *ddev, struct sk_buff *skb);
121 122
122int digital_tg_listen_nfca(struct nfc_digital_dev *ddev, u8 rf_tech); 123int digital_tg_listen_nfca(struct nfc_digital_dev *ddev, u8 rf_tech);
123int digital_tg_listen_nfcf(struct nfc_digital_dev *ddev, u8 rf_tech); 124int digital_tg_listen_nfcf(struct nfc_digital_dev *ddev, u8 rf_tech);
125void digital_tg_recv_md_req(struct nfc_digital_dev *ddev, void *arg,
126 struct sk_buff *resp);
124 127
125typedef u16 (*crc_func_t)(u16, const u8 *, size_t); 128typedef u16 (*crc_func_t)(u16, const u8 *, size_t);
126 129
diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c
index a6ce3c627e4e..009bcf317101 100644
--- a/net/nfc/digital_core.c
+++ b/net/nfc/digital_core.c
@@ -201,6 +201,11 @@ static void digital_wq_cmd(struct work_struct *work)
201 digital_send_cmd_complete, cmd); 201 digital_send_cmd_complete, cmd);
202 break; 202 break;
203 203
204 case DIGITAL_CMD_TG_LISTEN_MD:
205 rc = ddev->ops->tg_listen_md(ddev, cmd->timeout,
206 digital_send_cmd_complete, cmd);
207 break;
208
204 default: 209 default:
205 pr_err("Unknown cmd type %d\n", cmd->type); 210 pr_err("Unknown cmd type %d\n", cmd->type);
206 return; 211 return;
@@ -293,12 +298,19 @@ static int digital_tg_listen_mdaa(struct nfc_digital_dev *ddev, u8 rf_tech)
293 500, digital_tg_recv_atr_req, NULL); 298 500, digital_tg_recv_atr_req, NULL);
294} 299}
295 300
301static int digital_tg_listen_md(struct nfc_digital_dev *ddev, u8 rf_tech)
302{
303 return digital_send_cmd(ddev, DIGITAL_CMD_TG_LISTEN_MD, NULL, NULL, 500,
304 digital_tg_recv_md_req, NULL);
305}
306
296int digital_target_found(struct nfc_digital_dev *ddev, 307int digital_target_found(struct nfc_digital_dev *ddev,
297 struct nfc_target *target, u8 protocol) 308 struct nfc_target *target, u8 protocol)
298{ 309{
299 int rc; 310 int rc;
300 u8 framing; 311 u8 framing;
301 u8 rf_tech; 312 u8 rf_tech;
313 u8 poll_tech_count;
302 int (*check_crc)(struct sk_buff *skb); 314 int (*check_crc)(struct sk_buff *skb);
303 void (*add_crc)(struct sk_buff *skb); 315 void (*add_crc)(struct sk_buff *skb);
304 316
@@ -375,12 +387,16 @@ int digital_target_found(struct nfc_digital_dev *ddev,
375 return rc; 387 return rc;
376 388
377 target->supported_protocols = (1 << protocol); 389 target->supported_protocols = (1 << protocol);
378 rc = nfc_targets_found(ddev->nfc_dev, target, 1);
379 if (rc)
380 return rc;
381 390
391 poll_tech_count = ddev->poll_tech_count;
382 ddev->poll_tech_count = 0; 392 ddev->poll_tech_count = 0;
383 393
394 rc = nfc_targets_found(ddev->nfc_dev, target, 1);
395 if (rc) {
396 ddev->poll_tech_count = poll_tech_count;
397 return rc;
398 }
399
384 return 0; 400 return 0;
385} 401}
386 402
@@ -505,6 +521,9 @@ static int digital_start_poll(struct nfc_dev *nfc_dev, __u32 im_protocols,
505 if (ddev->ops->tg_listen_mdaa) { 521 if (ddev->ops->tg_listen_mdaa) {
506 digital_add_poll_tech(ddev, 0, 522 digital_add_poll_tech(ddev, 0,
507 digital_tg_listen_mdaa); 523 digital_tg_listen_mdaa);
524 } else if (ddev->ops->tg_listen_md) {
525 digital_add_poll_tech(ddev, 0,
526 digital_tg_listen_md);
508 } else { 527 } else {
509 digital_add_poll_tech(ddev, NFC_DIGITAL_RF_TECH_106A, 528 digital_add_poll_tech(ddev, NFC_DIGITAL_RF_TECH_106A,
510 digital_tg_listen_nfca); 529 digital_tg_listen_nfca);
@@ -732,7 +751,7 @@ struct nfc_digital_dev *nfc_digital_allocate_device(struct nfc_digital_ops *ops,
732 751
733 if (!ops->in_configure_hw || !ops->in_send_cmd || !ops->tg_listen || 752 if (!ops->in_configure_hw || !ops->in_send_cmd || !ops->tg_listen ||
734 !ops->tg_configure_hw || !ops->tg_send_cmd || !ops->abort_cmd || 753 !ops->tg_configure_hw || !ops->tg_send_cmd || !ops->abort_cmd ||
735 !ops->switch_rf) 754 !ops->switch_rf || (ops->tg_listen_md && !ops->tg_get_rf_tech))
736 return NULL; 755 return NULL;
737 756
738 ddev = kzalloc(sizeof(struct nfc_digital_dev), GFP_KERNEL); 757 ddev = kzalloc(sizeof(struct nfc_digital_dev), GFP_KERNEL);
diff --git a/net/nfc/digital_dep.c b/net/nfc/digital_dep.c
index 37deb173c956..e1638dab076d 100644
--- a/net/nfc/digital_dep.c
+++ b/net/nfc/digital_dep.c
@@ -671,6 +671,7 @@ void digital_tg_recv_atr_req(struct nfc_digital_dev *ddev, void *arg,
671 int rc; 671 int rc;
672 struct digital_atr_req *atr_req; 672 struct digital_atr_req *atr_req;
673 size_t gb_len, min_size; 673 size_t gb_len, min_size;
674 u8 poll_tech_count;
674 675
675 if (IS_ERR(resp)) { 676 if (IS_ERR(resp)) {
676 rc = PTR_ERR(resp); 677 rc = PTR_ERR(resp);
@@ -728,12 +729,16 @@ void digital_tg_recv_atr_req(struct nfc_digital_dev *ddev, void *arg,
728 goto exit; 729 goto exit;
729 730
730 gb_len = resp->len - sizeof(struct digital_atr_req); 731 gb_len = resp->len - sizeof(struct digital_atr_req);
732
733 poll_tech_count = ddev->poll_tech_count;
734 ddev->poll_tech_count = 0;
735
731 rc = nfc_tm_activated(ddev->nfc_dev, NFC_PROTO_NFC_DEP_MASK, 736 rc = nfc_tm_activated(ddev->nfc_dev, NFC_PROTO_NFC_DEP_MASK,
732 NFC_COMM_PASSIVE, atr_req->gb, gb_len); 737 NFC_COMM_PASSIVE, atr_req->gb, gb_len);
733 if (rc) 738 if (rc) {
739 ddev->poll_tech_count = poll_tech_count;
734 goto exit; 740 goto exit;
735 741 }
736 ddev->poll_tech_count = 0;
737 742
738 rc = 0; 743 rc = 0;
739exit: 744exit:
diff --git a/net/nfc/digital_technology.c b/net/nfc/digital_technology.c
index c2c1c0189b7c..fb58ed2dd41d 100644
--- a/net/nfc/digital_technology.c
+++ b/net/nfc/digital_technology.c
@@ -318,6 +318,8 @@ static void digital_in_recv_sel_res(struct nfc_digital_dev *ddev, void *arg,
318 318
319 if (DIGITAL_SEL_RES_IS_T2T(sel_res)) { 319 if (DIGITAL_SEL_RES_IS_T2T(sel_res)) {
320 nfc_proto = NFC_PROTO_MIFARE; 320 nfc_proto = NFC_PROTO_MIFARE;
321 } else if (DIGITAL_SEL_RES_IS_NFC_DEP(sel_res)) {
322 nfc_proto = NFC_PROTO_NFC_DEP;
321 } else if (DIGITAL_SEL_RES_IS_T4T(sel_res)) { 323 } else if (DIGITAL_SEL_RES_IS_T4T(sel_res)) {
322 rc = digital_in_send_rats(ddev, target); 324 rc = digital_in_send_rats(ddev, target);
323 if (rc) 325 if (rc)
@@ -327,8 +329,6 @@ static void digital_in_recv_sel_res(struct nfc_digital_dev *ddev, void *arg,
327 * done when receiving the ATS 329 * done when receiving the ATS
328 */ 330 */
329 goto exit_free_skb; 331 goto exit_free_skb;
330 } else if (DIGITAL_SEL_RES_IS_NFC_DEP(sel_res)) {
331 nfc_proto = NFC_PROTO_NFC_DEP;
332 } else { 332 } else {
333 rc = -EOPNOTSUPP; 333 rc = -EOPNOTSUPP;
334 goto exit; 334 goto exit;
@@ -944,6 +944,13 @@ static int digital_tg_send_sel_res(struct nfc_digital_dev *ddev)
944 if (!DIGITAL_DRV_CAPS_TG_CRC(ddev)) 944 if (!DIGITAL_DRV_CAPS_TG_CRC(ddev))
945 digital_skb_add_crc_a(skb); 945 digital_skb_add_crc_a(skb);
946 946
947 rc = digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
948 NFC_DIGITAL_FRAMING_NFCA_ANTICOL_COMPLETE);
949 if (rc) {
950 kfree_skb(skb);
951 return rc;
952 }
953
947 rc = digital_tg_send_cmd(ddev, skb, 300, digital_tg_recv_atr_req, 954 rc = digital_tg_send_cmd(ddev, skb, 300, digital_tg_recv_atr_req,
948 NULL); 955 NULL);
949 if (rc) 956 if (rc)
@@ -1002,6 +1009,13 @@ static int digital_tg_send_sdd_res(struct nfc_digital_dev *ddev)
1002 for (i = 0; i < 4; i++) 1009 for (i = 0; i < 4; i++)
1003 sdd_res->bcc ^= sdd_res->nfcid1[i]; 1010 sdd_res->bcc ^= sdd_res->nfcid1[i];
1004 1011
1012 rc = digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
1013 NFC_DIGITAL_FRAMING_NFCA_STANDARD_WITH_CRC_A);
1014 if (rc) {
1015 kfree_skb(skb);
1016 return rc;
1017 }
1018
1005 rc = digital_tg_send_cmd(ddev, skb, 300, digital_tg_recv_sel_req, 1019 rc = digital_tg_send_cmd(ddev, skb, 300, digital_tg_recv_sel_req,
1006 NULL); 1020 NULL);
1007 if (rc) 1021 if (rc)
@@ -1054,6 +1068,13 @@ static int digital_tg_send_sens_res(struct nfc_digital_dev *ddev)
1054 sens_res[0] = (DIGITAL_SENS_RES_NFC_DEP >> 8) & 0xFF; 1068 sens_res[0] = (DIGITAL_SENS_RES_NFC_DEP >> 8) & 0xFF;
1055 sens_res[1] = DIGITAL_SENS_RES_NFC_DEP & 0xFF; 1069 sens_res[1] = DIGITAL_SENS_RES_NFC_DEP & 0xFF;
1056 1070
1071 rc = digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
1072 NFC_DIGITAL_FRAMING_NFCA_STANDARD);
1073 if (rc) {
1074 kfree_skb(skb);
1075 return rc;
1076 }
1077
1057 rc = digital_tg_send_cmd(ddev, skb, 300, digital_tg_recv_sdd_req, 1078 rc = digital_tg_send_cmd(ddev, skb, 300, digital_tg_recv_sdd_req,
1058 NULL); 1079 NULL);
1059 if (rc) 1080 if (rc)
@@ -1197,33 +1218,48 @@ exit:
1197 dev_kfree_skb(resp); 1218 dev_kfree_skb(resp);
1198} 1219}
1199 1220
1200int digital_tg_listen_nfca(struct nfc_digital_dev *ddev, u8 rf_tech) 1221static int digital_tg_config_nfca(struct nfc_digital_dev *ddev)
1201{ 1222{
1202 int rc; 1223 int rc;
1203 1224
1204 rc = digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH, rf_tech); 1225 rc = digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH,
1226 NFC_DIGITAL_RF_TECH_106A);
1205 if (rc) 1227 if (rc)
1206 return rc; 1228 return rc;
1207 1229
1208 rc = digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING, 1230 return digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
1209 NFC_DIGITAL_FRAMING_NFCA_NFC_DEP); 1231 NFC_DIGITAL_FRAMING_NFCA_NFC_DEP);
1232}
1233
1234int digital_tg_listen_nfca(struct nfc_digital_dev *ddev, u8 rf_tech)
1235{
1236 int rc;
1237
1238 rc = digital_tg_config_nfca(ddev);
1210 if (rc) 1239 if (rc)
1211 return rc; 1240 return rc;
1212 1241
1213 return digital_tg_listen(ddev, 300, digital_tg_recv_sens_req, NULL); 1242 return digital_tg_listen(ddev, 300, digital_tg_recv_sens_req, NULL);
1214} 1243}
1215 1244
1216int digital_tg_listen_nfcf(struct nfc_digital_dev *ddev, u8 rf_tech) 1245static int digital_tg_config_nfcf(struct nfc_digital_dev *ddev, u8 rf_tech)
1217{ 1246{
1218 int rc; 1247 int rc;
1219 u8 *nfcid2;
1220 1248
1221 rc = digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH, rf_tech); 1249 rc = digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH, rf_tech);
1222 if (rc) 1250 if (rc)
1223 return rc; 1251 return rc;
1224 1252
1225 rc = digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING, 1253 return digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
1226 NFC_DIGITAL_FRAMING_NFCF_NFC_DEP); 1254 NFC_DIGITAL_FRAMING_NFCF_NFC_DEP);
1255}
1256
1257int digital_tg_listen_nfcf(struct nfc_digital_dev *ddev, u8 rf_tech)
1258{
1259 int rc;
1260 u8 *nfcid2;
1261
1262 rc = digital_tg_config_nfcf(ddev, rf_tech);
1227 if (rc) 1263 if (rc)
1228 return rc; 1264 return rc;
1229 1265
@@ -1237,3 +1273,43 @@ int digital_tg_listen_nfcf(struct nfc_digital_dev *ddev, u8 rf_tech)
1237 1273
1238 return digital_tg_listen(ddev, 300, digital_tg_recv_sensf_req, nfcid2); 1274 return digital_tg_listen(ddev, 300, digital_tg_recv_sensf_req, nfcid2);
1239} 1275}
1276
1277void digital_tg_recv_md_req(struct nfc_digital_dev *ddev, void *arg,
1278 struct sk_buff *resp)
1279{
1280 u8 rf_tech;
1281 int rc;
1282
1283 if (IS_ERR(resp)) {
1284 resp = NULL;
1285 goto exit_free_skb;
1286 }
1287
1288 rc = ddev->ops->tg_get_rf_tech(ddev, &rf_tech);
1289 if (rc)
1290 goto exit_free_skb;
1291
1292 switch (rf_tech) {
1293 case NFC_DIGITAL_RF_TECH_106A:
1294 rc = digital_tg_config_nfca(ddev);
1295 if (rc)
1296 goto exit_free_skb;
1297 digital_tg_recv_sens_req(ddev, arg, resp);
1298 break;
1299 case NFC_DIGITAL_RF_TECH_212F:
1300 case NFC_DIGITAL_RF_TECH_424F:
1301 rc = digital_tg_config_nfcf(ddev, rf_tech);
1302 if (rc)
1303 goto exit_free_skb;
1304 digital_tg_recv_sensf_req(ddev, arg, resp);
1305 break;
1306 default:
1307 goto exit_free_skb;
1308 }
1309
1310 return;
1311
1312exit_free_skb:
1313 digital_poll_next_tech(ddev);
1314 dev_kfree_skb(resp);
1315}
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c
index 47403705197e..117708263ced 100644
--- a/net/nfc/hci/core.c
+++ b/net/nfc/hci/core.c
@@ -553,8 +553,11 @@ static void hci_stop_poll(struct nfc_dev *nfc_dev)
553{ 553{
554 struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); 554 struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
555 555
556 nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE, 556 if (hdev->ops->stop_poll)
557 NFC_HCI_EVT_END_OPERATION, NULL, 0); 557 hdev->ops->stop_poll(hdev);
558 else
559 nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
560 NFC_HCI_EVT_END_OPERATION, NULL, 0);
558} 561}
559 562
560static int hci_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, 563static int hci_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target,
diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c
index f8f6af231381..df91bb95b12a 100644
--- a/net/nfc/nci/ntf.c
+++ b/net/nfc/nci/ntf.c
@@ -166,7 +166,9 @@ static int nci_add_new_protocol(struct nci_dev *ndev,
166 struct rf_tech_specific_params_nfcf_poll *nfcf_poll; 166 struct rf_tech_specific_params_nfcf_poll *nfcf_poll;
167 __u32 protocol; 167 __u32 protocol;
168 168
169 if (rf_protocol == NCI_RF_PROTOCOL_T2T) 169 if (rf_protocol == NCI_RF_PROTOCOL_T1T)
170 protocol = NFC_PROTO_JEWEL_MASK;
171 else if (rf_protocol == NCI_RF_PROTOCOL_T2T)
170 protocol = NFC_PROTO_MIFARE_MASK; 172 protocol = NFC_PROTO_MIFARE_MASK;
171 else if (rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) 173 else if (rf_protocol == NCI_RF_PROTOCOL_ISO_DEP)
172 if (rf_tech_and_mode == NCI_NFC_A_PASSIVE_POLL_MODE) 174 if (rf_tech_and_mode == NCI_NFC_A_PASSIVE_POLL_MODE)