Merge tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
[firefly-linux-kernel-4.4.55.git] / net / nfc / nci / core.c
index 4044973084a7a43797dbc3f5c7f0a5b8ffd54598..51feb5e630082a78d67c8342c0883168df9b2fb2 100644 (file)
@@ -299,7 +299,7 @@ static void nci_rf_deactivate_req(struct nci_dev *ndev, unsigned long opt)
 {
        struct nci_rf_deactivate_cmd cmd;
 
-       cmd.type = NCI_DEACTIVATE_TYPE_IDLE_MODE;
+       cmd.type = opt;
 
        nci_send_cmd(ndev, NCI_OP_RF_DEACTIVATE_CMD,
                     sizeof(struct nci_rf_deactivate_cmd), &cmd);
@@ -527,7 +527,8 @@ static int nci_start_poll(struct nfc_dev *nfc_dev,
            (atomic_read(&ndev->state) == NCI_POLL_ACTIVE)) {
                pr_debug("target active or w4 select, implicitly deactivate\n");
 
-               rc = nci_request(ndev, nci_rf_deactivate_req, 0,
+               rc = nci_request(ndev, nci_rf_deactivate_req,
+                                NCI_DEACTIVATE_TYPE_IDLE_MODE,
                                 msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT));
                if (rc)
                        return -EBUSY;
@@ -568,7 +569,7 @@ static void nci_stop_poll(struct nfc_dev *nfc_dev)
                return;
        }
 
-       nci_request(ndev, nci_rf_deactivate_req, 0,
+       nci_request(ndev, nci_rf_deactivate_req, NCI_DEACTIVATE_TYPE_IDLE_MODE,
                    msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT));
 }
 
@@ -653,7 +654,8 @@ static void nci_deactivate_target(struct nfc_dev *nfc_dev,
        ndev->target_active_prot = 0;
 
        if (atomic_read(&ndev->state) == NCI_POLL_ACTIVE) {
-               nci_request(ndev, nci_rf_deactivate_req, 0,
+               nci_request(ndev, nci_rf_deactivate_req,
+                           NCI_DEACTIVATE_TYPE_SLEEP_MODE,
                            msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT));
        }
 }
@@ -746,11 +748,21 @@ static int nci_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb)
 
 static int nci_enable_se(struct nfc_dev *nfc_dev, u32 se_idx)
 {
+       struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
+
+       if (ndev->ops->enable_se)
+               return ndev->ops->enable_se(ndev, se_idx);
+
        return 0;
 }
 
 static int nci_disable_se(struct nfc_dev *nfc_dev, u32 se_idx)
 {
+       struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
+
+       if (ndev->ops->disable_se)
+               return ndev->ops->disable_se(ndev, se_idx);
+
        return 0;
 }
 
@@ -764,6 +776,19 @@ static int nci_discover_se(struct nfc_dev *nfc_dev)
        return 0;
 }
 
+static int nci_se_io(struct nfc_dev *nfc_dev, u32 se_idx,
+                    u8 *apdu, size_t apdu_length,
+                    se_io_cb_t cb, void *cb_context)
+{
+       struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
+
+       if (ndev->ops->se_io)
+               return ndev->ops->se_io(ndev, se_idx, apdu,
+                               apdu_length, cb, cb_context);
+
+       return 0;
+}
+
 static struct nfc_ops nci_nfc_ops = {
        .dev_up = nci_dev_up,
        .dev_down = nci_dev_down,
@@ -778,6 +803,7 @@ static struct nfc_ops nci_nfc_ops = {
        .enable_se = nci_enable_se,
        .disable_se = nci_disable_se,
        .discover_se = nci_discover_se,
+       .se_io = nci_se_io,
 };
 
 /* ---- Interface to NCI drivers ---- */