Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 300875
b: refs/heads/master
c: c4fbb65
h: refs/heads/master
i:
  300873: 5b07595
  300871: f310b8f
v: v3
  • Loading branch information
Samuel Ortiz authored and John W. Linville committed Apr 12, 2012
1 parent 9ce5a4e commit 8d1f91f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0efbf7fb308d0c6f8419922850a2d0b45d4d4401
refs/heads/master: c4fbb6515a4dcec83d340247639b5644c4745528
2 changes: 2 additions & 0 deletions trunk/include/net/nfc/nfc.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ struct nfc_target {
u8 sensf_res_len;
u8 sensf_res[NFC_SENSF_RES_MAXSIZE];
u8 hci_reader_gate;
u8 logical_idx;
};

struct nfc_genl_data {
Expand All @@ -88,6 +89,7 @@ struct nfc_genl_data {

struct nfc_dev {
unsigned idx;
unsigned target_idx;
struct nfc_target *targets;
int n_targets;
int targets_generation;
Expand Down
5 changes: 5 additions & 0 deletions trunk/net/nfc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,15 @@ EXPORT_SYMBOL(nfc_alloc_recv_skb);
int nfc_targets_found(struct nfc_dev *dev,
struct nfc_target *targets, int n_targets)
{
int i;

pr_debug("dev_name=%s n_targets=%d\n", dev_name(&dev->dev), n_targets);

dev->polling = false;

for (i = 0; i < n_targets; i++)
targets[i].idx = dev->target_idx++;

spin_lock_bh(&dev->targets_lock);

dev->targets_generation++;
Expand Down
2 changes: 1 addition & 1 deletion trunk/net/nfc/nci/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx,
}

if (atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) {
param.rf_discovery_id = target->idx;
param.rf_discovery_id = target->logical_idx;

if (protocol == NFC_PROTO_JEWEL)
param.rf_protocol = NCI_RF_PROTOCOL_T1T;
Expand Down
11 changes: 6 additions & 5 deletions trunk/net/nfc/nci/ntf.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static void nci_add_new_target(struct nci_dev *ndev,

for (i = 0; i < ndev->n_targets; i++) {
target = &ndev->targets[i];
if (target->idx == ntf->rf_discovery_id) {
if (target->logical_idx == ntf->rf_discovery_id) {
/* This target already exists, add the new protocol */
nci_add_new_protocol(ndev, target, ntf->rf_protocol,
ntf->rf_tech_and_mode,
Expand All @@ -248,10 +248,10 @@ static void nci_add_new_target(struct nci_dev *ndev,
ntf->rf_tech_and_mode,
&ntf->rf_tech_specific_params);
if (!rc) {
target->idx = ntf->rf_discovery_id;
target->logical_idx = ntf->rf_discovery_id;
ndev->n_targets++;

pr_debug("target_idx %d, n_targets %d\n", target->idx,
pr_debug("logical idx %d, n_targets %d\n", target->logical_idx,
ndev->n_targets);
}
}
Expand Down Expand Up @@ -372,10 +372,11 @@ static void nci_target_auto_activated(struct nci_dev *ndev,
if (rc)
return;

target->idx = ntf->rf_discovery_id;
target->logical_idx = ntf->rf_discovery_id;
ndev->n_targets++;

pr_debug("target_idx %d, n_targets %d\n", target->idx, ndev->n_targets);
pr_debug("logical idx %d, n_targets %d\n",
target->logical_idx, ndev->n_targets);

nfc_targets_found(ndev->nfc_dev, ndev->targets, ndev->n_targets);
}
Expand Down
6 changes: 6 additions & 0 deletions trunk/net/nfc/rawsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ static int rawsock_connect(struct socket *sock, struct sockaddr *_addr,
goto error;
}

if (addr->target_idx > dev->target_idx - 1 ||
addr->target_idx < dev->target_idx - dev->n_targets) {
rc = -EINVAL;
goto error;
}

rc = nfc_activate_target(dev, addr->target_idx, addr->nfc_protocol);
if (rc)
goto put_dev;
Expand Down

0 comments on commit 8d1f91f

Please sign in to comment.