aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2013-07-03 09:14:17 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2013-08-13 18:35:19 -0400
commitdfccd0f580445d176acea174175b3e6518cc91f7 (patch)
tree9685d2c41e53be5b254bcaf26ccb54b116ea1ea5 /drivers/nfc
parent46f793b0413cfb234ca4faf7e598f24967e1fd3b (diff)
NFC: pn533: Add some polling entropy
By not always starting the polling loop from the same modulation, we avoid entering infinite loops where devices exporting 2 targets (on 2 different modulations) get the same target activated over and over. If this target is not readable (e.g. a wallet emulating a tag), we will stay in an error loop for ever. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/pn533.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index 9f3868b0170b..5df730be88a3 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -1913,6 +1913,7 @@ static int pn533_start_poll(struct nfc_dev *nfc_dev,
1913 u32 im_protocols, u32 tm_protocols) 1913 u32 im_protocols, u32 tm_protocols)
1914{ 1914{
1915 struct pn533 *dev = nfc_get_drvdata(nfc_dev); 1915 struct pn533 *dev = nfc_get_drvdata(nfc_dev);
1916 u8 rand_mod;
1916 1917
1917 nfc_dev_dbg(&dev->interface->dev, 1918 nfc_dev_dbg(&dev->interface->dev,
1918 "%s: im protocols 0x%x tm protocols 0x%x", 1919 "%s: im protocols 0x%x tm protocols 0x%x",
@@ -1936,11 +1937,15 @@ static int pn533_start_poll(struct nfc_dev *nfc_dev,
1936 tm_protocols = 0; 1937 tm_protocols = 0;
1937 } 1938 }
1938 1939
1939 dev->poll_mod_curr = 0;
1940 pn533_poll_create_mod_list(dev, im_protocols, tm_protocols); 1940 pn533_poll_create_mod_list(dev, im_protocols, tm_protocols);
1941 dev->poll_protocols = im_protocols; 1941 dev->poll_protocols = im_protocols;
1942 dev->listen_protocols = tm_protocols; 1942 dev->listen_protocols = tm_protocols;
1943 1943
1944 /* Do not always start polling from the same modulation */
1945 get_random_bytes(&rand_mod, sizeof(rand_mod));
1946 rand_mod %= dev->poll_mod_count;
1947 dev->poll_mod_curr = rand_mod;
1948
1944 return pn533_send_poll_frame(dev); 1949 return pn533_send_poll_frame(dev);
1945} 1950}
1946 1951