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

NFC: nci: Move NFCEE discovery logic

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 <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

authored by

Christophe Ricard and committed by
Samuel Ortiz
fa00e8fe 15d4a8da

+7 -5
-4
drivers/nfc/st21nfcb/st21nfcb_se.c
··· 499 499 struct nci_conn_info *conn_info; 500 500 int r, dev_num; 501 501 502 - r = nci_nfcee_discover(ndev, NCI_NFCEE_DISCOVERY_ACTION_ENABLE); 503 - if (r != NCI_STATUS_OK) 504 - goto exit; 505 - 506 502 dest_params = 507 503 kzalloc(sizeof(struct core_conn_create_dest_spec_params) + 508 504 sizeof(struct dest_spec_params), GFP_KERNEL);
+7 -1
net/nfc/nci/core.c
··· 880 880 881 881 static int nci_discover_se(struct nfc_dev *nfc_dev) 882 882 { 883 + int r; 883 884 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 884 885 885 - if (ndev->ops->discover_se) 886 + if (ndev->ops->discover_se) { 887 + r = nci_nfcee_discover(ndev, NCI_NFCEE_DISCOVERY_ACTION_ENABLE); 888 + if (r != NCI_STATUS_OK) 889 + return -EPROTO; 890 + 886 891 return ndev->ops->discover_se(ndev); 892 + } 887 893 888 894 return 0; 889 895 }