summaryrefslogtreecommitdiff
path: root/net/nfc
diff options
context:
space:
mode:
authorIlan Elias <ilane@ti.com>2012-01-17 13:06:43 +0400
committerJohn W. Linville <linville@tuxdriver.com>2012-01-24 23:21:15 +0400
commitd5a2ca60e41fec4ede7b82d3608278523cffe77b (patch)
tree64faf8e66edaf03fe35b9bd61e8263817a17cca9 /net/nfc
parentbfeb4dbc5cb36ae774fabe7b0e0d559e621a2ccd (diff)
downloadlinux-d5a2ca60e41fec4ede7b82d3608278523cffe77b.tar.xz
NFC: Export new attributes sensb_res and sensf_res
Export new attributes sensb_res for tech B and sensf_res for tech F in the target info (returned as a response to NFC_CMD_GET_TARGET). The max size of the attributes nfcid1, sensb_res and sensf_res is exported to user space though include/linux/nfc. 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>
Diffstat (limited to 'net/nfc')
-rw-r--r--net/nfc/nci/ntf.c111
-rw-r--r--net/nfc/netlink.c6
2 files changed, 104 insertions, 13 deletions
diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c
index 10682bf7029d..a88be91e973f 100644
--- a/net/nfc/nci/ntf.c
+++ b/net/nfc/nci/ntf.c
@@ -115,15 +115,53 @@ static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev,
return data;
}
+static __u8 *nci_extract_rf_params_nfcb_passive_poll(struct nci_dev *ndev,
+ struct nci_rf_intf_activated_ntf *ntf, __u8 *data)
+{
+ struct rf_tech_specific_params_nfcb_poll *nfcb_poll;
+
+ nfcb_poll = &ntf->rf_tech_specific_params.nfcb_poll;
+
+ nfcb_poll->sensb_res_len = *data++;
+
+ pr_debug("sensb_res_len %d\n", nfcb_poll->sensb_res_len);
+
+ memcpy(nfcb_poll->sensb_res, data, nfcb_poll->sensb_res_len);
+ data += nfcb_poll->sensb_res_len;
+
+ return data;
+}
+
+static __u8 *nci_extract_rf_params_nfcf_passive_poll(struct nci_dev *ndev,
+ struct nci_rf_intf_activated_ntf *ntf, __u8 *data)
+{
+ struct rf_tech_specific_params_nfcf_poll *nfcf_poll;
+
+ nfcf_poll = &ntf->rf_tech_specific_params.nfcf_poll;
+
+ nfcf_poll->bit_rate = *data++;
+ nfcf_poll->sensf_res_len = *data++;
+
+ pr_debug("bit_rate %d, sensf_res_len %d\n",
+ nfcf_poll->bit_rate, nfcf_poll->sensf_res_len);
+
+ memcpy(nfcf_poll->sensf_res, data, nfcf_poll->sensf_res_len);
+ data += nfcf_poll->sensf_res_len;
+
+ return data;
+}
+
static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev,
struct nci_rf_intf_activated_ntf *ntf, __u8 *data)
{
struct activation_params_nfca_poll_iso_dep *nfca_poll;
+ struct activation_params_nfcb_poll_iso_dep *nfcb_poll;
switch (ntf->activation_rf_tech_and_mode) {
case NCI_NFC_A_PASSIVE_POLL_MODE:
nfca_poll = &ntf->activation_params.nfca_poll_iso_dep;
nfca_poll->rats_res_len = *data++;
+ pr_debug("rats_res_len %d\n", nfca_poll->rats_res_len);
if (nfca_poll->rats_res_len > 0) {
memcpy(nfca_poll->rats_res,
data,
@@ -131,6 +169,18 @@ static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev,
}
break;
+ case NCI_NFC_B_PASSIVE_POLL_MODE:
+ nfcb_poll = &ntf->activation_params.nfcb_poll_iso_dep;
+ nfcb_poll->attrib_res_len = *data++;
+ pr_debug("attrib_res_len %d\n",
+ nfcb_poll->attrib_res_len);
+ if (nfcb_poll->attrib_res_len > 0) {
+ memcpy(nfcb_poll->attrib_res,
+ data,
+ nfcb_poll->attrib_res_len);
+ }
+ break;
+
default:
pr_err("unsupported activation_rf_tech_and_mode 0x%x\n",
ntf->activation_rf_tech_and_mode);
@@ -145,21 +195,14 @@ static void nci_target_found(struct nci_dev *ndev,
{
struct nfc_target nfc_tgt;
- if (ntf->rf_protocol == NCI_RF_PROTOCOL_T2T) /* T2T MifareUL */
+ memset(&nfc_tgt, 0, sizeof(nfc_tgt));
+
+ if (ntf->rf_protocol == NCI_RF_PROTOCOL_T2T)
nfc_tgt.supported_protocols = NFC_PROTO_MIFARE_MASK;
- else if (ntf->rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) /* 4A */
+ else if (ntf->rf_protocol == NCI_RF_PROTOCOL_ISO_DEP)
nfc_tgt.supported_protocols = NFC_PROTO_ISO14443_MASK;
- else
- nfc_tgt.supported_protocols = 0;
-
- nfc_tgt.sens_res = ntf->rf_tech_specific_params.nfca_poll.sens_res;
- nfc_tgt.sel_res = ntf->rf_tech_specific_params.nfca_poll.sel_res;
- nfc_tgt.nfcid1_len = ntf->rf_tech_specific_params.nfca_poll.nfcid1_len;
- if (nfc_tgt.nfcid1_len > 0) {
- memcpy(nfc_tgt.nfcid1,
- ntf->rf_tech_specific_params.nfca_poll.nfcid1,
- nfc_tgt.nfcid1_len);
- }
+ else if (ntf->rf_protocol == NCI_RF_PROTOCOL_T3T)
+ nfc_tgt.supported_protocols = NFC_PROTO_FELICA_MASK;
if (!(nfc_tgt.supported_protocols & ndev->poll_prots)) {
pr_debug("the target found does not have the desired protocol\n");
@@ -169,6 +212,38 @@ static void nci_target_found(struct nci_dev *ndev,
pr_debug("new target found, supported_protocols 0x%x\n",
nfc_tgt.supported_protocols);
+ if (ntf->activation_rf_tech_and_mode == NCI_NFC_A_PASSIVE_POLL_MODE) {
+ nfc_tgt.sens_res =
+ ntf->rf_tech_specific_params.nfca_poll.sens_res;
+ nfc_tgt.sel_res =
+ ntf->rf_tech_specific_params.nfca_poll.sel_res;
+ nfc_tgt.nfcid1_len =
+ ntf->rf_tech_specific_params.nfca_poll.nfcid1_len;
+ if (nfc_tgt.nfcid1_len > 0) {
+ memcpy(nfc_tgt.nfcid1,
+ ntf->rf_tech_specific_params.nfca_poll.nfcid1,
+ nfc_tgt.nfcid1_len);
+ }
+ } else if (ntf->activation_rf_tech_and_mode ==
+ NCI_NFC_B_PASSIVE_POLL_MODE) {
+ nfc_tgt.sensb_res_len =
+ ntf->rf_tech_specific_params.nfcb_poll.sensb_res_len;
+ if (nfc_tgt.sensb_res_len > 0) {
+ memcpy(nfc_tgt.sensb_res,
+ ntf->rf_tech_specific_params.nfcb_poll.sensb_res,
+ nfc_tgt.sensb_res_len);
+ }
+ } else if (ntf->activation_rf_tech_and_mode ==
+ NCI_NFC_F_PASSIVE_POLL_MODE) {
+ nfc_tgt.sensf_res_len =
+ ntf->rf_tech_specific_params.nfcf_poll.sensf_res_len;
+ if (nfc_tgt.sensf_res_len > 0) {
+ memcpy(nfc_tgt.sensf_res,
+ ntf->rf_tech_specific_params.nfcf_poll.sensf_res,
+ nfc_tgt.sensf_res_len);
+ }
+ }
+
ndev->target_available_prots = nfc_tgt.supported_protocols;
ndev->max_data_pkt_payload_size = ntf->max_data_pkt_payload_size;
ndev->initial_num_credits = ntf->initial_num_credits;
@@ -215,6 +290,16 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,
&ntf, data);
break;
+ case NCI_NFC_B_PASSIVE_POLL_MODE:
+ data = nci_extract_rf_params_nfcb_passive_poll(ndev,
+ &ntf, data);
+ break;
+
+ case NCI_NFC_F_PASSIVE_POLL_MODE:
+ data = nci_extract_rf_params_nfcf_passive_poll(ndev,
+ &ntf, data);
+ break;
+
default:
pr_err("unsupported activation_rf_tech_and_mode 0x%x\n",
ntf.activation_rf_tech_and_mode);
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index 6989dfa28ee2..07f0348aabf5 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -70,6 +70,12 @@ static int nfc_genl_send_target(struct sk_buff *msg, struct nfc_target *target,
if (target->nfcid1_len > 0)
NLA_PUT(msg, NFC_ATTR_TARGET_NFCID1, target->nfcid1_len,
target->nfcid1);
+ if (target->sensb_res_len > 0)
+ NLA_PUT(msg, NFC_ATTR_TARGET_SENSB_RES, target->sensb_res_len,
+ target->sensb_res);
+ if (target->sensf_res_len > 0)
+ NLA_PUT(msg, NFC_ATTR_TARGET_SENSF_RES, target->sensf_res_len,
+ target->sensf_res);
return genlmsg_end(msg, hdr);