Skip to content

Commit

Permalink
NFC: digital: Randomize poll cycles
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thierry Escande authored and Samuel Ortiz committed May 25, 2014
1 parent 00e625d commit 9dc3370
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/nfc/digital_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ int digital_target_found(struct nfc_digital_dev *ddev,

void digital_poll_next_tech(struct nfc_digital_dev *ddev)
{
u8 rand_mod;

digital_switch_rf(ddev, 0);

mutex_lock(&ddev->poll_lock);
Expand All @@ -395,8 +397,8 @@ void digital_poll_next_tech(struct nfc_digital_dev *ddev)
return;
}

ddev->poll_tech_index = (ddev->poll_tech_index + 1) %
ddev->poll_tech_count;
get_random_bytes(&rand_mod, sizeof(rand_mod));
ddev->poll_tech_index = rand_mod % ddev->poll_tech_count;

mutex_unlock(&ddev->poll_lock);

Expand Down

0 comments on commit 9dc3370

Please sign in to comment.