diff options
author | Christophe Ricard <christophe.ricard@gmail.com> | 2014-05-13 16:03:41 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2014-05-19 18:48:06 -0400 |
commit | a779b8878c20a5cafff26d774eed4d36a903882a (patch) | |
tree | 29a9e844aab930612815c7298fc8f36864e7f637 | |
parent | f517a5f370de4171afe1487d67345d7eef1f1822 (diff) |
NFC: st21nfca: Improve load_session
In case anybody uses previous patchset with the CLF, add a check to make sure
missing pipe are created.
st21nfca returns its pipe list in the creation order (most recent latest).
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | drivers/nfc/st21nfca/st21nfca.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/drivers/nfc/st21nfca/st21nfca.c b/drivers/nfc/st21nfca/st21nfca.c index 201a3eacbc9d..d9ee3d0c1a78 100644 --- a/drivers/nfc/st21nfca/st21nfca.c +++ b/drivers/nfc/st21nfca/st21nfca.c | |||
@@ -61,10 +61,10 @@ | |||
61 | static DECLARE_BITMAP(dev_mask, ST21NFCA_NUM_DEVICES); | 61 | static DECLARE_BITMAP(dev_mask, ST21NFCA_NUM_DEVICES); |
62 | 62 | ||
63 | static struct nfc_hci_gate st21nfca_gates[] = { | 63 | static struct nfc_hci_gate st21nfca_gates[] = { |
64 | {NFC_HCI_ADMIN_GATE, NFC_HCI_INVALID_PIPE}, | 64 | {NFC_HCI_ADMIN_GATE, NFC_HCI_ADMIN_PIPE}, |
65 | {NFC_HCI_LOOPBACK_GATE, NFC_HCI_INVALID_PIPE}, | 65 | {NFC_HCI_LOOPBACK_GATE, NFC_HCI_INVALID_PIPE}, |
66 | {NFC_HCI_ID_MGMT_GATE, NFC_HCI_INVALID_PIPE}, | 66 | {NFC_HCI_ID_MGMT_GATE, NFC_HCI_INVALID_PIPE}, |
67 | {NFC_HCI_LINK_MGMT_GATE, NFC_HCI_INVALID_PIPE}, | 67 | {NFC_HCI_LINK_MGMT_GATE, NFC_HCI_LINK_MGMT_PIPE}, |
68 | {NFC_HCI_RF_READER_B_GATE, NFC_HCI_INVALID_PIPE}, | 68 | {NFC_HCI_RF_READER_B_GATE, NFC_HCI_INVALID_PIPE}, |
69 | {NFC_HCI_RF_READER_A_GATE, NFC_HCI_INVALID_PIPE}, | 69 | {NFC_HCI_RF_READER_A_GATE, NFC_HCI_INVALID_PIPE}, |
70 | {ST21NFCA_DEVICE_MGNT_GATE, ST21NFCA_DEVICE_MGNT_PIPE}, | 70 | {ST21NFCA_DEVICE_MGNT_GATE, ST21NFCA_DEVICE_MGNT_PIPE}, |
@@ -170,6 +170,23 @@ static int st21nfca_hci_load_session(struct nfc_hci_dev *hdev) | |||
170 | st21nfca_gates[j].pipe; | 170 | st21nfca_gates[j].pipe; |
171 | } | 171 | } |
172 | } | 172 | } |
173 | |||
174 | /* | ||
175 | * 3 gates have a well known pipe ID. | ||
176 | * They will never appear in the pipe list | ||
177 | */ | ||
178 | if (skb_pipe_list->len + 3 < ARRAY_SIZE(st21nfca_gates)) { | ||
179 | for (i = skb_pipe_list->len + 3; | ||
180 | i < ARRAY_SIZE(st21nfca_gates); i++) { | ||
181 | r = nfc_hci_connect_gate(hdev, | ||
182 | NFC_HCI_HOST_CONTROLLER_ID, | ||
183 | st21nfca_gates[i].gate, | ||
184 | st21nfca_gates[i].pipe); | ||
185 | if (r < 0) | ||
186 | goto free_info; | ||
187 | } | ||
188 | } | ||
189 | |||
173 | memcpy(hdev->init_data.gates, st21nfca_gates, sizeof(st21nfca_gates)); | 190 | memcpy(hdev->init_data.gates, st21nfca_gates, sizeof(st21nfca_gates)); |
174 | free_info: | 191 | free_info: |
175 | kfree_skb(skb_pipe_info); | 192 | kfree_skb(skb_pipe_info); |