NFC: nci: Add nci init ops for early device initialization
authorChristophe Ricard <christophe.ricard@gmail.com>
Sat, 6 Jun 2015 11:16:40 +0000 (13:16 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 8 Jun 2015 22:34:21 +0000 (00:34 +0200)
Some device may need to execute some proprietary commands
in order to "wake-up"; Before the nci state initialization.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
include/net/nfc/nci_core.h
net/nfc/nci/core.c

index c49688c..886854a 100644 (file)
@@ -73,6 +73,7 @@ struct nci_prop_ops {
 };
 
 struct nci_ops {
+       int   (*init)(struct nci_dev *ndev);
        int   (*open)(struct nci_dev *ndev);
        int   (*close)(struct nci_dev *ndev);
        int   (*send)(struct nci_dev *ndev, struct sk_buff *skb);
index b900e6a..458e58b 100644 (file)
@@ -344,8 +344,13 @@ static int nci_open_device(struct nci_dev *ndev)
 
        set_bit(NCI_INIT, &ndev->flags);
 
-       rc = __nci_request(ndev, nci_reset_req, 0,
-                          msecs_to_jiffies(NCI_RESET_TIMEOUT));
+       if (ndev->ops->init)
+               rc = ndev->ops->init(ndev);
+
+       if (!rc) {
+               rc = __nci_request(ndev, nci_reset_req, 0,
+                                  msecs_to_jiffies(NCI_RESET_TIMEOUT));
+       }
 
        if (!rc && ndev->ops->setup) {
                rc = ndev->ops->setup(ndev);