NFC: nci: Allow the driver to set handler for core nci ops
The driver may be required to act when some responses or notifications arrive. For example the NCI core does not have a handler for NCI_OP_CORE_GET_CONFIG_RSP. The NFCC can send a config response that has to be read by the driver and the packet may contain vendor specific data. The Fields Peak driver needs to take certain actions when a reset notification arrives (packet also not handled by the nfc core). The driver handlers do not interfere with the core and they are called after the core processes the packet. Signed-off-by: Robert Dolca <robert.dolca@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
7bc4824ed5
commit
0a97a3cba2
|
@ -96,6 +96,9 @@ struct nci_ops {
|
||||||
|
|
||||||
struct nci_prop_ops *prop_ops;
|
struct nci_prop_ops *prop_ops;
|
||||||
size_t n_prop_ops;
|
size_t n_prop_ops;
|
||||||
|
|
||||||
|
struct nci_prop_ops *core_ops;
|
||||||
|
size_t n_core_ops;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NCI_MAX_SUPPORTED_RF_INTERFACES 4
|
#define NCI_MAX_SUPPORTED_RF_INTERFACES 4
|
||||||
|
@ -345,9 +348,13 @@ static inline int nci_set_vendor_cmds(struct nci_dev *ndev,
|
||||||
|
|
||||||
void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb);
|
void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb);
|
||||||
void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb);
|
void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb);
|
||||||
int nci_prop_rsp_packet(struct nci_dev *ndev, __u16 opcode,
|
inline int nci_prop_rsp_packet(struct nci_dev *ndev, __u16 opcode,
|
||||||
struct sk_buff *skb);
|
struct sk_buff *skb);
|
||||||
int nci_prop_ntf_packet(struct nci_dev *ndev, __u16 opcode,
|
inline int nci_prop_ntf_packet(struct nci_dev *ndev, __u16 opcode,
|
||||||
|
struct sk_buff *skb);
|
||||||
|
inline int nci_core_rsp_packet(struct nci_dev *ndev, __u16 opcode,
|
||||||
|
struct sk_buff *skb);
|
||||||
|
inline int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
|
||||||
struct sk_buff *skb);
|
struct sk_buff *skb);
|
||||||
void nci_rx_data_packet(struct nci_dev *ndev, struct sk_buff *skb);
|
void nci_rx_data_packet(struct nci_dev *ndev, struct sk_buff *skb);
|
||||||
int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, void *payload);
|
int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, void *payload);
|
||||||
|
|
|
@ -1242,46 +1242,77 @@ int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, void *payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Proprietary commands API */
|
/* Proprietary commands API */
|
||||||
static struct nci_prop_ops *prop_cmd_lookup(struct nci_dev *ndev,
|
static struct nci_prop_ops *ops_cmd_lookup(struct nci_prop_ops *ops,
|
||||||
__u16 opcode)
|
size_t n_ops,
|
||||||
|
__u16 opcode)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
struct nci_prop_ops *prop_op;
|
struct nci_prop_ops *op;
|
||||||
|
|
||||||
if (!ndev->ops->prop_ops || !ndev->ops->n_prop_ops)
|
if (!ops || !n_ops)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < ndev->ops->n_prop_ops; i++) {
|
for (i = 0; i < n_ops; i++) {
|
||||||
prop_op = &ndev->ops->prop_ops[i];
|
op = &ops[i];
|
||||||
if (prop_op->opcode == opcode)
|
if (op->opcode == opcode)
|
||||||
return prop_op;
|
return op;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nci_prop_rsp_packet(struct nci_dev *ndev, __u16 rsp_opcode,
|
static int nci_op_rsp_packet(struct nci_dev *ndev, __u16 rsp_opcode,
|
||||||
struct sk_buff *skb)
|
struct sk_buff *skb, struct nci_prop_ops *ops,
|
||||||
|
size_t n_ops)
|
||||||
{
|
{
|
||||||
struct nci_prop_ops *prop_op;
|
struct nci_prop_ops *op;
|
||||||
|
|
||||||
prop_op = prop_cmd_lookup(ndev, rsp_opcode);
|
op = ops_cmd_lookup(ops, n_ops, rsp_opcode);
|
||||||
if (!prop_op || !prop_op->rsp)
|
if (!op || !op->rsp)
|
||||||
return -ENOTSUPP;
|
return -ENOTSUPP;
|
||||||
|
|
||||||
return prop_op->rsp(ndev, skb);
|
return op->rsp(ndev, skb);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nci_prop_ntf_packet(struct nci_dev *ndev, __u16 ntf_opcode,
|
static int nci_op_ntf_packet(struct nci_dev *ndev, __u16 ntf_opcode,
|
||||||
struct sk_buff *skb)
|
struct sk_buff *skb, struct nci_prop_ops *ops,
|
||||||
|
size_t n_ops)
|
||||||
{
|
{
|
||||||
struct nci_prop_ops *prop_op;
|
struct nci_prop_ops *op;
|
||||||
|
|
||||||
prop_op = prop_cmd_lookup(ndev, ntf_opcode);
|
op = ops_cmd_lookup(ops, n_ops, ntf_opcode);
|
||||||
if (!prop_op || !prop_op->ntf)
|
if (!op || !op->ntf)
|
||||||
return -ENOTSUPP;
|
return -ENOTSUPP;
|
||||||
|
|
||||||
return prop_op->ntf(ndev, skb);
|
return op->ntf(ndev, skb);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int nci_prop_rsp_packet(struct nci_dev *ndev, __u16 opcode,
|
||||||
|
struct sk_buff *skb)
|
||||||
|
{
|
||||||
|
return nci_op_rsp_packet(ndev, opcode, skb, ndev->ops->prop_ops,
|
||||||
|
ndev->ops->n_prop_ops);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int nci_prop_ntf_packet(struct nci_dev *ndev, __u16 opcode,
|
||||||
|
struct sk_buff *skb)
|
||||||
|
{
|
||||||
|
return nci_op_ntf_packet(ndev, opcode, skb, ndev->ops->prop_ops,
|
||||||
|
ndev->ops->n_prop_ops);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int nci_core_rsp_packet(struct nci_dev *ndev, __u16 opcode,
|
||||||
|
struct sk_buff *skb)
|
||||||
|
{
|
||||||
|
return nci_op_rsp_packet(ndev, opcode, skb, ndev->ops->core_ops,
|
||||||
|
ndev->ops->n_core_ops);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode,
|
||||||
|
struct sk_buff *skb)
|
||||||
|
{
|
||||||
|
return nci_op_ntf_packet(ndev, opcode, skb, ndev->ops->core_ops,
|
||||||
|
ndev->ops->n_core_ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---- NCI TX Data worker thread ---- */
|
/* ---- NCI TX Data worker thread ---- */
|
||||||
|
|
|
@ -759,7 +759,7 @@ void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb)
|
||||||
skb_pull(skb, NCI_CTRL_HDR_SIZE);
|
skb_pull(skb, NCI_CTRL_HDR_SIZE);
|
||||||
|
|
||||||
if (nci_opcode_gid(ntf_opcode) == NCI_GID_PROPRIETARY) {
|
if (nci_opcode_gid(ntf_opcode) == NCI_GID_PROPRIETARY) {
|
||||||
if (nci_prop_ntf_packet(ndev, ntf_opcode, skb)) {
|
if (nci_prop_ntf_packet(ndev, ntf_opcode, skb) == -ENOTSUPP) {
|
||||||
pr_err("unsupported ntf opcode 0x%x\n",
|
pr_err("unsupported ntf opcode 0x%x\n",
|
||||||
ntf_opcode);
|
ntf_opcode);
|
||||||
}
|
}
|
||||||
|
@ -805,6 +805,7 @@ void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nci_core_ntf_packet(ndev, ntf_opcode, skb);
|
||||||
end:
|
end:
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,6 +355,7 @@ void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nci_core_rsp_packet(ndev, rsp_opcode, skb);
|
||||||
end:
|
end:
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue