summaryrefslogtreecommitdiffstats
path: root/include/net/nfc/nfc.h
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2014-10-14 01:42:23 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2015-06-09 01:20:19 +0200
commit8115dd5905318afcde713726064ec052b7d488cf (patch)
treeb4504be9f866bb932f3fe5e4f39b96b0f22f3674 /include/net/nfc/nfc.h
parent41fc2f50a7a2bfef1deaf78107a4d7b5bf4bd7a5 (diff)
downloadlinux-8115dd5905318afcde713726064ec052b7d488cf.tar.bz2
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: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'include/net/nfc/nfc.h')
-rw-r--r--include/net/nfc/nfc.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h
index 7ac029c07546..f9e58ae45f9c 100644
--- a/include/net/nfc/nfc.h
+++ b/include/net/nfc/nfc.h
@@ -165,6 +165,12 @@ struct nfc_genl_data {
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 {
int idx;
u32 target_next_idx;
@@ -193,6 +199,9 @@ struct nfc_dev {
struct rfkill *rfkill;
+ struct nfc_vendor_cmd *vendor_cmds;
+ int n_vendor_cmds;
+
struct nfc_ops *ops;
};
#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);
void nfc_send_to_raw_sock(struct nfc_dev *dev, struct sk_buff *skb,
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 */