These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / include / net / nfc / nfc.h
index 7ac029c..dcfcfc9 100644 (file)
@@ -68,7 +68,7 @@ struct nfc_ops {
        int (*activate_target)(struct nfc_dev *dev, struct nfc_target *target,
                               u32 protocol);
        void (*deactivate_target)(struct nfc_dev *dev,
-                                 struct nfc_target *target);
+                                 struct nfc_target *target, u8 mode);
        int (*im_transceive)(struct nfc_dev *dev, struct nfc_target *target,
                             struct sk_buff *skb, data_exchange_cb_t cb,
                             void *cb_context);
@@ -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,7 +199,11 @@ struct nfc_dev {
 
        struct rfkill *rfkill;
 
+       struct nfc_vendor_cmd *vendor_cmds;
+       int n_vendor_cmds;
+
        struct nfc_ops *ops;
+       struct genl_info *cur_cmd_info;
 };
 #define to_nfc_dev(_dev) container_of(_dev, struct nfc_dev, dev)
 
@@ -296,4 +306,57 @@ 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;
+}
+
+struct sk_buff *__nfc_alloc_vendor_cmd_reply_skb(struct nfc_dev *dev,
+                                                enum nfc_attrs attr,
+                                                u32 oui, u32 subcmd,
+                                                int approxlen);
+int nfc_vendor_cmd_reply(struct sk_buff *skb);
+
+/**
+ * nfc_vendor_cmd_alloc_reply_skb - allocate vendor command reply
+ * @dev: nfc device
+ * @oui: vendor oui
+ * @approxlen: an upper bound of the length of the data that will
+ *      be put into the skb
+ *
+ * This function allocates and pre-fills an skb for a reply to
+ * a vendor command. Since it is intended for a reply, calling
+ * it outside of a vendor command's doit() operation is invalid.
+ *
+ * The returned skb is pre-filled with some identifying data in
+ * a way that any data that is put into the skb (with skb_put(),
+ * nla_put() or similar) will end up being within the
+ * %NFC_ATTR_VENDOR_DATA attribute, so all that needs to be done
+ * with the skb is adding data for the corresponding userspace tool
+ * which can then read that data out of the vendor data attribute.
+ * You must not modify the skb in any other way.
+ *
+ * When done, call nfc_vendor_cmd_reply() with the skb and return
+ * its error code as the result of the doit() operation.
+ *
+ * Return: An allocated and pre-filled skb. %NULL if any errors happen.
+ */
+static inline struct sk_buff *
+nfc_vendor_cmd_alloc_reply_skb(struct nfc_dev *dev,
+                               u32 oui, u32 subcmd, int approxlen)
+{
+       return __nfc_alloc_vendor_cmd_reply_skb(dev,
+                                               NFC_ATTR_VENDOR_DATA,
+                                               oui,
+                                               subcmd, approxlen);
+}
+
 #endif /* __NET_NFC_H */