NFC: hci: Add load_session HCI operand
authorChristophe Ricard <christophe.ricard@gmail.com>
Tue, 25 Mar 2014 05:51:49 +0000 (06:51 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 21 Apr 2014 22:37:26 +0000 (00:37 +0200)
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>
include/net/nfc/hci.h
net/nfc/hci/core.c

index 03c4650b548ca7b01c24ba0f95317139949c7cdb..61286db54388b9d03b6a49b494d1492e7cfd8e5c 100644 (file)
@@ -27,6 +27,7 @@ struct nfc_hci_dev;
 struct nfc_hci_ops {
        int (*open) (struct nfc_hci_dev *hdev);
        void (*close) (struct nfc_hci_dev *hdev);
+       int (*load_session) (struct nfc_hci_dev *hdev);
        int (*hci_ready) (struct nfc_hci_dev *hdev);
        /*
         * xmit must always send the complete buffer before
index d45b638e77c78ec25b8228eacf2ea0ac754ad8d7..c4d251a6fd6791b9836c6332af87ab4091b4163b 100644 (file)
@@ -380,34 +380,31 @@ static int hci_dev_session_init(struct nfc_hci_dev *hdev)
        if (r < 0)
                goto disconnect_all;
 
-       if (skb->len && skb->len == strlen(hdev->init_data.session_id))
-               if (memcmp(hdev->init_data.session_id, skb->data,
-                          skb->len) == 0) {
-                       /* TODO ELa: restore gate<->pipe table from
-                        * some TBD location.
-                        * note: it doesn't seem possible to get the chip
-                        * currently open gate/pipe table.
-                        * It is only possible to obtain the supported
-                        * gate list.
-                        */
+       if (skb->len && skb->len == strlen(hdev->init_data.session_id) &&
+               (memcmp(hdev->init_data.session_id, skb->data,
+                          skb->len) == 0) && hdev->ops->load_session) {
+               /* Restore gate<->pipe table from some proprietary location. */
 
-                       /* goto exit
-                        * For now, always do a full initialization */
-               }
+               r = hdev->ops->load_session(hdev);
 
-       r = nfc_hci_disconnect_all_gates(hdev);
-       if (r < 0)
-               goto exit;
+               if (r < 0)
+                       goto disconnect_all;
+       } else {
 
-       r = hci_dev_connect_gates(hdev, hdev->init_data.gate_count,
-                                 hdev->init_data.gates);
-       if (r < 0)
-               goto disconnect_all;
+               r = nfc_hci_disconnect_all_gates(hdev);
+               if (r < 0)
+                       goto exit;
 
-       r = nfc_hci_set_param(hdev, NFC_HCI_ADMIN_GATE,
-                             NFC_HCI_ADMIN_SESSION_IDENTITY,
-                             hdev->init_data.session_id,
-                             strlen(hdev->init_data.session_id));
+               r = hci_dev_connect_gates(hdev, hdev->init_data.gate_count,
+                                         hdev->init_data.gates);
+               if (r < 0)
+                       goto disconnect_all;
+
+               r = nfc_hci_set_param(hdev, NFC_HCI_ADMIN_GATE,
+                               NFC_HCI_ADMIN_SESSION_IDENTITY,
+                               hdev->init_data.session_id,
+                               strlen(hdev->init_data.session_id));
+       }
        if (r == 0)
                goto exit;
 
This page took 0.026009 seconds and 5 git commands to generate.