diff options
author | Ilan Elias <ilane@ti.com> | 2012-08-15 04:46:24 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-09-24 18:17:23 -0400 |
commit | 767f19ae698e535f308663c48245fa951abebe20 (patch) | |
tree | 98c9353741a371d9c812f81c577fa36e0c4e5451 /net/nfc | |
parent | ac206838403411e617dbe0e7df1891ee957f1f9a (diff) |
NFC: Implement NCI dep_link_up and dep_link_down
During NFC-DEP target activation, store the remote
general bytes to be used later in dep_link_up.
When dep_link_up is called, activate the NFC-DEP target,
and forward the remote general bytes.
When dep_link_down is called, deactivate the target.
Signed-off-by: Ilan Elias <ilane@ti.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc')
-rw-r--r-- | net/nfc/nci/core.c | 36 | ||||
-rw-r--r-- | net/nfc/nci/ntf.c | 20 |
2 files changed, 55 insertions, 1 deletions
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index f017b781667a..acf9abb7d99b 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c | |||
@@ -564,7 +564,7 @@ static void nci_deactivate_target(struct nfc_dev *nfc_dev, | |||
564 | { | 564 | { |
565 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); | 565 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); |
566 | 566 | ||
567 | pr_debug("target_idx %d\n", target->idx); | 567 | pr_debug("entry\n"); |
568 | 568 | ||
569 | if (!ndev->target_active_prot) { | 569 | if (!ndev->target_active_prot) { |
570 | pr_err("unable to deactivate target, no active target\n"); | 570 | pr_err("unable to deactivate target, no active target\n"); |
@@ -579,6 +579,38 @@ static void nci_deactivate_target(struct nfc_dev *nfc_dev, | |||
579 | } | 579 | } |
580 | } | 580 | } |
581 | 581 | ||
582 | |||
583 | static int nci_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, | ||
584 | __u8 comm_mode, __u8 *gb, size_t gb_len) | ||
585 | { | ||
586 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); | ||
587 | int rc; | ||
588 | |||
589 | pr_debug("target_idx %d, comm_mode %d\n", target->idx, comm_mode); | ||
590 | |||
591 | rc = nci_activate_target(nfc_dev, target, NFC_PROTO_NFC_DEP); | ||
592 | if (rc) | ||
593 | return rc; | ||
594 | |||
595 | rc = nfc_set_remote_general_bytes(nfc_dev, ndev->remote_gb, | ||
596 | ndev->remote_gb_len); | ||
597 | if (!rc) | ||
598 | rc = nfc_dep_link_is_up(nfc_dev, target->idx, NFC_COMM_PASSIVE, | ||
599 | NFC_RF_INITIATOR); | ||
600 | |||
601 | return rc; | ||
602 | } | ||
603 | |||
604 | static int nci_dep_link_down(struct nfc_dev *nfc_dev) | ||
605 | { | ||
606 | pr_debug("entry\n"); | ||
607 | |||
608 | nci_deactivate_target(nfc_dev, NULL); | ||
609 | |||
610 | return 0; | ||
611 | } | ||
612 | |||
613 | |||
582 | static int nci_transceive(struct nfc_dev *nfc_dev, struct nfc_target *target, | 614 | static int nci_transceive(struct nfc_dev *nfc_dev, struct nfc_target *target, |
583 | struct sk_buff *skb, | 615 | struct sk_buff *skb, |
584 | data_exchange_cb_t cb, void *cb_context) | 616 | data_exchange_cb_t cb, void *cb_context) |
@@ -612,6 +644,8 @@ static struct nfc_ops nci_nfc_ops = { | |||
612 | .dev_down = nci_dev_down, | 644 | .dev_down = nci_dev_down, |
613 | .start_poll = nci_start_poll, | 645 | .start_poll = nci_start_poll, |
614 | .stop_poll = nci_stop_poll, | 646 | .stop_poll = nci_stop_poll, |
647 | .dep_link_up = nci_dep_link_up, | ||
648 | .dep_link_down = nci_dep_link_down, | ||
615 | .activate_target = nci_activate_target, | 649 | .activate_target = nci_activate_target, |
616 | .deactivate_target = nci_deactivate_target, | 650 | .deactivate_target = nci_deactivate_target, |
617 | .im_transceive = nci_transceive, | 651 | .im_transceive = nci_transceive, |
diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c index 6e17661a41a4..b2aa98ef0927 100644 --- a/net/nfc/nci/ntf.c +++ b/net/nfc/nci/ntf.c | |||
@@ -176,6 +176,8 @@ static int nci_add_new_protocol(struct nci_dev *ndev, | |||
176 | protocol = NFC_PROTO_ISO14443_B_MASK; | 176 | protocol = NFC_PROTO_ISO14443_B_MASK; |
177 | else if (rf_protocol == NCI_RF_PROTOCOL_T3T) | 177 | else if (rf_protocol == NCI_RF_PROTOCOL_T3T) |
178 | protocol = NFC_PROTO_FELICA_MASK; | 178 | protocol = NFC_PROTO_FELICA_MASK; |
179 | else if (rf_protocol == NCI_RF_PROTOCOL_NFC_DEP) | ||
180 | protocol = NFC_PROTO_NFC_DEP_MASK; | ||
179 | else | 181 | else |
180 | protocol = 0; | 182 | protocol = 0; |
181 | 183 | ||
@@ -505,6 +507,24 @@ exit: | |||
505 | 507 | ||
506 | /* set the available credits to initial value */ | 508 | /* set the available credits to initial value */ |
507 | atomic_set(&ndev->credits_cnt, ndev->initial_num_credits); | 509 | atomic_set(&ndev->credits_cnt, ndev->initial_num_credits); |
510 | |||
511 | /* store general bytes to be reported later in dep_link_up */ | ||
512 | if (ntf.rf_interface == NCI_RF_INTERFACE_NFC_DEP) { | ||
513 | ndev->remote_gb_len = 0; | ||
514 | |||
515 | if (ntf.activation_params_len > 0) { | ||
516 | /* ATR_RES general bytes at offset 15 */ | ||
517 | ndev->remote_gb_len = min_t(__u8, | ||
518 | (ntf.activation_params | ||
519 | .poll_nfc_dep.atr_res_len | ||
520 | - NFC_ATR_RES_GT_OFFSET), | ||
521 | NFC_MAX_GT_LEN); | ||
522 | memcpy(ndev->remote_gb, | ||
523 | (ntf.activation_params.poll_nfc_dep | ||
524 | .atr_res + NFC_ATR_RES_GT_OFFSET), | ||
525 | ndev->remote_gb_len); | ||
526 | } | ||
527 | } | ||
508 | } | 528 | } |
509 | 529 | ||
510 | if (atomic_read(&ndev->state) == NCI_DISCOVERY) { | 530 | if (atomic_read(&ndev->state) == NCI_DISCOVERY) { |