diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2013-07-03 08:50:36 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-08-13 18:35:19 -0400 |
commit | 46f793b0413cfb234ca4faf7e598f24967e1fd3b (patch) | |
tree | 80c2d6bfa63996a00c8553c019ee2f8968c62020 /drivers/nfc/pn533.c | |
parent | ac22ac466a659f1b2e02a2e2ee23fc5c42da2c95 (diff) |
NFC: pn533: Add delay between each poll frame
It seems that some pn533 firmwares go belly up when being asked to send
poll frames too frequently. Adding a 10ms delay between each of them
calm the chip down and prevent it from crashing.
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc/pn533.c')
-rw-r--r-- | drivers/nfc/pn533.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index 2f1ebbd8cba6..9f3868b0170b 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c | |||
@@ -83,6 +83,8 @@ MODULE_DEVICE_TABLE(usb, pn533_table); | |||
83 | 83 | ||
84 | /* How much time we spend listening for initiators */ | 84 | /* How much time we spend listening for initiators */ |
85 | #define PN533_LISTEN_TIME 2 | 85 | #define PN533_LISTEN_TIME 2 |
86 | /* Delay between each poll frame (ms) */ | ||
87 | #define PN533_POLL_INTERVAL 10 | ||
86 | 88 | ||
87 | /* Standard pn533 frame definitions (standard and extended)*/ | 89 | /* Standard pn533 frame definitions (standard and extended)*/ |
88 | #define PN533_STD_FRAME_HEADER_LEN (sizeof(struct pn533_std_frame) \ | 90 | #define PN533_STD_FRAME_HEADER_LEN (sizeof(struct pn533_std_frame) \ |
@@ -368,7 +370,7 @@ struct pn533 { | |||
368 | struct workqueue_struct *wq; | 370 | struct workqueue_struct *wq; |
369 | struct work_struct cmd_work; | 371 | struct work_struct cmd_work; |
370 | struct work_struct cmd_complete_work; | 372 | struct work_struct cmd_complete_work; |
371 | struct work_struct poll_work; | 373 | struct delayed_work poll_work; |
372 | struct work_struct mi_rx_work; | 374 | struct work_struct mi_rx_work; |
373 | struct work_struct mi_tx_work; | 375 | struct work_struct mi_tx_work; |
374 | struct work_struct tg_work; | 376 | struct work_struct tg_work; |
@@ -1719,7 +1721,8 @@ static void pn533_listen_mode_timer(unsigned long data) | |||
1719 | 1721 | ||
1720 | pn533_poll_next_mod(dev); | 1722 | pn533_poll_next_mod(dev); |
1721 | 1723 | ||
1722 | queue_work(dev->wq, &dev->poll_work); | 1724 | queue_delayed_work(dev->wq, &dev->poll_work, |
1725 | msecs_to_jiffies(PN533_POLL_INTERVAL)); | ||
1723 | } | 1726 | } |
1724 | 1727 | ||
1725 | static int pn533_rf_complete(struct pn533 *dev, void *arg, | 1728 | static int pn533_rf_complete(struct pn533 *dev, void *arg, |
@@ -1738,7 +1741,8 @@ static int pn533_rf_complete(struct pn533 *dev, void *arg, | |||
1738 | return rc; | 1741 | return rc; |
1739 | } | 1742 | } |
1740 | 1743 | ||
1741 | queue_work(dev->wq, &dev->poll_work); | 1744 | queue_delayed_work(dev->wq, &dev->poll_work, |
1745 | msecs_to_jiffies(PN533_POLL_INTERVAL)); | ||
1742 | 1746 | ||
1743 | dev_kfree_skb(resp); | 1747 | dev_kfree_skb(resp); |
1744 | return rc; | 1748 | return rc; |
@@ -1880,7 +1884,7 @@ static int pn533_send_poll_frame(struct pn533 *dev) | |||
1880 | 1884 | ||
1881 | static void pn533_wq_poll(struct work_struct *work) | 1885 | static void pn533_wq_poll(struct work_struct *work) |
1882 | { | 1886 | { |
1883 | struct pn533 *dev = container_of(work, struct pn533, poll_work); | 1887 | struct pn533 *dev = container_of(work, struct pn533, poll_work.work); |
1884 | struct pn533_poll_modulations *cur_mod; | 1888 | struct pn533_poll_modulations *cur_mod; |
1885 | int rc; | 1889 | int rc; |
1886 | 1890 | ||
@@ -1955,6 +1959,7 @@ static void pn533_stop_poll(struct nfc_dev *nfc_dev) | |||
1955 | } | 1959 | } |
1956 | 1960 | ||
1957 | pn533_abort_cmd(dev, GFP_KERNEL); | 1961 | pn533_abort_cmd(dev, GFP_KERNEL); |
1962 | flush_delayed_work(&dev->poll_work); | ||
1958 | pn533_poll_reset_mod_list(dev); | 1963 | pn533_poll_reset_mod_list(dev); |
1959 | } | 1964 | } |
1960 | 1965 | ||
@@ -2931,7 +2936,7 @@ static int pn533_probe(struct usb_interface *interface, | |||
2931 | INIT_WORK(&dev->mi_rx_work, pn533_wq_mi_recv); | 2936 | INIT_WORK(&dev->mi_rx_work, pn533_wq_mi_recv); |
2932 | INIT_WORK(&dev->mi_tx_work, pn533_wq_mi_send); | 2937 | INIT_WORK(&dev->mi_tx_work, pn533_wq_mi_send); |
2933 | INIT_WORK(&dev->tg_work, pn533_wq_tg_get_data); | 2938 | INIT_WORK(&dev->tg_work, pn533_wq_tg_get_data); |
2934 | INIT_WORK(&dev->poll_work, pn533_wq_poll); | 2939 | INIT_DELAYED_WORK(&dev->poll_work, pn533_wq_poll); |
2935 | INIT_WORK(&dev->rf_work, pn533_wq_rf); | 2940 | INIT_WORK(&dev->rf_work, pn533_wq_rf); |
2936 | dev->wq = alloc_ordered_workqueue("pn533", 0); | 2941 | dev->wq = alloc_ordered_workqueue("pn533", 0); |
2937 | if (dev->wq == NULL) | 2942 | if (dev->wq == NULL) |
@@ -3044,6 +3049,7 @@ static void pn533_disconnect(struct usb_interface *interface) | |||
3044 | usb_kill_urb(dev->in_urb); | 3049 | usb_kill_urb(dev->in_urb); |
3045 | usb_kill_urb(dev->out_urb); | 3050 | usb_kill_urb(dev->out_urb); |
3046 | 3051 | ||
3052 | flush_delayed_work(&dev->poll_work); | ||
3047 | destroy_workqueue(dev->wq); | 3053 | destroy_workqueue(dev->wq); |
3048 | 3054 | ||
3049 | skb_queue_purge(&dev->resp_q); | 3055 | skb_queue_purge(&dev->resp_q); |