NFC: Set active target upon DEP up event reception
authorSamuel Ortiz <sameo@linux.intel.com>
Wed, 21 Aug 2013 12:46:20 +0000 (14:46 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 24 Sep 2013 23:35:41 +0000 (01:35 +0200)
As we can potentially get DEP up events without having sent a netlink
command, we need to set the active target properly from dep_link_is_up.
Spontaneous DEP up events can come from devices that detected an active
p2p target. In that case there is no need to call the netlink DEP up
command as the link is already up and running.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
net/nfc/core.c

index 269ffc5288d02fcf894e0cac249ec5073bf2f785..872529105abc7c3a2e41b9d579e934e019e8e5ff 100644 (file)
@@ -384,6 +384,19 @@ int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx,
 {
        dev->dep_link_up = true;
 
+       if (!dev->active_target) {
+               struct nfc_target *target;
+
+               target = nfc_find_target(dev, target_idx);
+               if (target == NULL)
+                       return -ENOTCONN;
+
+               dev->active_target = target;
+       }
+
+       dev->polling = false;
+       dev->rf_mode = rf_mode;
+
        nfc_llcp_mac_is_up(dev, target_idx, comm_mode, rf_mode);
 
        return nfc_genl_dep_link_up_event(dev, target_idx, comm_mode, rf_mode);