diff options
-rw-r--r-- | include/linux/nfc.h | 1 | ||||
-rw-r--r-- | include/net/nfc/nfc.h | 2 | ||||
-rw-r--r-- | net/nfc/core.c | 14 |
3 files changed, 12 insertions, 5 deletions
diff --git a/include/linux/nfc.h b/include/linux/nfc.h index d124e9273fcb..f4e6dd915b1c 100644 --- a/include/linux/nfc.h +++ b/include/linux/nfc.h | |||
@@ -146,6 +146,7 @@ enum nfc_attrs { | |||
146 | /* NFC RF modes */ | 146 | /* NFC RF modes */ |
147 | #define NFC_RF_INITIATOR 0 | 147 | #define NFC_RF_INITIATOR 0 |
148 | #define NFC_RF_TARGET 1 | 148 | #define NFC_RF_TARGET 1 |
149 | #define NFC_RF_NONE 2 | ||
149 | 150 | ||
150 | /* NFC protocols masks used in bitsets */ | 151 | /* NFC protocols masks used in bitsets */ |
151 | #define NFC_PROTO_JEWEL_MASK (1 << NFC_PROTO_JEWEL) | 152 | #define NFC_PROTO_JEWEL_MASK (1 << NFC_PROTO_JEWEL) |
diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h index 41573b4bd78a..a6a7b49a3e2d 100644 --- a/include/net/nfc/nfc.h +++ b/include/net/nfc/nfc.h | |||
@@ -100,10 +100,10 @@ struct nfc_dev { | |||
100 | int targets_generation; | 100 | int targets_generation; |
101 | struct device dev; | 101 | struct device dev; |
102 | bool dev_up; | 102 | bool dev_up; |
103 | u8 rf_mode; | ||
103 | bool polling; | 104 | bool polling; |
104 | struct nfc_target *active_target; | 105 | struct nfc_target *active_target; |
105 | bool dep_link_up; | 106 | bool dep_link_up; |
106 | u32 dep_rf_mode; | ||
107 | struct nfc_genl_data genl_data; | 107 | struct nfc_genl_data genl_data; |
108 | u32 supported_protocols; | 108 | u32 supported_protocols; |
109 | 109 | ||
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 | ||
150 | error: | 152 | error: |
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 | ||
241 | error: | 245 | error: |
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 | ||