Commit a4415e76 authored by Christophe Ricard's avatar Christophe Ricard Committed by Samuel Ortiz

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: default avatarChristophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent a688bf55
...@@ -77,10 +77,6 @@ ...@@ -77,10 +77,6 @@
((p & 0x0f) == (ST21NFCA_DM_PIPE_CREATED | ST21NFCA_DM_PIPE_OPEN)) ((p & 0x0f) == (ST21NFCA_DM_PIPE_CREATED | ST21NFCA_DM_PIPE_OPEN))
#define ST21NFCA_NFC_MODE 0x03 /* NFC_MODE parameter*/ #define ST21NFCA_NFC_MODE 0x03 /* NFC_MODE parameter*/
#define ST21NFCA_EVT_FIELD_ON 0x11
#define ST21NFCA_EVT_CARD_DEACTIVATED 0x12
#define ST21NFCA_EVT_CARD_ACTIVATED 0x13
#define ST21NFCA_EVT_FIELD_OFF 0x14
static DECLARE_BITMAP(dev_mask, ST21NFCA_NUM_DEVICES); static DECLARE_BITMAP(dev_mask, ST21NFCA_NUM_DEVICES);
...@@ -841,31 +837,11 @@ static int st21nfca_hci_check_presence(struct nfc_hci_dev *hdev, ...@@ -841,31 +837,11 @@ static int st21nfca_hci_check_presence(struct nfc_hci_dev *hdev,
static int st21nfca_hci_event_received(struct nfc_hci_dev *hdev, u8 gate, static int st21nfca_hci_event_received(struct nfc_hci_dev *hdev, u8 gate,
u8 event, struct sk_buff *skb) u8 event, struct sk_buff *skb)
{ {
int r; pr_debug("hci event: %d gate: %x\n", event, gate);
struct st21nfca_hci_info *info = nfc_hci_get_clientdata(hdev);
pr_debug("hci event: %d\n", event); switch (gate) {
case ST21NFCA_RF_CARD_F_GATE:
switch (event) { return st21nfca_dep_event_received(hdev, event, skb);
case ST21NFCA_EVT_CARD_ACTIVATED:
if (gate == ST21NFCA_RF_CARD_F_GATE)
info->dep_info.curr_nfc_dep_pni = 0;
break;
case ST21NFCA_EVT_CARD_DEACTIVATED:
break;
case ST21NFCA_EVT_FIELD_ON:
break;
case ST21NFCA_EVT_FIELD_OFF:
break;
case ST21NFCA_EVT_SEND_DATA:
if (gate == ST21NFCA_RF_CARD_F_GATE) {
r = st21nfca_tm_event_send_data(hdev, skb, gate);
if (r < 0)
return r;
return 0;
}
info->dep_info.curr_nfc_dep_pni = 0;
return 1;
default: default:
return 1; return 1;
} }
......
...@@ -85,6 +85,4 @@ struct st21nfca_hci_info { ...@@ -85,6 +85,4 @@ struct st21nfca_hci_info {
#define ST21NFCA_RF_CARD_F_GATE 0x24 #define ST21NFCA_RF_CARD_F_GATE 0x24
#define ST21NFCA_EVT_SEND_DATA 0x10
#endif /* __LOCAL_ST21NFCA_H_ */ #endif /* __LOCAL_ST21NFCA_H_ */
...@@ -49,6 +49,12 @@ ...@@ -49,6 +49,12 @@
#define ST21NFCA_LR_BITS_PAYLOAD_SIZE_254B 0x30 #define ST21NFCA_LR_BITS_PAYLOAD_SIZE_254B 0x30
#define ST21NFCA_GB_BIT 0x02 #define ST21NFCA_GB_BIT 0x02
#define ST21NFCA_EVT_SEND_DATA 0x10
#define ST21NFCA_EVT_FIELD_ON 0x11
#define ST21NFCA_EVT_CARD_DEACTIVATED 0x12
#define ST21NFCA_EVT_CARD_ACTIVATED 0x13
#define ST21NFCA_EVT_FIELD_OFF 0x14
#define ST21NFCA_EVT_CARD_F_BITRATE 0x16 #define ST21NFCA_EVT_CARD_F_BITRATE 0x16
#define ST21NFCA_EVT_READER_F_BITRATE 0x13 #define ST21NFCA_EVT_READER_F_BITRATE 0x13
#define ST21NFCA_PSL_REQ_SEND_SPEED(brs) (brs & 0x38) #define ST21NFCA_PSL_REQ_SEND_SPEED(brs) (brs & 0x38)
...@@ -372,8 +378,8 @@ static int st21nfca_tm_recv_dep_req(struct nfc_hci_dev *hdev, ...@@ -372,8 +378,8 @@ static int st21nfca_tm_recv_dep_req(struct nfc_hci_dev *hdev,
return r; return r;
} }
int st21nfca_tm_event_send_data(struct nfc_hci_dev *hdev, struct sk_buff *skb, static int st21nfca_tm_event_send_data(struct nfc_hci_dev *hdev,
u8 gate) struct sk_buff *skb)
{ {
u8 cmd0, cmd1; u8 cmd0, cmd1;
int r; int r;
...@@ -400,7 +406,42 @@ int st21nfca_tm_event_send_data(struct nfc_hci_dev *hdev, struct sk_buff *skb, ...@@ -400,7 +406,42 @@ int st21nfca_tm_event_send_data(struct nfc_hci_dev *hdev, struct sk_buff *skb,
} }
return r; return r;
} }
EXPORT_SYMBOL(st21nfca_tm_event_send_data);
/*
* Returns:
* <= 0: driver handled the event, skb consumed
* 1: driver does not handle the event, please do standard processing
*/
int st21nfca_dep_event_received(struct nfc_hci_dev *hdev,
u8 event, struct sk_buff *skb)
{
int r = 0;
struct st21nfca_hci_info *info = nfc_hci_get_clientdata(hdev);
pr_debug("dep event: %d\n", event);
switch (event) {
case ST21NFCA_EVT_CARD_ACTIVATED:
info->dep_info.curr_nfc_dep_pni = 0;
break;
case ST21NFCA_EVT_CARD_DEACTIVATED:
break;
case ST21NFCA_EVT_FIELD_ON:
break;
case ST21NFCA_EVT_FIELD_OFF:
break;
case ST21NFCA_EVT_SEND_DATA:
r = st21nfca_tm_event_send_data(hdev, skb);
if (r < 0)
return r;
return 0;
default:
return 1;
}
kfree_skb(skb);
return r;
}
EXPORT_SYMBOL(st21nfca_dep_event_received);
static void st21nfca_im_send_psl_req(struct nfc_hci_dev *hdev, u8 did, u8 bsi, static void st21nfca_im_send_psl_req(struct nfc_hci_dev *hdev, u8 did, u8 bsi,
u8 bri, u8 lri) u8 bri, u8 lri)
......
...@@ -32,8 +32,8 @@ struct st21nfca_dep_info { ...@@ -32,8 +32,8 @@ struct st21nfca_dep_info {
u8 lri; u8 lri;
} __packed; } __packed;
int st21nfca_tm_event_send_data(struct nfc_hci_dev *hdev, struct sk_buff *skb, int st21nfca_dep_event_received(struct nfc_hci_dev *hdev,
u8 gate); u8 event, struct sk_buff *skb);
int st21nfca_tm_send_dep_res(struct nfc_hci_dev *hdev, struct sk_buff *skb); int st21nfca_tm_send_dep_res(struct nfc_hci_dev *hdev, struct sk_buff *skb);
int st21nfca_im_send_atr_req(struct nfc_hci_dev *hdev, u8 *gb, size_t gb_len); int st21nfca_im_send_atr_req(struct nfc_hci_dev *hdev, u8 *gb, size_t gb_len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment