aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArron Wang <arron.wang@intel.com>2012-09-27 05:32:58 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-10-26 12:26:46 -0400
commite81076235b46189a776362ec5e4c6626bf1599ff (patch)
treef1623677ef0202907a94ef32ee52b928b9aa36f8
parentc40d17401f89f575a6ff5774abaa0838398b820c (diff)
NFC: Implement HCI DEP send and receive data
And implement the corresponding hooks for pn544. Signed-off-by: Arron Wang <arron.wang@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--drivers/nfc/pn544_hci.c36
-rw-r--r--include/net/nfc/hci.h3
-rw-r--r--net/nfc/hci/core.c19
3 files changed, 51 insertions, 7 deletions
diff --git a/drivers/nfc/pn544_hci.c b/drivers/nfc/pn544_hci.c
index 4ed2b8356017..554faf0a92d7 100644
--- a/drivers/nfc/pn544_hci.c
+++ b/drivers/nfc/pn544_hci.c
@@ -900,7 +900,7 @@ static void pn544_hci_data_exchange_cb(void *context, struct sk_buff *skb,
900 * <= 0: driver handled the data exchange 900 * <= 0: driver handled the data exchange
901 * 1: driver doesn't especially handle, please do standard processing 901 * 1: driver doesn't especially handle, please do standard processing
902 */ 902 */
903static int pn544_hci_data_exchange(struct nfc_hci_dev *hdev, 903static int pn544_hci_im_transceive(struct nfc_hci_dev *hdev,
904 struct nfc_target *target, 904 struct nfc_target *target,
905 struct sk_buff *skb, data_exchange_cb_t cb, 905 struct sk_buff *skb, data_exchange_cb_t cb,
906 void *cb_context) 906 void *cb_context)
@@ -953,11 +953,26 @@ static int pn544_hci_data_exchange(struct nfc_hci_dev *hdev,
953 return nfc_hci_send_cmd_async(hdev, target->hci_reader_gate, 953 return nfc_hci_send_cmd_async(hdev, target->hci_reader_gate,
954 PN544_JEWEL_RAW_CMD, skb->data, 954 PN544_JEWEL_RAW_CMD, skb->data,
955 skb->len, cb, cb_context); 955 skb->len, cb, cb_context);
956 case PN544_RF_READER_NFCIP1_INITIATOR_GATE:
957 *skb_push(skb, 1) = 0;
958
959 return nfc_hci_send_event(hdev, target->hci_reader_gate,
960 PN544_HCI_EVT_SND_DATA, skb->data,
961 skb->len);
956 default: 962 default:
957 return 1; 963 return 1;
958 } 964 }
959} 965}
960 966
967static int pn544_hci_tm_send(struct nfc_hci_dev *hdev, struct sk_buff *skb)
968{
969 /* Set default false for multiple information chaining */
970 *skb_push(skb, 1) = 0;
971
972 return nfc_hci_send_event(hdev, PN544_RF_READER_NFCIP1_TARGET_GATE,
973 PN544_HCI_EVT_SND_DATA, skb->data, skb->len);
974}
975
961static int pn544_hci_check_presence(struct nfc_hci_dev *hdev, 976static int pn544_hci_check_presence(struct nfc_hci_dev *hdev,
962 struct nfc_target *target) 977 struct nfc_target *target)
963{ 978{
@@ -996,6 +1011,22 @@ void pn544_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, u8 event,
996 nfc_hci_send_event(hdev, gate, 1011 nfc_hci_send_event(hdev, gate,
997 NFC_HCI_EVT_END_OPERATION, NULL, 0); 1012 NFC_HCI_EVT_END_OPERATION, NULL, 0);
998 break; 1013 break;
1014 case PN544_HCI_EVT_RCV_DATA:
1015 if (skb->len < 2) {
1016 r = -EPROTO;
1017 goto exit;
1018 }
1019
1020 if (skb->data[0] != 0) {
1021 pr_debug("data0 %d", skb->data[0]);
1022 r = -EPROTO;
1023 goto exit;
1024 }
1025
1026 skb_pull(skb, 2);
1027 nfc_tm_data_received(hdev->ndev, skb);
1028
1029 return;
999 default: 1030 default:
1000 break; 1031 break;
1001 } 1032 }
@@ -1014,7 +1045,8 @@ static struct nfc_hci_ops pn544_hci_ops = {
1014 .dep_link_down = pn544_hci_dep_link_down, 1045 .dep_link_down = pn544_hci_dep_link_down,
1015 .target_from_gate = pn544_hci_target_from_gate, 1046 .target_from_gate = pn544_hci_target_from_gate,
1016 .complete_target_discovered = pn544_hci_complete_target_discovered, 1047 .complete_target_discovered = pn544_hci_complete_target_discovered,
1017 .data_exchange = pn544_hci_data_exchange, 1048 .im_transceive = pn544_hci_im_transceive,
1049 .tm_send = pn544_hci_tm_send,
1018 .check_presence = pn544_hci_check_presence, 1050 .check_presence = pn544_hci_check_presence,
1019 .event_received = pn544_hci_event_received, 1051 .event_received = pn544_hci_event_received,
1020}; 1052};
diff --git a/include/net/nfc/hci.h b/include/net/nfc/hci.h
index 6b2d75dc7c01..bc87b8f2d692 100644
--- a/include/net/nfc/hci.h
+++ b/include/net/nfc/hci.h
@@ -45,9 +45,10 @@ struct nfc_hci_ops {
45 struct nfc_target *target); 45 struct nfc_target *target);
46 int (*complete_target_discovered) (struct nfc_hci_dev *hdev, u8 gate, 46 int (*complete_target_discovered) (struct nfc_hci_dev *hdev, u8 gate,
47 struct nfc_target *target); 47 struct nfc_target *target);
48 int (*data_exchange) (struct nfc_hci_dev *hdev, 48 int (*im_transceive) (struct nfc_hci_dev *hdev,
49 struct nfc_target *target, struct sk_buff *skb, 49 struct nfc_target *target, struct sk_buff *skb,
50 data_exchange_cb_t cb, void *cb_context); 50 data_exchange_cb_t cb, void *cb_context);
51 int (*tm_send)(struct nfc_hci_dev *hdev, struct sk_buff *skb);
51 int (*check_presence)(struct nfc_hci_dev *hdev, 52 int (*check_presence)(struct nfc_hci_dev *hdev,
52 struct nfc_target *target); 53 struct nfc_target *target);
53 void (*event_received)(struct nfc_hci_dev *hdev, u8 gate, u8 event, 54 void (*event_received)(struct nfc_hci_dev *hdev, u8 gate, u8 event,
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c
index 777deb84aa73..c2339c468d91 100644
--- a/net/nfc/hci/core.c
+++ b/net/nfc/hci/core.c
@@ -616,8 +616,8 @@ static int hci_transceive(struct nfc_dev *nfc_dev, struct nfc_target *target,
616 switch (target->hci_reader_gate) { 616 switch (target->hci_reader_gate) {
617 case NFC_HCI_RF_READER_A_GATE: 617 case NFC_HCI_RF_READER_A_GATE:
618 case NFC_HCI_RF_READER_B_GATE: 618 case NFC_HCI_RF_READER_B_GATE:
619 if (hdev->ops->data_exchange) { 619 if (hdev->ops->im_transceive) {
620 r = hdev->ops->data_exchange(hdev, target, skb, cb, 620 r = hdev->ops->im_transceive(hdev, target, skb, cb,
621 cb_context); 621 cb_context);
622 if (r <= 0) /* handled */ 622 if (r <= 0) /* handled */
623 break; 623 break;
@@ -634,8 +634,8 @@ static int hci_transceive(struct nfc_dev *nfc_dev, struct nfc_target *target,
634 skb->len, hci_transceive_cb, hdev); 634 skb->len, hci_transceive_cb, hdev);
635 break; 635 break;
636 default: 636 default:
637 if (hdev->ops->data_exchange) { 637 if (hdev->ops->im_transceive) {
638 r = hdev->ops->data_exchange(hdev, target, skb, cb, 638 r = hdev->ops->im_transceive(hdev, target, skb, cb,
639 cb_context); 639 cb_context);
640 if (r == 1) 640 if (r == 1)
641 r = -ENOTSUPP; 641 r = -ENOTSUPP;
@@ -650,6 +650,16 @@ static int hci_transceive(struct nfc_dev *nfc_dev, struct nfc_target *target,
650 return r; 650 return r;
651} 651}
652 652
653int hci_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb)
654{
655 struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
656
657 if (hdev->ops->tm_send)
658 return hdev->ops->tm_send(hdev, skb);
659 else
660 return -ENOTSUPP;
661}
662
653static int hci_check_presence(struct nfc_dev *nfc_dev, 663static int hci_check_presence(struct nfc_dev *nfc_dev,
654 struct nfc_target *target) 664 struct nfc_target *target)
655{ 665{
@@ -758,6 +768,7 @@ static struct nfc_ops hci_nfc_ops = {
758 .activate_target = hci_activate_target, 768 .activate_target = hci_activate_target,
759 .deactivate_target = hci_deactivate_target, 769 .deactivate_target = hci_deactivate_target,
760 .im_transceive = hci_transceive, 770 .im_transceive = hci_transceive,
771 .tm_send = hci_tm_send,
761 .check_presence = hci_check_presence, 772 .check_presence = hci_check_presence,
762}; 773};
763 774