Commit 288e0713f469c03dbc412153b5341d6dfc2c9907
Committed by
John W. Linville
1 parent
9931df2692
Exists in
master
and in
38 other branches
NFC: Export a new attribute nfcid1 in target info
The nfcid1 is the NFC-A identifier. It is exported as an attribute of the target info (returned as a response to NFC_CMD_GET_TARGET). Signed-off-by: Ilan Elias <ilane@ti.com> Acked-by: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Showing 4 changed files with 14 additions and 0 deletions Side-by-side Diff
include/linux/nfc.h
... | ... | @@ -88,6 +88,7 @@ |
88 | 88 | * @NFC_ATTR_TARGET_SENS_RES: NFC-A targets extra information such as NFCID |
89 | 89 | * @NFC_ATTR_TARGET_SEL_RES: NFC-A targets extra information (useful if the |
90 | 90 | * target is not NFC-Forum compliant) |
91 | + * @NFC_ATTR_TARGET_NFCID1: NFC-A targets identifier, max 10 bytes | |
91 | 92 | * @NFC_ATTR_COMM_MODE: Passive or active mode |
92 | 93 | * @NFC_ATTR_RF_MODE: Initiator or target |
93 | 94 | */ |
... | ... | @@ -99,6 +100,7 @@ |
99 | 100 | NFC_ATTR_TARGET_INDEX, |
100 | 101 | NFC_ATTR_TARGET_SENS_RES, |
101 | 102 | NFC_ATTR_TARGET_SEL_RES, |
103 | + NFC_ATTR_TARGET_NFCID1, | |
102 | 104 | NFC_ATTR_COMM_MODE, |
103 | 105 | NFC_ATTR_RF_MODE, |
104 | 106 | /* private: internal use only */ |
include/net/nfc/nfc.h
... | ... | @@ -65,12 +65,15 @@ |
65 | 65 | |
66 | 66 | #define NFC_TARGET_IDX_ANY -1 |
67 | 67 | #define NFC_MAX_GT_LEN 48 |
68 | +#define NFC_MAX_NFCID1_LEN 10 | |
68 | 69 | |
69 | 70 | struct nfc_target { |
70 | 71 | u32 idx; |
71 | 72 | u32 supported_protocols; |
72 | 73 | u16 sens_res; |
73 | 74 | u8 sel_res; |
75 | + u8 nfcid1_len; | |
76 | + u8 nfcid1[NFC_MAX_NFCID1_LEN]; | |
74 | 77 | }; |
75 | 78 | |
76 | 79 | struct nfc_genl_data { |
net/nfc/nci/ntf.c
... | ... | @@ -154,6 +154,12 @@ |
154 | 154 | |
155 | 155 | nfc_tgt.sens_res = ntf->rf_tech_specific_params.nfca_poll.sens_res; |
156 | 156 | nfc_tgt.sel_res = ntf->rf_tech_specific_params.nfca_poll.sel_res; |
157 | + nfc_tgt.nfcid1_len = ntf->rf_tech_specific_params.nfca_poll.nfcid1_len; | |
158 | + if (nfc_tgt.nfcid1_len > 0) { | |
159 | + memcpy(nfc_tgt.nfcid1, | |
160 | + ntf->rf_tech_specific_params.nfca_poll.nfcid1, | |
161 | + nfc_tgt.nfcid1_len); | |
162 | + } | |
157 | 163 | |
158 | 164 | if (!(nfc_tgt.supported_protocols & ndev->poll_prots)) { |
159 | 165 | pr_debug("the target found does not have the desired protocol\n"); |
net/nfc/netlink.c
... | ... | @@ -67,6 +67,9 @@ |
67 | 67 | target->supported_protocols); |
68 | 68 | NLA_PUT_U16(msg, NFC_ATTR_TARGET_SENS_RES, target->sens_res); |
69 | 69 | NLA_PUT_U8(msg, NFC_ATTR_TARGET_SEL_RES, target->sel_res); |
70 | + if (target->nfcid1_len > 0) | |
71 | + NLA_PUT(msg, NFC_ATTR_TARGET_NFCID1, target->nfcid1_len, | |
72 | + target->nfcid1); | |
70 | 73 | |
71 | 74 | return genlmsg_end(msg, hdr); |
72 | 75 |