diff options
author | Christophe Ricard <christophe.ricard@gmail.com> | 2014-03-25 01:51:49 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2014-04-21 18:37:26 -0400 |
commit | e240bc36125691b0e18e70407c2d18ca6117c2f5 (patch) | |
tree | 158d0492b86259ebd6d0dd351d92a874da74761d | |
parent | d330905db608ff416a241e97c7f3b91103bfd827 (diff) |
NFC: hci: Add load_session HCI operand
load_session allows a CLF to restore the gate <-> pipe table from some
proprietary location.
The main advantage to add this function is to reduce the memory wear by
running pipe creation (and storing) only once.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | include/net/nfc/hci.h | 1 | ||||
-rw-r--r-- | net/nfc/hci/core.c | 45 |
2 files changed, 22 insertions, 24 deletions
diff --git a/include/net/nfc/hci.h b/include/net/nfc/hci.h index 03c4650b548c..61286db54388 100644 --- a/include/net/nfc/hci.h +++ b/include/net/nfc/hci.h | |||
@@ -27,6 +27,7 @@ struct nfc_hci_dev; | |||
27 | struct nfc_hci_ops { | 27 | struct nfc_hci_ops { |
28 | int (*open) (struct nfc_hci_dev *hdev); | 28 | int (*open) (struct nfc_hci_dev *hdev); |
29 | void (*close) (struct nfc_hci_dev *hdev); | 29 | void (*close) (struct nfc_hci_dev *hdev); |
30 | int (*load_session) (struct nfc_hci_dev *hdev); | ||
30 | int (*hci_ready) (struct nfc_hci_dev *hdev); | 31 | int (*hci_ready) (struct nfc_hci_dev *hdev); |
31 | /* | 32 | /* |
32 | * xmit must always send the complete buffer before | 33 | * xmit must always send the complete buffer before |
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c index d45b638e77c7..c4d251a6fd67 100644 --- a/net/nfc/hci/core.c +++ b/net/nfc/hci/core.c | |||
@@ -380,34 +380,31 @@ static int hci_dev_session_init(struct nfc_hci_dev *hdev) | |||
380 | if (r < 0) | 380 | if (r < 0) |
381 | goto disconnect_all; | 381 | goto disconnect_all; |
382 | 382 | ||
383 | if (skb->len && skb->len == strlen(hdev->init_data.session_id)) | 383 | if (skb->len && skb->len == strlen(hdev->init_data.session_id) && |
384 | if (memcmp(hdev->init_data.session_id, skb->data, | 384 | (memcmp(hdev->init_data.session_id, skb->data, |
385 | skb->len) == 0) { | 385 | skb->len) == 0) && hdev->ops->load_session) { |
386 | /* TODO ELa: restore gate<->pipe table from | 386 | /* Restore gate<->pipe table from some proprietary location. */ |
387 | * some TBD location. | ||
388 | * note: it doesn't seem possible to get the chip | ||
389 | * currently open gate/pipe table. | ||
390 | * It is only possible to obtain the supported | ||
391 | * gate list. | ||
392 | */ | ||
393 | 387 | ||
394 | /* goto exit | 388 | r = hdev->ops->load_session(hdev); |
395 | * For now, always do a full initialization */ | ||
396 | } | ||
397 | 389 | ||
398 | r = nfc_hci_disconnect_all_gates(hdev); | 390 | if (r < 0) |
399 | if (r < 0) | 391 | goto disconnect_all; |
400 | goto exit; | 392 | } else { |
401 | 393 | ||
402 | r = hci_dev_connect_gates(hdev, hdev->init_data.gate_count, | 394 | r = nfc_hci_disconnect_all_gates(hdev); |
403 | hdev->init_data.gates); | 395 | if (r < 0) |
404 | if (r < 0) | 396 | goto exit; |
405 | goto disconnect_all; | ||
406 | 397 | ||
407 | r = nfc_hci_set_param(hdev, NFC_HCI_ADMIN_GATE, | 398 | r = hci_dev_connect_gates(hdev, hdev->init_data.gate_count, |
408 | NFC_HCI_ADMIN_SESSION_IDENTITY, | 399 | hdev->init_data.gates); |
409 | hdev->init_data.session_id, | 400 | if (r < 0) |
410 | strlen(hdev->init_data.session_id)); | 401 | goto disconnect_all; |
402 | |||
403 | r = nfc_hci_set_param(hdev, NFC_HCI_ADMIN_GATE, | ||
404 | NFC_HCI_ADMIN_SESSION_IDENTITY, | ||
405 | hdev->init_data.session_id, | ||
406 | strlen(hdev->init_data.session_id)); | ||
407 | } | ||
411 | if (r == 0) | 408 | if (r == 0) |
412 | goto exit; | 409 | goto exit; |
413 | 410 | ||