Commit 322bce957e9b0e30ef7147dae0414ad8f3f558c8
1 parent
31c44464ac
Exists in
smarc-imx_3.14.28_1.0.0_ga
and in
1 other branch
NFC: pn533: Copy NFCID2 through ATR_REQ
When using NFC-F we should copy the NFCID2 buffer that we got from SENSF_RES through the ATR_REQ NFCID3 buffer. Not doing so violates NFC Forum digital requirement #189. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Showing 3 changed files with 17 additions and 1 deletions Side-by-side Diff
drivers/nfc/pn533.c
... | ... | @@ -1235,7 +1235,7 @@ |
1235 | 1235 | struct pn533_target_felica { |
1236 | 1236 | u8 pol_res; |
1237 | 1237 | u8 opcode; |
1238 | - u8 nfcid2[8]; | |
1238 | + u8 nfcid2[NFC_NFCID2_MAXSIZE]; | |
1239 | 1239 | u8 pad[8]; |
1240 | 1240 | /* optional */ |
1241 | 1241 | u8 syst_code[]; |
... | ... | @@ -1275,6 +1275,9 @@ |
1275 | 1275 | memcpy(nfc_tgt->sensf_res, &tgt_felica->opcode, 9); |
1276 | 1276 | nfc_tgt->sensf_res_len = 9; |
1277 | 1277 | |
1278 | + memcpy(nfc_tgt->nfcid2, tgt_felica->nfcid2, NFC_NFCID2_MAXSIZE); | |
1279 | + nfc_tgt->nfcid2_len = NFC_NFCID2_MAXSIZE; | |
1280 | + | |
1278 | 1281 | return 0; |
1279 | 1282 | } |
1280 | 1283 | |
... | ... | @@ -2084,6 +2087,9 @@ |
2084 | 2087 | if (comm_mode == NFC_COMM_PASSIVE) |
2085 | 2088 | skb_len += PASSIVE_DATA_LEN; |
2086 | 2089 | |
2090 | + if (target && target->nfcid2_len) | |
2091 | + skb_len += NFC_NFCID3_MAXSIZE; | |
2092 | + | |
2087 | 2093 | skb = pn533_alloc_skb(dev, skb_len); |
2088 | 2094 | if (!skb) |
2089 | 2095 | return -ENOMEM; |
... | ... | @@ -2098,6 +2104,12 @@ |
2098 | 2104 | memcpy(skb_put(skb, PASSIVE_DATA_LEN), passive_data, |
2099 | 2105 | PASSIVE_DATA_LEN); |
2100 | 2106 | *next |= 1; |
2107 | + } | |
2108 | + | |
2109 | + if (target && target->nfcid2_len) { | |
2110 | + memcpy(skb_put(skb, NFC_NFCID3_MAXSIZE), target->nfcid2, | |
2111 | + target->nfcid2_len); | |
2112 | + *next |= 2; | |
2101 | 2113 | } |
2102 | 2114 | |
2103 | 2115 | if (gb != NULL && gb_len > 0) { |
include/net/nfc/nfc.h
include/uapi/linux/nfc.h
... | ... | @@ -164,6 +164,8 @@ |
164 | 164 | |
165 | 165 | #define NFC_DEVICE_NAME_MAXSIZE 8 |
166 | 166 | #define NFC_NFCID1_MAXSIZE 10 |
167 | +#define NFC_NFCID2_MAXSIZE 8 | |
168 | +#define NFC_NFCID3_MAXSIZE 10 | |
167 | 169 | #define NFC_SENSB_RES_MAXSIZE 12 |
168 | 170 | #define NFC_SENSF_RES_MAXSIZE 18 |
169 | 171 | #define NFC_GB_MAXSIZE 48 |