diff options
author | Christophe Ricard <christophe.ricard@gmail.com> | 2015-01-26 19:18:12 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2015-01-27 17:39:32 -0500 |
commit | 118278f20aa89efe45fa1e2b1829f198d557f8fe (patch) | |
tree | edac7f90f582e3c29f13290a016f12b0068a4ff2 /net/nfc | |
parent | fda7a49cb991e9da15f5955d1ea292f8ec74f27a (diff) |
NFC: hci: Add pipes table to reference them with a tuple {gate, host}
In order to keep host source information on specific hci event (such as
evt_connectivity or evt_transaction) and because 2 pipes can be connected
to the same gate, it is necessary to add a table referencing every pipe
with a {gate, host} tuple.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc')
-rw-r--r-- | net/nfc/hci/command.c | 6 | ||||
-rw-r--r-- | net/nfc/hci/core.c | 36 |
2 files changed, 35 insertions, 7 deletions
diff --git a/net/nfc/hci/command.c b/net/nfc/hci/command.c index 91df487aa0a9..9acf586c98d4 100644 --- a/net/nfc/hci/command.c +++ b/net/nfc/hci/command.c | |||
@@ -331,7 +331,7 @@ int nfc_hci_disconnect_all_gates(struct nfc_hci_dev *hdev) | |||
331 | if (r < 0) | 331 | if (r < 0) |
332 | return r; | 332 | return r; |
333 | 333 | ||
334 | memset(hdev->gate2pipe, NFC_HCI_INVALID_PIPE, sizeof(hdev->gate2pipe)); | 334 | nfc_hci_reset_pipes(hdev); |
335 | 335 | ||
336 | return 0; | 336 | return 0; |
337 | } | 337 | } |
@@ -345,7 +345,7 @@ int nfc_hci_connect_gate(struct nfc_hci_dev *hdev, u8 dest_host, u8 dest_gate, | |||
345 | 345 | ||
346 | pr_debug("\n"); | 346 | pr_debug("\n"); |
347 | 347 | ||
348 | if (hdev->gate2pipe[dest_gate] == NFC_HCI_DO_NOT_CREATE_PIPE) | 348 | if (pipe == NFC_HCI_DO_NOT_CREATE_PIPE) |
349 | return 0; | 349 | return 0; |
350 | 350 | ||
351 | if (hdev->gate2pipe[dest_gate] != NFC_HCI_INVALID_PIPE) | 351 | if (hdev->gate2pipe[dest_gate] != NFC_HCI_INVALID_PIPE) |
@@ -380,6 +380,8 @@ open_pipe: | |||
380 | return r; | 380 | return r; |
381 | } | 381 | } |
382 | 382 | ||
383 | hdev->pipes[pipe].gate = dest_gate; | ||
384 | hdev->pipes[pipe].dest_host = dest_host; | ||
383 | hdev->gate2pipe[dest_gate] = pipe; | 385 | hdev->gate2pipe[dest_gate] = pipe; |
384 | 386 | ||
385 | return 0; | 387 | return 0; |
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c index 12a9a4b956d2..8f8abfed7f65 100644 --- a/net/nfc/hci/core.c +++ b/net/nfc/hci/core.c | |||
@@ -46,6 +46,32 @@ int nfc_hci_result_to_errno(u8 result) | |||
46 | } | 46 | } |
47 | EXPORT_SYMBOL(nfc_hci_result_to_errno); | 47 | EXPORT_SYMBOL(nfc_hci_result_to_errno); |
48 | 48 | ||
49 | void nfc_hci_reset_pipes(struct nfc_hci_dev *hdev) | ||
50 | { | ||
51 | int i = 0; | ||
52 | |||
53 | for (i = 0; i < NFC_HCI_MAX_PIPES; i++) { | ||
54 | hdev->pipes[i].gate = NFC_HCI_INVALID_GATE; | ||
55 | hdev->pipes[i].dest_host = NFC_HCI_INVALID_HOST; | ||
56 | } | ||
57 | memset(hdev->gate2pipe, NFC_HCI_INVALID_PIPE, sizeof(hdev->gate2pipe)); | ||
58 | } | ||
59 | EXPORT_SYMBOL(nfc_hci_reset_pipes); | ||
60 | |||
61 | void nfc_hci_reset_pipes_per_host(struct nfc_hci_dev *hdev, u8 host) | ||
62 | { | ||
63 | int i = 0; | ||
64 | |||
65 | for (i = 0; i < NFC_HCI_MAX_PIPES; i++) { | ||
66 | if (hdev->pipes[i].dest_host != host) | ||
67 | continue; | ||
68 | |||
69 | hdev->pipes[i].gate = NFC_HCI_INVALID_GATE; | ||
70 | hdev->pipes[i].dest_host = NFC_HCI_INVALID_HOST; | ||
71 | } | ||
72 | } | ||
73 | EXPORT_SYMBOL(nfc_hci_reset_pipes_per_host); | ||
74 | |||
49 | static void nfc_hci_msg_tx_work(struct work_struct *work) | 75 | static void nfc_hci_msg_tx_work(struct work_struct *work) |
50 | { | 76 | { |
51 | struct nfc_hci_dev *hdev = container_of(work, struct nfc_hci_dev, | 77 | struct nfc_hci_dev *hdev = container_of(work, struct nfc_hci_dev, |
@@ -168,7 +194,7 @@ void nfc_hci_cmd_received(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd, | |||
168 | struct sk_buff *skb) | 194 | struct sk_buff *skb) |
169 | { | 195 | { |
170 | int r = 0; | 196 | int r = 0; |
171 | u8 gate = nfc_hci_pipe2gate(hdev, pipe); | 197 | u8 gate = hdev->pipes[pipe].gate; |
172 | u8 local_gate, new_pipe; | 198 | u8 local_gate, new_pipe; |
173 | u8 gate_opened = 0x00; | 199 | u8 gate_opened = 0x00; |
174 | 200 | ||
@@ -330,9 +356,9 @@ void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event, | |||
330 | struct sk_buff *skb) | 356 | struct sk_buff *skb) |
331 | { | 357 | { |
332 | int r = 0; | 358 | int r = 0; |
333 | u8 gate = nfc_hci_pipe2gate(hdev, pipe); | 359 | u8 gate = hdev->pipes[pipe].gate; |
334 | 360 | ||
335 | if (gate == 0xff) { | 361 | if (gate == NFC_HCI_INVALID_GATE) { |
336 | pr_err("Discarded event %x to unopened pipe %x\n", event, pipe); | 362 | pr_err("Discarded event %x to unopened pipe %x\n", event, pipe); |
337 | goto exit; | 363 | goto exit; |
338 | } | 364 | } |
@@ -573,7 +599,7 @@ static int hci_dev_down(struct nfc_dev *nfc_dev) | |||
573 | if (hdev->ops->close) | 599 | if (hdev->ops->close) |
574 | hdev->ops->close(hdev); | 600 | hdev->ops->close(hdev); |
575 | 601 | ||
576 | memset(hdev->gate2pipe, NFC_HCI_INVALID_PIPE, sizeof(hdev->gate2pipe)); | 602 | nfc_hci_reset_pipes(hdev); |
577 | 603 | ||
578 | return 0; | 604 | return 0; |
579 | } | 605 | } |
@@ -932,7 +958,7 @@ struct nfc_hci_dev *nfc_hci_allocate_device(struct nfc_hci_ops *ops, | |||
932 | 958 | ||
933 | nfc_set_drvdata(hdev->ndev, hdev); | 959 | nfc_set_drvdata(hdev->ndev, hdev); |
934 | 960 | ||
935 | memset(hdev->gate2pipe, NFC_HCI_INVALID_PIPE, sizeof(hdev->gate2pipe)); | 961 | nfc_hci_reset_pipes(hdev); |
936 | 962 | ||
937 | hdev->quirks = quirks; | 963 | hdev->quirks = quirks; |
938 | 964 | ||