aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-05-31 14:01:32 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-06-04 15:34:34 -0400
commit51ad304cc8db5589d1e7b0a9df3858381753d788 (patch)
tree352608624988d0bbc1262896cc1094c8b25e7f2f /drivers/nfc
parent0201ed0349a71cec12ced7e142e6df78504f38fb (diff)
NFC: Monitor pn533 target mode
When receiving a DEP link down event, we should cancel all pending URBs if we're activated as a target or if we're an initiator. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/pn533.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index 58c1641cf658..9ac829e22e73 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -343,6 +343,7 @@ struct pn533 {
343 343
344 u8 tgt_available_prots; 344 u8 tgt_available_prots;
345 u8 tgt_active_prot; 345 u8 tgt_active_prot;
346 u8 tgt_mode;
346}; 347};
347 348
348struct pn533_frame { 349struct pn533_frame {
@@ -1158,6 +1159,8 @@ static int pn533_tm_get_data_complete(struct pn533 *dev, void *arg,
1158 if (params_len > 0 && params[0] != 0) { 1159 if (params_len > 0 && params[0] != 0) {
1159 nfc_tm_deactivated(dev->nfc_dev); 1160 nfc_tm_deactivated(dev->nfc_dev);
1160 1161
1162 dev->tgt_mode = 0;
1163
1161 kfree_skb(skb_resp); 1164 kfree_skb(skb_resp);
1162 return 0; 1165 return 0;
1163 } 1166 }
@@ -1245,6 +1248,8 @@ static int pn533_init_target_complete(struct pn533 *dev, void *arg,
1245 return rc; 1248 return rc;
1246 } 1249 }
1247 1250
1251 dev->tgt_mode = 1;
1252
1248 queue_work(dev->wq, &dev->tg_work); 1253 queue_work(dev->wq, &dev->tg_work);
1249 1254
1250 return 0; 1255 return 0;
@@ -1397,6 +1402,12 @@ static int pn533_start_poll(struct nfc_dev *nfc_dev,
1397 return -EBUSY; 1402 return -EBUSY;
1398 } 1403 }
1399 1404
1405 if (dev->tgt_mode) {
1406 nfc_dev_err(&dev->interface->dev,
1407 "Cannot poll while already being activated");
1408 return -EBUSY;
1409 }
1410
1400 if (tm_protocols) { 1411 if (tm_protocols) {
1401 dev->gb = nfc_get_local_general_bytes(nfc_dev, &dev->gb_len); 1412 dev->gb = nfc_get_local_general_bytes(nfc_dev, &dev->gb_len);
1402 if (dev->gb == NULL) 1413 if (dev->gb == NULL)
@@ -1725,7 +1736,15 @@ static int pn533_dep_link_down(struct nfc_dev *nfc_dev)
1725 1736
1726 pn533_poll_reset_mod_list(dev); 1737 pn533_poll_reset_mod_list(dev);
1727 1738
1728 pn533_deactivate_target(nfc_dev, 0); 1739 if (dev->tgt_mode || dev->tgt_active_prot) {
1740 pn533_send_ack(dev, GFP_KERNEL);
1741 usb_kill_urb(dev->in_urb);
1742 }
1743
1744 dev->tgt_active_prot = 0;
1745 dev->tgt_mode = 0;
1746
1747 skb_queue_purge(&dev->resp_q);
1729 1748
1730 return 0; 1749 return 0;
1731} 1750}
@@ -1956,6 +1975,8 @@ static int pn533_tm_send_complete(struct pn533 *dev, void *arg,
1956 if (params_len > 0 && params[0] != 0) { 1975 if (params_len > 0 && params[0] != 0) {
1957 nfc_tm_deactivated(dev->nfc_dev); 1976 nfc_tm_deactivated(dev->nfc_dev);
1958 1977
1978 dev->tgt_mode = 0;
1979
1959 return 0; 1980 return 0;
1960 } 1981 }
1961 1982