Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFC: NFC core layer should not set the target_idx

The NFC core layer should not set the target_idx.
Instead, the driver layer (e.g. NCI, PN533) should set the
target_idx, so that it will be able to identify the target
when its I/F (e.g. activate_target) is called.
This is required in order to support multiple targets.
Note that currently supported drivers (PN533 and NCI) don't
use the target_idx in their implementation.

Signed-off-by: Ilan Elias <ilane@ti.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Ilan Elias and committed by
John W. Linville
25a1d9dc 8939e47f

-18
-1
include/net/nfc/nfc.h
··· 87 87 88 88 struct nfc_dev { 89 89 unsigned idx; 90 - unsigned target_idx; 91 90 struct nfc_target *targets; 92 91 int n_targets; 93 92 int targets_generation;
-5
net/nfc/core.c
··· 431 431 int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets, 432 432 int n_targets) 433 433 { 434 - int i; 435 - 436 434 pr_debug("dev_name=%s n_targets=%d\n", dev_name(&dev->dev), n_targets); 437 435 438 436 dev->polling = false; 439 - 440 - for (i = 0; i < n_targets; i++) 441 - targets[i].idx = dev->target_idx++; 442 437 443 438 spin_lock_bh(&dev->targets_lock); 444 439
-12
net/nfc/rawsock.c
··· 92 92 goto error; 93 93 } 94 94 95 - if (addr->target_idx > dev->target_idx - 1 || 96 - addr->target_idx < dev->target_idx - dev->n_targets) { 97 - rc = -EINVAL; 98 - goto error; 99 - } 100 - 101 - if (addr->target_idx > dev->target_idx - 1 || 102 - addr->target_idx < dev->target_idx - dev->n_targets) { 103 - rc = -EINVAL; 104 - goto error; 105 - } 106 - 107 95 rc = nfc_activate_target(dev, addr->target_idx, addr->nfc_protocol); 108 96 if (rc) 109 97 goto put_dev;