Skip to content

Commit 288e071

Browse files
Ilan Eliaslinvjw
authored andcommitted
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>
1 parent 9931df2 commit 288e071

4 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎include/linux/nfc.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ enum nfc_commands {
8888
* @NFC_ATTR_TARGET_SENS_RES: NFC-A targets extra information such as NFCID
8989
* @NFC_ATTR_TARGET_SEL_RES: NFC-A targets extra information (useful if the
9090
* target is not NFC-Forum compliant)
91+
* @NFC_ATTR_TARGET_NFCID1: NFC-A targets identifier, max 10 bytes
9192
* @NFC_ATTR_COMM_MODE: Passive or active mode
9293
* @NFC_ATTR_RF_MODE: Initiator or target
9394
*/
@@ -99,6 +100,7 @@ enum nfc_attrs {
99100
NFC_ATTR_TARGET_INDEX,
100101
NFC_ATTR_TARGET_SENS_RES,
101102
NFC_ATTR_TARGET_SEL_RES,
103+
NFC_ATTR_TARGET_NFCID1,
102104
NFC_ATTR_COMM_MODE,
103105
NFC_ATTR_RF_MODE,
104106
/* private: internal use only */

‎include/net/nfc/nfc.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,15 @@ struct nfc_ops {
6565

6666
#define NFC_TARGET_IDX_ANY -1
6767
#define NFC_MAX_GT_LEN 48
68+
#define NFC_MAX_NFCID1_LEN 10
6869

6970
struct nfc_target {
7071
u32 idx;
7172
u32 supported_protocols;
7273
u16 sens_res;
7374
u8 sel_res;
75+
u8 nfcid1_len;
76+
u8 nfcid1[NFC_MAX_NFCID1_LEN];
7477
};
7578

7679
struct nfc_genl_data {

‎net/nfc/nci/ntf.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ static void nci_target_found(struct nci_dev *ndev,
154154

155155
nfc_tgt.sens_res = ntf->rf_tech_specific_params.nfca_poll.sens_res;
156156
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+
}
157163

158164
if (!(nfc_tgt.supported_protocols & ndev->poll_prots)) {
159165
pr_debug("the target found does not have the desired protocol\n");

‎net/nfc/netlink.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ static int nfc_genl_send_target(struct sk_buff *msg, struct nfc_target *target,
6767
target->supported_protocols);
6868
NLA_PUT_U16(msg, NFC_ATTR_TARGET_SENS_RES, target->sens_res);
6969
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);
7073

7174
return genlmsg_end(msg, hdr);
7275

0 commit comments

Comments
 (0)