treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / hv / hv_utils_transport.h
blob1c162393c27b989277fb8e698d6f073cd5c19399
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Kernel/userspace transport abstraction for Hyper-V util driver.
5 * Copyright (C) 2015, Vitaly Kuznetsov <vkuznets@redhat.com>
6 */
8 #ifndef _HV_UTILS_TRANSPORT_H
9 #define _HV_UTILS_TRANSPORT_H
11 #include <linux/connector.h>
12 #include <linux/miscdevice.h>
14 enum hvutil_transport_mode {
15 HVUTIL_TRANSPORT_INIT = 0,
16 HVUTIL_TRANSPORT_NETLINK,
17 HVUTIL_TRANSPORT_CHARDEV,
18 HVUTIL_TRANSPORT_DESTROY,
21 struct hvutil_transport {
22 int mode; /* hvutil_transport_mode */
23 struct file_operations fops; /* file operations */
24 struct miscdevice mdev; /* misc device */
25 struct cb_id cn_id; /* CN_*_IDX/CN_*_VAL */
26 struct list_head list; /* hvt_list */
27 int (*on_msg)(void *, int); /* callback on new user message */
28 void (*on_reset)(void); /* callback when userspace drops */
29 void (*on_read)(void); /* callback on message read */
30 u8 *outmsg; /* message to the userspace */
31 int outmsg_len; /* its length */
32 wait_queue_head_t outmsg_q; /* poll/read wait queue */
33 struct mutex lock; /* protects struct members */
34 struct completion release; /* synchronize with fd release */
37 struct hvutil_transport *hvutil_transport_init(const char *name,
38 u32 cn_idx, u32 cn_val,
39 int (*on_msg)(void *, int),
40 void (*on_reset)(void));
41 int hvutil_transport_send(struct hvutil_transport *hvt, void *msg, int len,
42 void (*on_read_cb)(void));
43 void hvutil_transport_destroy(struct hvutil_transport *hvt);
45 #endif /* _HV_UTILS_TRANSPORT_H */