Skip to content

Commit

Permalink
NFC: nci: Move NFCEE discovery logic
Browse files Browse the repository at this point in the history
NFCEE_DISCOVER_CMD is a specified NCI command used to discover
NFCEE IDs.
Move nci_nfcee_discover() call to nci_discover_se() in order to
guarantee:
- NFCEE_DISCOVER_CMD run when the NCI state machine is initialized
- NFCEE_DISCOVER_CMD is not run in case there is not discover_se
  hook defined by a NFC device driver.

Signed-off-by: Christophe Ricard <[email protected]>
Signed-off-by: Samuel Ortiz <[email protected]>
  • Loading branch information
cricard13 authored and Samuel Ortiz committed Feb 4, 2015
1 parent 15d4a8d commit fa00e8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 0 additions & 4 deletions drivers/nfc/st21nfcb/st21nfcb_se.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,10 +499,6 @@ static int st21nfcb_hci_network_init(struct nci_dev *ndev)
struct nci_conn_info *conn_info;
int r, dev_num;

r = nci_nfcee_discover(ndev, NCI_NFCEE_DISCOVERY_ACTION_ENABLE);
if (r != NCI_STATUS_OK)
goto exit;

dest_params =
kzalloc(sizeof(struct core_conn_create_dest_spec_params) +
sizeof(struct dest_spec_params), GFP_KERNEL);
Expand Down
8 changes: 7 additions & 1 deletion net/nfc/nci/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,10 +880,16 @@ static int nci_disable_se(struct nfc_dev *nfc_dev, u32 se_idx)

static int nci_discover_se(struct nfc_dev *nfc_dev)
{
int r;
struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);

if (ndev->ops->discover_se)
if (ndev->ops->discover_se) {
r = nci_nfcee_discover(ndev, NCI_NFCEE_DISCOVERY_ACTION_ENABLE);
if (r != NCI_STATUS_OK)
return -EPROTO;

return ndev->ops->discover_se(ndev);
}

return 0;
}
Expand Down

0 comments on commit fa00e8f

Please sign in to comment.