Commit 8115dd59 authored by Samuel Ortiz's avatar Samuel Ortiz

NFC: Introduce vendor commands structures

Together with inline routines to associate a vendor commands
array with an NFC device.

Vendor commands allow vendors to implement their very specific
operations from driver code instead of adding new stack ops
for non NFC generic commands.
Vendors need to select their own unique IDs and use that as a
namespace for defining sub commands.
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 41fc2f50
...@@ -179,6 +179,13 @@ void nfc_hci_unregister_device(struct nfc_hci_dev *hdev); ...@@ -179,6 +179,13 @@ void nfc_hci_unregister_device(struct nfc_hci_dev *hdev);
void nfc_hci_set_clientdata(struct nfc_hci_dev *hdev, void *clientdata); void nfc_hci_set_clientdata(struct nfc_hci_dev *hdev, void *clientdata);
void *nfc_hci_get_clientdata(struct nfc_hci_dev *hdev); void *nfc_hci_get_clientdata(struct nfc_hci_dev *hdev);
static inline int nfc_hci_set_vendor_cmds(struct nfc_hci_dev *hdev,
struct nfc_vendor_cmd *cmds,
int n_cmds)
{
return nfc_set_vendor_cmds(hdev->ndev, cmds, n_cmds);
}
void nfc_hci_driver_failure(struct nfc_hci_dev *hdev, int err); void nfc_hci_driver_failure(struct nfc_hci_dev *hdev, int err);
int nfc_hci_result_to_errno(u8 result); int nfc_hci_result_to_errno(u8 result);
......
...@@ -331,6 +331,13 @@ static inline void *nci_get_drvdata(struct nci_dev *ndev) ...@@ -331,6 +331,13 @@ static inline void *nci_get_drvdata(struct nci_dev *ndev)
return ndev->driver_data; return ndev->driver_data;
} }
static inline int nci_set_vendor_cmds(struct nci_dev *ndev,
struct nfc_vendor_cmd *cmds,
int n_cmds)
{
return nfc_set_vendor_cmds(ndev->nfc_dev, cmds, n_cmds);
}
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, int nci_prop_rsp_packet(struct nci_dev *ndev, __u16 opcode,
......
...@@ -165,6 +165,12 @@ struct nfc_genl_data { ...@@ -165,6 +165,12 @@ struct nfc_genl_data {
struct mutex genl_data_mutex; struct mutex genl_data_mutex;
}; };
struct nfc_vendor_cmd {
__u32 vendor_id;
__u32 subcmd;
int (*doit)(struct nfc_dev *dev, void *data, size_t data_len);
};
struct nfc_dev { struct nfc_dev {
int idx; int idx;
u32 target_next_idx; u32 target_next_idx;
...@@ -193,6 +199,9 @@ struct nfc_dev { ...@@ -193,6 +199,9 @@ struct nfc_dev {
struct rfkill *rfkill; struct rfkill *rfkill;
struct nfc_vendor_cmd *vendor_cmds;
int n_vendor_cmds;
struct nfc_ops *ops; struct nfc_ops *ops;
}; };
#define to_nfc_dev(_dev) container_of(_dev, struct nfc_dev, dev) #define to_nfc_dev(_dev) container_of(_dev, struct nfc_dev, dev)
...@@ -296,4 +305,17 @@ struct nfc_se *nfc_find_se(struct nfc_dev *dev, u32 se_idx); ...@@ -296,4 +305,17 @@ struct nfc_se *nfc_find_se(struct nfc_dev *dev, u32 se_idx);
void nfc_send_to_raw_sock(struct nfc_dev *dev, struct sk_buff *skb, void nfc_send_to_raw_sock(struct nfc_dev *dev, struct sk_buff *skb,
u8 payload_type, u8 direction); u8 payload_type, u8 direction);
static inline int nfc_set_vendor_cmds(struct nfc_dev *dev,
struct nfc_vendor_cmd *cmds,
int n_cmds)
{
if (dev->vendor_cmds || dev->n_vendor_cmds)
return -EINVAL;
dev->vendor_cmds = cmds;
dev->n_vendor_cmds = n_cmds;
return 0;
}
#endif /* __NET_NFC_H */ #endif /* __NET_NFC_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment