aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc
diff options
context:
space:
mode:
authorThierry Escande <thierry.escande@linux.intel.com>2014-01-06 17:34:37 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2014-01-07 12:48:12 -0500
commit48e1044515967a0d88ee076045b2141535557d8e (patch)
tree564a069a933c1567908725f4a9150c2d7afbb5c4 /net/nfc
parent15203b4c79aaeb443f89ac3190eed3447bf2178b (diff)
NFC: digital: Set current target active on activate_target() call
The curr_protocol field of nfc_digital_dev structure used to determine if a target is currently active was set too soon, immediately when a target is found. This is not good since there is no other way than deactivate_target() to reset curr_protocol and if activate_target() is not called, the target remains active and it's not possible to put the device in poll mode anymore. With this patch curr_protocol is set when nfc core activates a target, puts a device up, or when an ATR_REQ is received in target mode. Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc')
-rw-r--r--net/nfc/digital_core.c28
-rw-r--r--net/nfc/digital_dep.c2
2 files changed, 28 insertions, 2 deletions
diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c
index 09fc95439955..c129d1571ca6 100644
--- a/net/nfc/digital_core.c
+++ b/net/nfc/digital_core.c
@@ -339,7 +339,6 @@ int digital_target_found(struct nfc_digital_dev *ddev,
339 pr_debug("rf_tech=%d, protocol=%d\n", rf_tech, protocol); 339 pr_debug("rf_tech=%d, protocol=%d\n", rf_tech, protocol);
340 340
341 ddev->curr_rf_tech = rf_tech; 341 ddev->curr_rf_tech = rf_tech;
342 ddev->curr_protocol = protocol;
343 342
344 if (DIGITAL_DRV_CAPS_IN_CRC(ddev)) { 343 if (DIGITAL_DRV_CAPS_IN_CRC(ddev)) {
345 ddev->skb_add_crc = digital_skb_add_crc_none; 344 ddev->skb_add_crc = digital_skb_add_crc_none;
@@ -541,8 +540,14 @@ static int digital_dep_link_up(struct nfc_dev *nfc_dev,
541 __u8 comm_mode, __u8 *gb, size_t gb_len) 540 __u8 comm_mode, __u8 *gb, size_t gb_len)
542{ 541{
543 struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev); 542 struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev);
543 int rc;
544
545 rc = digital_in_send_atr_req(ddev, target, comm_mode, gb, gb_len);
544 546
545 return digital_in_send_atr_req(ddev, target, comm_mode, gb, gb_len); 547 if (!rc)
548 ddev->curr_protocol = NFC_PROTO_NFC_DEP;
549
550 return rc;
546} 551}
547 552
548static int digital_dep_link_down(struct nfc_dev *nfc_dev) 553static int digital_dep_link_down(struct nfc_dev *nfc_dev)
@@ -557,6 +562,20 @@ static int digital_dep_link_down(struct nfc_dev *nfc_dev)
557static int digital_activate_target(struct nfc_dev *nfc_dev, 562static int digital_activate_target(struct nfc_dev *nfc_dev,
558 struct nfc_target *target, __u32 protocol) 563 struct nfc_target *target, __u32 protocol)
559{ 564{
565 struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev);
566
567 if (ddev->poll_tech_count) {
568 pr_err("Can't activate a target while polling\n");
569 return -EBUSY;
570 }
571
572 if (ddev->curr_protocol) {
573 pr_err("A target is already active\n");
574 return -EBUSY;
575 }
576
577 ddev->curr_protocol = protocol;
578
560 return 0; 579 return 0;
561} 580}
562 581
@@ -565,6 +584,11 @@ static void digital_deactivate_target(struct nfc_dev *nfc_dev,
565{ 584{
566 struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev); 585 struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev);
567 586
587 if (!ddev->curr_protocol) {
588 pr_err("No active target\n");
589 return;
590 }
591
568 ddev->curr_protocol = 0; 592 ddev->curr_protocol = 0;
569} 593}
570 594
diff --git a/net/nfc/digital_dep.c b/net/nfc/digital_dep.c
index 470a0b4016ed..562bec9ad8d9 100644
--- a/net/nfc/digital_dep.c
+++ b/net/nfc/digital_dep.c
@@ -681,6 +681,8 @@ void digital_tg_recv_atr_req(struct nfc_digital_dev *ddev, void *arg,
681 ddev->skb_check_crc = digital_skb_check_crc_none; 681 ddev->skb_check_crc = digital_skb_check_crc_none;
682 } 682 }
683 683
684 ddev->curr_protocol = NFC_PROTO_NFC_DEP_MASK;
685
684 rc = ddev->skb_check_crc(resp); 686 rc = ddev->skb_check_crc(resp);
685 if (rc) { 687 if (rc) {
686 PROTOCOL_ERR("14.4.1.6"); 688 PROTOCOL_ERR("14.4.1.6");