aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc/digital_core.c
diff options
context:
space:
mode:
authorThierry Escande <thierry.escande@linux.intel.com>2014-05-10 07:06:02 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2014-05-25 18:42:02 -0400
commit9dc33705b26aa67a94d8ada0a083557e9815cd0d (patch)
treeb4fc0baca7eb80ad007fc6f437c85894d8854e1f /net/nfc/digital_core.c
parent00e625df3ef6c3ce94ed6fc46565b41f55e379f8 (diff)
NFC: digital: Randomize poll cycles
This change adds some entropy to polling cycles, choosing the next polling rf technology randomly. This reflects the change done in the pn533 driver, avoiding possible infinite loop for devices that export 2 targets on 2 different modulations. If the first target is not readable, we will stay in an error loop for ever. Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc/digital_core.c')
-rw-r--r--net/nfc/digital_core.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c
index b105cfb00e76..a6ce3c627e4e 100644
--- a/net/nfc/digital_core.c
+++ b/net/nfc/digital_core.c
@@ -386,6 +386,8 @@ int digital_target_found(struct nfc_digital_dev *ddev,
386 386
387void digital_poll_next_tech(struct nfc_digital_dev *ddev) 387void digital_poll_next_tech(struct nfc_digital_dev *ddev)
388{ 388{
389 u8 rand_mod;
390
389 digital_switch_rf(ddev, 0); 391 digital_switch_rf(ddev, 0);
390 392
391 mutex_lock(&ddev->poll_lock); 393 mutex_lock(&ddev->poll_lock);
@@ -395,8 +397,8 @@ void digital_poll_next_tech(struct nfc_digital_dev *ddev)
395 return; 397 return;
396 } 398 }
397 399
398 ddev->poll_tech_index = (ddev->poll_tech_index + 1) % 400 get_random_bytes(&rand_mod, sizeof(rand_mod));
399 ddev->poll_tech_count; 401 ddev->poll_tech_index = rand_mod % ddev->poll_tech_count;
400 402
401 mutex_unlock(&ddev->poll_lock); 403 mutex_unlock(&ddev->poll_lock);
402 404