aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Ricard <christophe.ricard@gmail.com>2014-11-12 18:30:42 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2014-12-01 20:02:00 -0500
commitdeff5aa4699a36e792c00ad7e7a8aa811edd6296 (patch)
tree9288cd621357b3add9cc8711fc1800486a179e70
parentace91838eff5bb4665bfaffd428bee50934b08ca (diff)
NFC: hci: Add open pipe command handler
If our terminal connect with other host like UICC, it may create a pipe with us, the host controller will notify us new pipe created, after that UICC will open that pipe, if we don't handle that request, UICC may failed to continue initialize which may lead to card emulation feature failed to work Signed-off-by: Arron Wang <arron.wang@intel.com> Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--net/nfc/hci/core.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c
index 58b1610ca545..779a3c1fc344 100644
--- a/net/nfc/hci/core.c
+++ b/net/nfc/hci/core.c
@@ -167,6 +167,45 @@ exit:
167void nfc_hci_cmd_received(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd, 167void nfc_hci_cmd_received(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd,
168 struct sk_buff *skb) 168 struct sk_buff *skb)
169{ 169{
170 int r = 0;
171 u8 gate = nfc_hci_pipe2gate(hdev, pipe);
172 u8 local_gate, new_pipe;
173 u8 gate_opened = 0x00;
174
175 pr_debug("from gate %x pipe %x cmd %x\n", gate, pipe, cmd);
176
177 switch (cmd) {
178 case NFC_HCI_ADM_NOTIFY_PIPE_CREATED:
179 if (skb->len != 5) {
180 r = -EPROTO;
181 break;
182 }
183
184 local_gate = skb->data[3];
185 new_pipe = skb->data[4];
186 nfc_hci_send_response(hdev, gate, NFC_HCI_ANY_OK, NULL, 0);
187
188 /* save the new created pipe and bind with local gate,
189 * the description for skb->data[3] is destination gate id
190 * but since we received this cmd from host controller, we
191 * are the destination and it is our local gate
192 */
193 hdev->gate2pipe[local_gate] = new_pipe;
194 break;
195 case NFC_HCI_ANY_OPEN_PIPE:
196 /* if the pipe is already created, we allow remote host to
197 * open it
198 */
199 if (gate != 0xff)
200 nfc_hci_send_response(hdev, gate, NFC_HCI_ANY_OK,
201 &gate_opened, 1);
202 break;
203 default:
204 pr_info("Discarded unknown cmd %x to gate %x\n", cmd, gate);
205 r = -EINVAL;
206 break;
207 }
208
170 kfree_skb(skb); 209 kfree_skb(skb);
171} 210}
172 211