A secure element can be activated in different order. The host_list is
updated keeping a fixed order: <terminal_host_id><uicc_id><ese_id>.

Cc: sta...@vger.kernel.org
Signed-off-by: Christophe Ricard <christophe-h.ric...@st.com>
---
 drivers/nfc/st-nci/st-nci_se.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/nfc/st-nci/st-nci_se.c b/drivers/nfc/st-nci/st-nci_se.c
index ee53fc0..8886072 100644
--- a/drivers/nfc/st-nci/st-nci_se.c
+++ b/drivers/nfc/st-nci/st-nci_se.c
@@ -419,7 +419,7 @@ static int st_nci_control_se(struct nci_dev *ndev, u8 
se_idx,
                             u8 state)
 {
        struct st_nci_info *info = nci_get_drvdata(ndev);
-       int r;
+       int r, i;
        struct sk_buff *sk_host_list;
        u8 host_id;
 
@@ -466,7 +466,10 @@ static int st_nci_control_se(struct nci_dev *ndev, u8 
se_idx,
        if (r != NCI_HCI_ANY_OK)
                return r;
 
-       host_id = sk_host_list->data[sk_host_list->len - 1];
+       for (i = 0; i < sk_host_list->len &&
+               sk_host_list->data[i] != se_idx; i++)
+               ;
+       host_id = sk_host_list->data[i];
        kfree_skb(sk_host_list);
        if (state == ST_NCI_SE_MODE_ON && host_id == se_idx)
                return se_idx;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to