udp: Resolve NULL pointer dereference over flow-based vxlan device
[linux-2.6-block.git] / include / linux / soc / qcom / smd.h
1 #ifndef __QCOM_SMD_H__
2 #define __QCOM_SMD_H__
3
4 #include <linux/device.h>
5 #include <linux/mod_devicetable.h>
6
7 struct qcom_smd;
8 struct qcom_smd_channel;
9 struct qcom_smd_lookup;
10
11 /**
12  * struct qcom_smd_id - struct used for matching a smd device
13  * @name:       name of the channel
14  */
15 struct qcom_smd_id {
16         char name[20];
17 };
18
19 /**
20  * struct qcom_smd_device - smd device struct
21  * @dev:        the device struct
22  * @channel:    handle to the smd channel for this device
23  */
24 struct qcom_smd_device {
25         struct device dev;
26         struct qcom_smd_channel *channel;
27 };
28
29 /**
30  * struct qcom_smd_driver - smd driver struct
31  * @driver:     underlying device driver
32  * @smd_match_table: static channel match table
33  * @probe:      invoked when the smd channel is found
34  * @remove:     invoked when the smd channel is closed
35  * @callback:   invoked when an inbound message is received on the channel,
36  *              should return 0 on success or -EBUSY if the data cannot be
37  *              consumed at this time
38  */
39 struct qcom_smd_driver {
40         struct device_driver driver;
41         const struct qcom_smd_id *smd_match_table;
42
43         int (*probe)(struct qcom_smd_device *dev);
44         void (*remove)(struct qcom_smd_device *dev);
45         int (*callback)(struct qcom_smd_device *, const void *, size_t);
46 };
47
48 #if IS_ENABLED(CONFIG_QCOM_SMD)
49
50 int qcom_smd_driver_register(struct qcom_smd_driver *drv);
51 void qcom_smd_driver_unregister(struct qcom_smd_driver *drv);
52
53 int qcom_smd_send(struct qcom_smd_channel *channel, const void *data, int len);
54
55 #else
56
57 static inline int qcom_smd_driver_register(struct qcom_smd_driver *drv)
58 {
59         return -ENXIO;
60 }
61
62 static inline void qcom_smd_driver_unregister(struct qcom_smd_driver *drv)
63 {
64         /* This shouldn't be possible */
65         WARN_ON(1);
66 }
67
68 static inline int qcom_smd_send(struct qcom_smd_channel *channel,
69                                 const void *data, int len)
70 {
71         /* This shouldn't be possible */
72         WARN_ON(1);
73         return -ENXIO;
74 }
75
76 #endif
77
78 #define module_qcom_smd_driver(__smd_driver) \
79         module_driver(__smd_driver, qcom_smd_driver_register, \
80                       qcom_smd_driver_unregister)
81
82
83 #endif