mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
NFC: Update names and structs to NCI spec 1.0 d18
Addition, deletion and modification of NCI constants. Changes in NCI commands, responses and notifications structures. Signed-off-by: Ilan Elias <[email protected]> Acked-by: Lauro Ramos Venancio <[email protected]> Signed-off-by: John W. Linville <[email protected]>
This commit is contained in:
parent
e999882a05
commit
e8c0dacd98
7 changed files with 193 additions and 114 deletions
|
|
@ -125,7 +125,10 @@ static inline int nci_request(struct nci_dev *ndev,
|
|||
|
||||
static void nci_reset_req(struct nci_dev *ndev, unsigned long opt)
|
||||
{
|
||||
nci_send_cmd(ndev, NCI_OP_CORE_RESET_CMD, 0, NULL);
|
||||
struct nci_core_reset_cmd cmd;
|
||||
|
||||
cmd.reset_type = NCI_RESET_TYPE_RESET_CONFIG;
|
||||
nci_send_cmd(ndev, NCI_OP_CORE_RESET_CMD, 1, &cmd);
|
||||
}
|
||||
|
||||
static void nci_init_req(struct nci_dev *ndev, unsigned long opt)
|
||||
|
|
@ -469,7 +472,7 @@ static int nci_data_exchange(struct nfc_dev *nfc_dev, __u32 target_idx,
|
|||
ndev->data_exchange_cb = cb;
|
||||
ndev->data_exchange_cb_context = cb_context;
|
||||
|
||||
rc = nci_send_data(ndev, ndev->conn_id, skb);
|
||||
rc = nci_send_data(ndev, NCI_STATIC_RF_CONN_ID, skb);
|
||||
if (rc)
|
||||
clear_bit(NCI_DATA_EXCHANGE, &ndev->flags);
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,8 @@ static int nci_queue_tx_data_frags(struct nci_dev *ndev,
|
|||
__skb_queue_head_init(&frags_q);
|
||||
|
||||
while (total_len) {
|
||||
frag_len = min_t(int, total_len, ndev->max_pkt_payload_size);
|
||||
frag_len =
|
||||
min_t(int, total_len, ndev->max_data_pkt_payload_size);
|
||||
|
||||
skb_frag = nci_skb_alloc(ndev,
|
||||
(NCI_DATA_HDR_SIZE + frag_len),
|
||||
|
|
@ -151,7 +152,7 @@ int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb)
|
|||
nfc_dbg("entry, conn_id 0x%x, plen %d", conn_id, skb->len);
|
||||
|
||||
/* check if the packet need to be fragmented */
|
||||
if (skb->len <= ndev->max_pkt_payload_size) {
|
||||
if (skb->len <= ndev->max_data_pkt_payload_size) {
|
||||
/* no need to fragment packet */
|
||||
nci_push_data_hdr(ndev, conn_id, skb, NCI_PBF_LAST);
|
||||
|
||||
|
|
|
|||
|
|
@ -42,12 +42,9 @@ int nci_to_errno(__u8 code)
|
|||
case NCI_STATUS_REJECTED:
|
||||
return -EBUSY;
|
||||
|
||||
case NCI_STATUS_MESSAGE_CORRUPTED:
|
||||
case NCI_STATUS_RF_FRAME_CORRUPTED:
|
||||
return -EBADMSG;
|
||||
|
||||
case NCI_STATUS_BUFFER_FULL:
|
||||
return -ENOBUFS;
|
||||
|
||||
case NCI_STATUS_NOT_INITIALIZED:
|
||||
return -EHOSTDOWN;
|
||||
|
||||
|
|
@ -80,9 +77,6 @@ int nci_to_errno(__u8 code)
|
|||
case NCI_STATUS_NFCEE_TIMEOUT_ERROR:
|
||||
return -ETIMEDOUT;
|
||||
|
||||
case NCI_STATUS_RF_LINK_LOSS_ERROR:
|
||||
return -ENOLINK;
|
||||
|
||||
case NCI_STATUS_MAX_ACTIVE_NFCEE_INTERFACES_REACHED:
|
||||
return -EDQUOT;
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev,
|
|||
ntf->conn_entries[i].conn_id,
|
||||
ntf->conn_entries[i].credits);
|
||||
|
||||
if (ntf->conn_entries[i].conn_id == ndev->conn_id) {
|
||||
if (ntf->conn_entries[i].conn_id == NCI_STATIC_RF_CONN_ID) {
|
||||
/* found static rf connection */
|
||||
atomic_add(ntf->conn_entries[i].credits,
|
||||
&ndev->credits_cnt);
|
||||
|
|
@ -74,14 +74,12 @@ static void nci_rf_field_info_ntf_packet(struct nci_dev *ndev,
|
|||
nfc_dbg("entry, rf_field_status %d", ntf->rf_field_status);
|
||||
}
|
||||
|
||||
static int nci_rf_activate_nfca_passive_poll(struct nci_dev *ndev,
|
||||
struct nci_rf_activate_ntf *ntf, __u8 *data)
|
||||
static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev,
|
||||
struct nci_rf_intf_activated_ntf *ntf, __u8 *data)
|
||||
{
|
||||
struct rf_tech_specific_params_nfca_poll *nfca_poll;
|
||||
struct activation_params_nfca_poll_iso_dep *nfca_poll_iso_dep;
|
||||
|
||||
nfca_poll = &ntf->rf_tech_specific_params.nfca_poll;
|
||||
nfca_poll_iso_dep = &ntf->activation_params.nfca_poll_iso_dep;
|
||||
|
||||
nfca_poll->sens_res = __le16_to_cpu(*((__u16 *)data));
|
||||
data += 2;
|
||||
|
|
@ -100,32 +98,32 @@ static int nci_rf_activate_nfca_passive_poll(struct nci_dev *ndev,
|
|||
if (nfca_poll->sel_res_len != 0)
|
||||
nfca_poll->sel_res = *data++;
|
||||
|
||||
ntf->rf_interface_type = *data++;
|
||||
ntf->activation_params_len = *data++;
|
||||
|
||||
nfc_dbg("sel_res_len %d, sel_res 0x%x, rf_interface_type %d, activation_params_len %d",
|
||||
nfc_dbg("sel_res_len %d, sel_res 0x%x",
|
||||
nfca_poll->sel_res_len,
|
||||
nfca_poll->sel_res,
|
||||
ntf->rf_interface_type,
|
||||
ntf->activation_params_len);
|
||||
nfca_poll->sel_res);
|
||||
|
||||
switch (ntf->rf_interface_type) {
|
||||
case NCI_RF_INTERFACE_ISO_DEP:
|
||||
nfca_poll_iso_dep->rats_res_len = *data++;
|
||||
if (nfca_poll_iso_dep->rats_res_len > 0) {
|
||||
memcpy(nfca_poll_iso_dep->rats_res,
|
||||
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;
|
||||
|
||||
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++;
|
||||
if (nfca_poll->rats_res_len > 0) {
|
||||
memcpy(nfca_poll->rats_res,
|
||||
data,
|
||||
nfca_poll_iso_dep->rats_res_len);
|
||||
nfca_poll->rats_res_len);
|
||||
}
|
||||
break;
|
||||
|
||||
case NCI_RF_INTERFACE_FRAME:
|
||||
/* no activation params */
|
||||
break;
|
||||
|
||||
default:
|
||||
nfc_err("unsupported rf_interface_type 0x%x",
|
||||
ntf->rf_interface_type);
|
||||
nfc_err("unsupported activation_rf_tech_and_mode 0x%x",
|
||||
ntf->activation_rf_tech_and_mode);
|
||||
return -EPROTO;
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +131,7 @@ static int nci_rf_activate_nfca_passive_poll(struct nci_dev *ndev,
|
|||
}
|
||||
|
||||
static void nci_target_found(struct nci_dev *ndev,
|
||||
struct nci_rf_activate_ntf *ntf)
|
||||
struct nci_rf_intf_activated_ntf *ntf)
|
||||
{
|
||||
struct nfc_target nfc_tgt;
|
||||
|
||||
|
|
@ -141,6 +139,8 @@ static void nci_target_found(struct nci_dev *ndev,
|
|||
nfc_tgt.supported_protocols = NFC_PROTO_MIFARE_MASK;
|
||||
else if (ntf->rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) /* 4A */
|
||||
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;
|
||||
|
|
@ -158,49 +158,86 @@ static void nci_target_found(struct nci_dev *ndev,
|
|||
nfc_targets_found(ndev->nfc_dev, &nfc_tgt, 1);
|
||||
}
|
||||
|
||||
static void nci_rf_activate_ntf_packet(struct nci_dev *ndev,
|
||||
struct sk_buff *skb)
|
||||
static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct nci_rf_activate_ntf ntf;
|
||||
struct nci_rf_intf_activated_ntf ntf;
|
||||
__u8 *data = skb->data;
|
||||
int rc = -1;
|
||||
int err = 0;
|
||||
|
||||
clear_bit(NCI_DISCOVERY, &ndev->flags);
|
||||
set_bit(NCI_POLL_ACTIVE, &ndev->flags);
|
||||
|
||||
ntf.target_handle = *data++;
|
||||
ntf.rf_discovery_id = *data++;
|
||||
ntf.rf_interface_type = *data++;
|
||||
ntf.rf_protocol = *data++;
|
||||
ntf.rf_tech_and_mode = *data++;
|
||||
ntf.activation_rf_tech_and_mode = *data++;
|
||||
ntf.rf_tech_specific_params_len = *data++;
|
||||
|
||||
nfc_dbg("target_handle %d, rf_protocol 0x%x, rf_tech_and_mode 0x%x, rf_tech_specific_params_len %d",
|
||||
ntf.target_handle,
|
||||
ntf.rf_protocol,
|
||||
ntf.rf_tech_and_mode,
|
||||
nfc_dbg("rf_discovery_id %d", ntf.rf_discovery_id);
|
||||
nfc_dbg("rf_interface_type 0x%x", ntf.rf_interface_type);
|
||||
nfc_dbg("rf_protocol 0x%x", ntf.rf_protocol);
|
||||
nfc_dbg("activation_rf_tech_and_mode 0x%x",
|
||||
ntf.activation_rf_tech_and_mode);
|
||||
nfc_dbg("rf_tech_specific_params_len %d",
|
||||
ntf.rf_tech_specific_params_len);
|
||||
|
||||
switch (ntf.rf_tech_and_mode) {
|
||||
case NCI_NFC_A_PASSIVE_POLL_MODE:
|
||||
rc = nci_rf_activate_nfca_passive_poll(ndev, &ntf,
|
||||
data);
|
||||
break;
|
||||
if (ntf.rf_tech_specific_params_len > 0) {
|
||||
switch (ntf.activation_rf_tech_and_mode) {
|
||||
case NCI_NFC_A_PASSIVE_POLL_MODE:
|
||||
data = nci_extract_rf_params_nfca_passive_poll(ndev,
|
||||
&ntf, data);
|
||||
break;
|
||||
|
||||
default:
|
||||
nfc_err("unsupported rf_tech_and_mode 0x%x",
|
||||
ntf.rf_tech_and_mode);
|
||||
return;
|
||||
default:
|
||||
nfc_err("unsupported activation_rf_tech_and_mode 0x%x",
|
||||
ntf.activation_rf_tech_and_mode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!rc)
|
||||
ntf.data_exch_rf_tech_and_mode = *data++;
|
||||
ntf.data_exch_tx_bit_rate = *data++;
|
||||
ntf.data_exch_rx_bit_rate = *data++;
|
||||
ntf.activation_params_len = *data++;
|
||||
|
||||
nfc_dbg("data_exch_rf_tech_and_mode 0x%x",
|
||||
ntf.data_exch_rf_tech_and_mode);
|
||||
nfc_dbg("data_exch_tx_bit_rate 0x%x",
|
||||
ntf.data_exch_tx_bit_rate);
|
||||
nfc_dbg("data_exch_rx_bit_rate 0x%x",
|
||||
ntf.data_exch_rx_bit_rate);
|
||||
nfc_dbg("activation_params_len %d",
|
||||
ntf.activation_params_len);
|
||||
|
||||
if (ntf.activation_params_len > 0) {
|
||||
switch (ntf.rf_interface_type) {
|
||||
case NCI_RF_INTERFACE_ISO_DEP:
|
||||
err = nci_extract_activation_params_iso_dep(ndev,
|
||||
&ntf, data);
|
||||
break;
|
||||
|
||||
case NCI_RF_INTERFACE_FRAME:
|
||||
/* no activation params */
|
||||
break;
|
||||
|
||||
default:
|
||||
nfc_err("unsupported rf_interface_type 0x%x",
|
||||
ntf.rf_interface_type);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!err)
|
||||
nci_target_found(ndev, &ntf);
|
||||
}
|
||||
|
||||
static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
__u8 type = skb->data[0];
|
||||
struct nci_rf_deactivate_ntf *ntf = (void *) skb->data;
|
||||
|
||||
nfc_dbg("entry, type 0x%x", type);
|
||||
nfc_dbg("entry, type 0x%x, reason 0x%x", ntf->type, ntf->reason);
|
||||
|
||||
clear_bit(NCI_POLL_ACTIVE, &ndev->flags);
|
||||
ndev->target_active_prot = 0;
|
||||
|
|
@ -241,8 +278,8 @@ void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb)
|
|||
nci_rf_field_info_ntf_packet(ndev, skb);
|
||||
break;
|
||||
|
||||
case NCI_OP_RF_ACTIVATE_NTF:
|
||||
nci_rf_activate_ntf_packet(ndev, skb);
|
||||
case NCI_OP_RF_INTF_ACTIVATED_NTF:
|
||||
nci_rf_intf_activated_ntf_packet(ndev, skb);
|
||||
break;
|
||||
|
||||
case NCI_OP_RF_DEACTIVATE_NTF:
|
||||
|
|
|
|||
|
|
@ -42,10 +42,11 @@ static void nci_core_reset_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
|
|||
|
||||
nfc_dbg("entry, status 0x%x", rsp->status);
|
||||
|
||||
if (rsp->status == NCI_STATUS_OK)
|
||||
if (rsp->status == NCI_STATUS_OK) {
|
||||
ndev->nci_ver = rsp->nci_ver;
|
||||
|
||||
nfc_dbg("nci_ver 0x%x", ndev->nci_ver);
|
||||
nfc_dbg("nci_ver 0x%x, config_status 0x%x",
|
||||
rsp->nci_ver, rsp->config_status);
|
||||
}
|
||||
|
||||
nci_req_complete(ndev, rsp->status);
|
||||
}
|
||||
|
|
@ -58,13 +59,13 @@ static void nci_core_init_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
|
|||
nfc_dbg("entry, status 0x%x", rsp_1->status);
|
||||
|
||||
if (rsp_1->status != NCI_STATUS_OK)
|
||||
return;
|
||||
goto exit;
|
||||
|
||||
ndev->nfcc_features = __le32_to_cpu(rsp_1->nfcc_features);
|
||||
ndev->num_supported_rf_interfaces = rsp_1->num_supported_rf_interfaces;
|
||||
|
||||
if (ndev->num_supported_rf_interfaces >
|
||||
NCI_MAX_SUPPORTED_RF_INTERFACES) {
|
||||
NCI_MAX_SUPPORTED_RF_INTERFACES) {
|
||||
ndev->num_supported_rf_interfaces =
|
||||
NCI_MAX_SUPPORTED_RF_INTERFACES;
|
||||
}
|
||||
|
|
@ -73,20 +74,26 @@ static void nci_core_init_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
|
|||
rsp_1->supported_rf_interfaces,
|
||||
ndev->num_supported_rf_interfaces);
|
||||
|
||||
rsp_2 = (void *) (skb->data + 6 + ndev->num_supported_rf_interfaces);
|
||||
rsp_2 = (void *) (skb->data + 6 + rsp_1->num_supported_rf_interfaces);
|
||||
|
||||
ndev->max_logical_connections =
|
||||
rsp_2->max_logical_connections;
|
||||
ndev->max_routing_table_size =
|
||||
__le16_to_cpu(rsp_2->max_routing_table_size);
|
||||
ndev->max_control_packet_payload_length =
|
||||
rsp_2->max_control_packet_payload_length;
|
||||
ndev->rf_sending_buffer_size =
|
||||
__le16_to_cpu(rsp_2->rf_sending_buffer_size);
|
||||
ndev->rf_receiving_buffer_size =
|
||||
__le16_to_cpu(rsp_2->rf_receiving_buffer_size);
|
||||
ndev->manufacturer_id =
|
||||
__le16_to_cpu(rsp_2->manufacturer_id);
|
||||
ndev->max_ctrl_pkt_payload_len =
|
||||
rsp_2->max_ctrl_pkt_payload_len;
|
||||
ndev->max_size_for_large_params =
|
||||
__le16_to_cpu(rsp_2->max_size_for_large_params);
|
||||
ndev->max_data_pkt_payload_size =
|
||||
rsp_2->max_data_pkt_payload_size;
|
||||
ndev->initial_num_credits =
|
||||
rsp_2->initial_num_credits;
|
||||
ndev->manufact_id =
|
||||
rsp_2->manufact_id;
|
||||
ndev->manufact_specific_info =
|
||||
__le32_to_cpu(rsp_2->manufact_specific_info);
|
||||
|
||||
atomic_set(&ndev->credits_cnt, ndev->initial_num_credits);
|
||||
|
||||
nfc_dbg("nfcc_features 0x%x",
|
||||
ndev->nfcc_features);
|
||||
|
|
@ -104,15 +111,20 @@ static void nci_core_init_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
|
|||
ndev->max_logical_connections);
|
||||
nfc_dbg("max_routing_table_size %d",
|
||||
ndev->max_routing_table_size);
|
||||
nfc_dbg("max_control_packet_payload_length %d",
|
||||
ndev->max_control_packet_payload_length);
|
||||
nfc_dbg("rf_sending_buffer_size %d",
|
||||
ndev->rf_sending_buffer_size);
|
||||
nfc_dbg("rf_receiving_buffer_size %d",
|
||||
ndev->rf_receiving_buffer_size);
|
||||
nfc_dbg("manufacturer_id 0x%x",
|
||||
ndev->manufacturer_id);
|
||||
nfc_dbg("max_ctrl_pkt_payload_len %d",
|
||||
ndev->max_ctrl_pkt_payload_len);
|
||||
nfc_dbg("max_size_for_large_params %d",
|
||||
ndev->max_size_for_large_params);
|
||||
nfc_dbg("max_data_pkt_payload_size %d",
|
||||
ndev->max_data_pkt_payload_size);
|
||||
nfc_dbg("initial_num_credits %d",
|
||||
ndev->initial_num_credits);
|
||||
nfc_dbg("manufact_id 0x%x",
|
||||
ndev->manufact_id);
|
||||
nfc_dbg("manufact_specific_info 0x%x",
|
||||
ndev->manufact_specific_info);
|
||||
|
||||
exit:
|
||||
nci_req_complete(ndev, rsp_1->status);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue