aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorChristophe Ricard <christophe.ricard@gmail.com>2014-11-12 18:30:39 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2014-12-01 20:02:00 -0500
commita4415e761404324dfbf7aa80aa3980103d7071f9 (patch)
treeb2f1b093a0387561b6ea2010c38949242ad6e183 /drivers/nfc
parenta688bf55c5908d2206307a9f76d31172ee2b2d92 (diff)
NFC: st21nfca: Rework st21nfca_hci_event_received to route event to relevent gate.
As many event with the same id can come from several gates, it will be easier to manage each of them by gate. Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/st21nfca/st21nfca.c32
-rw-r--r--drivers/nfc/st21nfca/st21nfca.h2
-rw-r--r--drivers/nfc/st21nfca/st21nfca_dep.c47
-rw-r--r--drivers/nfc/st21nfca/st21nfca_dep.h4
4 files changed, 50 insertions, 35 deletions
diff --git a/drivers/nfc/st21nfca/st21nfca.c b/drivers/nfc/st21nfca/st21nfca.c
index a89e56c2c749..f2596c8d68b0 100644
--- a/drivers/nfc/st21nfca/st21nfca.c
+++ b/drivers/nfc/st21nfca/st21nfca.c
@@ -77,10 +77,6 @@
77 ((p & 0x0f) == (ST21NFCA_DM_PIPE_CREATED | ST21NFCA_DM_PIPE_OPEN)) 77 ((p & 0x0f) == (ST21NFCA_DM_PIPE_CREATED | ST21NFCA_DM_PIPE_OPEN))
78 78
79#define ST21NFCA_NFC_MODE 0x03 /* NFC_MODE parameter*/ 79#define ST21NFCA_NFC_MODE 0x03 /* NFC_MODE parameter*/
80#define ST21NFCA_EVT_FIELD_ON 0x11
81#define ST21NFCA_EVT_CARD_DEACTIVATED 0x12
82#define ST21NFCA_EVT_CARD_ACTIVATED 0x13
83#define ST21NFCA_EVT_FIELD_OFF 0x14
84 80
85static DECLARE_BITMAP(dev_mask, ST21NFCA_NUM_DEVICES); 81static DECLARE_BITMAP(dev_mask, ST21NFCA_NUM_DEVICES);
86 82
@@ -841,31 +837,11 @@ static int st21nfca_hci_check_presence(struct nfc_hci_dev *hdev,
841static int st21nfca_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, 837static int st21nfca_hci_event_received(struct nfc_hci_dev *hdev, u8 gate,
842 u8 event, struct sk_buff *skb) 838 u8 event, struct sk_buff *skb)
843{ 839{
844 int r; 840 pr_debug("hci event: %d gate: %x\n", event, gate);
845 struct st21nfca_hci_info *info = nfc_hci_get_clientdata(hdev);
846
847 pr_debug("hci event: %d\n", event);
848 841
849 switch (event) { 842 switch (gate) {
850 case ST21NFCA_EVT_CARD_ACTIVATED: 843 case ST21NFCA_RF_CARD_F_GATE:
851 if (gate == ST21NFCA_RF_CARD_F_GATE) 844 return st21nfca_dep_event_received(hdev, event, skb);
852 info->dep_info.curr_nfc_dep_pni = 0;
853 break;
854 case ST21NFCA_EVT_CARD_DEACTIVATED:
855 break;
856 case ST21NFCA_EVT_FIELD_ON:
857 break;
858 case ST21NFCA_EVT_FIELD_OFF:
859 break;
860 case ST21NFCA_EVT_SEND_DATA:
861 if (gate == ST21NFCA_RF_CARD_F_GATE) {
862 r = st21nfca_tm_event_send_data(hdev, skb, gate);
863 if (r < 0)
864 return r;
865 return 0;
866 }
867 info->dep_info.curr_nfc_dep_pni = 0;
868 return 1;
869 default: 845 default:
870 return 1; 846 return 1;
871 } 847 }
diff --git a/drivers/nfc/st21nfca/st21nfca.h b/drivers/nfc/st21nfca/st21nfca.h
index a0b77f1ba6d9..7c2a85292230 100644
--- a/drivers/nfc/st21nfca/st21nfca.h
+++ b/drivers/nfc/st21nfca/st21nfca.h
@@ -85,6 +85,4 @@ struct st21nfca_hci_info {
85 85
86#define ST21NFCA_RF_CARD_F_GATE 0x24 86#define ST21NFCA_RF_CARD_F_GATE 0x24
87 87
88#define ST21NFCA_EVT_SEND_DATA 0x10
89
90#endif /* __LOCAL_ST21NFCA_H_ */ 88#endif /* __LOCAL_ST21NFCA_H_ */
diff --git a/drivers/nfc/st21nfca/st21nfca_dep.c b/drivers/nfc/st21nfca/st21nfca_dep.c
index bfb6df56c505..8882181d65de 100644
--- a/drivers/nfc/st21nfca/st21nfca_dep.c
+++ b/drivers/nfc/st21nfca/st21nfca_dep.c
@@ -49,6 +49,12 @@
49#define ST21NFCA_LR_BITS_PAYLOAD_SIZE_254B 0x30 49#define ST21NFCA_LR_BITS_PAYLOAD_SIZE_254B 0x30
50#define ST21NFCA_GB_BIT 0x02 50#define ST21NFCA_GB_BIT 0x02
51 51
52#define ST21NFCA_EVT_SEND_DATA 0x10
53#define ST21NFCA_EVT_FIELD_ON 0x11
54#define ST21NFCA_EVT_CARD_DEACTIVATED 0x12
55#define ST21NFCA_EVT_CARD_ACTIVATED 0x13
56#define ST21NFCA_EVT_FIELD_OFF 0x14
57
52#define ST21NFCA_EVT_CARD_F_BITRATE 0x16 58#define ST21NFCA_EVT_CARD_F_BITRATE 0x16
53#define ST21NFCA_EVT_READER_F_BITRATE 0x13 59#define ST21NFCA_EVT_READER_F_BITRATE 0x13
54#define ST21NFCA_PSL_REQ_SEND_SPEED(brs) (brs & 0x38) 60#define ST21NFCA_PSL_REQ_SEND_SPEED(brs) (brs & 0x38)
@@ -372,8 +378,8 @@ exit:
372 return r; 378 return r;
373} 379}
374 380
375int st21nfca_tm_event_send_data(struct nfc_hci_dev *hdev, struct sk_buff *skb, 381static int st21nfca_tm_event_send_data(struct nfc_hci_dev *hdev,
376 u8 gate) 382 struct sk_buff *skb)
377{ 383{
378 u8 cmd0, cmd1; 384 u8 cmd0, cmd1;
379 int r; 385 int r;
@@ -400,7 +406,42 @@ int st21nfca_tm_event_send_data(struct nfc_hci_dev *hdev, struct sk_buff *skb,
400 } 406 }
401 return r; 407 return r;
402} 408}
403EXPORT_SYMBOL(st21nfca_tm_event_send_data); 409
410/*
411 * Returns:
412 * <= 0: driver handled the event, skb consumed
413 * 1: driver does not handle the event, please do standard processing
414 */
415int st21nfca_dep_event_received(struct nfc_hci_dev *hdev,
416 u8 event, struct sk_buff *skb)
417{
418 int r = 0;
419 struct st21nfca_hci_info *info = nfc_hci_get_clientdata(hdev);
420
421 pr_debug("dep event: %d\n", event);
422
423 switch (event) {
424 case ST21NFCA_EVT_CARD_ACTIVATED:
425 info->dep_info.curr_nfc_dep_pni = 0;
426 break;
427 case ST21NFCA_EVT_CARD_DEACTIVATED:
428 break;
429 case ST21NFCA_EVT_FIELD_ON:
430 break;
431 case ST21NFCA_EVT_FIELD_OFF:
432 break;
433 case ST21NFCA_EVT_SEND_DATA:
434 r = st21nfca_tm_event_send_data(hdev, skb);
435 if (r < 0)
436 return r;
437 return 0;
438 default:
439 return 1;
440 }
441 kfree_skb(skb);
442 return r;
443}
444EXPORT_SYMBOL(st21nfca_dep_event_received);
404 445
405static void st21nfca_im_send_psl_req(struct nfc_hci_dev *hdev, u8 did, u8 bsi, 446static void st21nfca_im_send_psl_req(struct nfc_hci_dev *hdev, u8 did, u8 bsi,
406 u8 bri, u8 lri) 447 u8 bri, u8 lri)
diff --git a/drivers/nfc/st21nfca/st21nfca_dep.h b/drivers/nfc/st21nfca/st21nfca_dep.h
index ca213dee9c6e..baf4664b4fc4 100644
--- a/drivers/nfc/st21nfca/st21nfca_dep.h
+++ b/drivers/nfc/st21nfca/st21nfca_dep.h
@@ -32,8 +32,8 @@ struct st21nfca_dep_info {
32 u8 lri; 32 u8 lri;
33} __packed; 33} __packed;
34 34
35int st21nfca_tm_event_send_data(struct nfc_hci_dev *hdev, struct sk_buff *skb, 35int st21nfca_dep_event_received(struct nfc_hci_dev *hdev,
36 u8 gate); 36 u8 event, struct sk_buff *skb);
37int st21nfca_tm_send_dep_res(struct nfc_hci_dev *hdev, struct sk_buff *skb); 37int st21nfca_tm_send_dep_res(struct nfc_hci_dev *hdev, struct sk_buff *skb);
38 38
39int st21nfca_im_send_atr_req(struct nfc_hci_dev *hdev, u8 *gb, size_t gb_len); 39int st21nfca_im_send_atr_req(struct nfc_hci_dev *hdev, u8 *gb, size_t gb_len);