aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc/core.c
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-05-30 18:02:26 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-06-04 15:34:30 -0400
commitf212ad5e993e7efb996fc8ce94a5de8f0bd06d41 (patch)
tree719e09118ffc8e80a7c916d16c0529510bdc5ebb /net/nfc/core.c
parentfc40a8c1a06ab7db45da790693dd9802612a055c (diff)
NFC: Set the NFC device RF mode appropriately
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc/core.c')
-rw-r--r--net/nfc/core.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/net/nfc/core.c b/net/nfc/core.c
index 17f147430b7c..722a0c76c669 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -144,8 +144,10 @@ int nfc_start_poll(struct nfc_dev *dev, u32 im_protocols, u32 tm_protocols)
144 } 144 }
145 145
146 rc = dev->ops->start_poll(dev, im_protocols, tm_protocols); 146 rc = dev->ops->start_poll(dev, im_protocols, tm_protocols);
147 if (!rc) 147 if (!rc) {
148 dev->polling = true; 148 dev->polling = true;
149 dev->rf_mode = NFC_RF_NONE;
150 }
149 151
150error: 152error:
151 device_unlock(&dev->dev); 153 device_unlock(&dev->dev);
@@ -235,8 +237,10 @@ int nfc_dep_link_up(struct nfc_dev *dev, int target_index, u8 comm_mode)
235 } 237 }
236 238
237 rc = dev->ops->dep_link_up(dev, target, comm_mode, gb, gb_len); 239 rc = dev->ops->dep_link_up(dev, target, comm_mode, gb, gb_len);
238 if (!rc) 240 if (!rc) {
239 dev->active_target = target; 241 dev->active_target = target;
242 dev->rf_mode = NFC_RF_INITIATOR;
243 }
240 244
241error: 245error:
242 device_unlock(&dev->dev); 246 device_unlock(&dev->dev);
@@ -264,7 +268,7 @@ int nfc_dep_link_down(struct nfc_dev *dev)
264 goto error; 268 goto error;
265 } 269 }
266 270
267 if (dev->dep_rf_mode == NFC_RF_TARGET) { 271 if (dev->rf_mode == NFC_RF_TARGET) {
268 rc = -EOPNOTSUPP; 272 rc = -EOPNOTSUPP;
269 goto error; 273 goto error;
270 } 274 }
@@ -286,7 +290,6 @@ int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx,
286 u8 comm_mode, u8 rf_mode) 290 u8 comm_mode, u8 rf_mode)
287{ 291{
288 dev->dep_link_up = true; 292 dev->dep_link_up = true;
289 dev->dep_rf_mode = rf_mode;
290 293
291 nfc_llcp_mac_is_up(dev, target_idx, comm_mode, rf_mode); 294 nfc_llcp_mac_is_up(dev, target_idx, comm_mode, rf_mode);
292 295
@@ -330,6 +333,7 @@ int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol)
330 rc = dev->ops->activate_target(dev, target, protocol); 333 rc = dev->ops->activate_target(dev, target, protocol);
331 if (!rc) { 334 if (!rc) {
332 dev->active_target = target; 335 dev->active_target = target;
336 dev->rf_mode = NFC_RF_INITIATOR;
333 337
334 if (dev->ops->check_presence) 338 if (dev->ops->check_presence)
335 mod_timer(&dev->check_pres_timer, jiffies + 339 mod_timer(&dev->check_pres_timer, jiffies +
@@ -470,6 +474,8 @@ int nfc_tm_activated(struct nfc_dev *dev, u32 protocol, u8 comm_mode,
470 goto out; 474 goto out;
471 } 475 }
472 476
477 dev->rf_mode = NFC_RF_TARGET;
478
473 if (protocol == NFC_PROTO_NFC_DEP_MASK) 479 if (protocol == NFC_PROTO_NFC_DEP_MASK)
474 nfc_dep_link_is_up(dev, 0, comm_mode, NFC_RF_TARGET); 480 nfc_dep_link_is_up(dev, 0, comm_mode, NFC_RF_TARGET);
475 481