lightnvm: NVM should depend on HAS_DMA
[deliverable/linux.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 typedef int (*qcom_smd_cb_t)(struct qcom_smd_channel *, const void *, size_t);
30
31 /**
32 * struct qcom_smd_driver - smd driver struct
33 * @driver: underlying device driver
34 * @smd_match_table: static channel match table
35 * @probe: invoked when the smd channel is found
36 * @remove: invoked when the smd channel is closed
37 * @callback: invoked when an inbound message is received on the channel,
38 * should return 0 on success or -EBUSY if the data cannot be
39 * consumed at this time
40 */
41 struct qcom_smd_driver {
42 struct device_driver driver;
43 const struct qcom_smd_id *smd_match_table;
44
45 int (*probe)(struct qcom_smd_device *dev);
46 void (*remove)(struct qcom_smd_device *dev);
47 qcom_smd_cb_t callback;
48 };
49
50 #if IS_ENABLED(CONFIG_QCOM_SMD)
51
52 int qcom_smd_driver_register(struct qcom_smd_driver *drv);
53 void qcom_smd_driver_unregister(struct qcom_smd_driver *drv);
54
55 struct qcom_smd_channel *qcom_smd_open_channel(struct qcom_smd_channel *channel,
56 const char *name,
57 qcom_smd_cb_t cb);
58 void *qcom_smd_get_drvdata(struct qcom_smd_channel *channel);
59 void qcom_smd_set_drvdata(struct qcom_smd_channel *channel, void *data);
60 int qcom_smd_send(struct qcom_smd_channel *channel, const void *data, int len);
61
62
63 #else
64
65 static inline int qcom_smd_driver_register(struct qcom_smd_driver *drv)
66 {
67 return -ENXIO;
68 }
69
70 static inline void qcom_smd_driver_unregister(struct qcom_smd_driver *drv)
71 {
72 /* This shouldn't be possible */
73 WARN_ON(1);
74 }
75
76 static inline struct qcom_smd_channel *
77 qcom_smd_open_channel(struct qcom_smd_channel *channel,
78 const char *name,
79 qcom_smd_cb_t cb)
80 {
81 /* This shouldn't be possible */
82 WARN_ON(1);
83 return NULL;
84 }
85
86 void *qcom_smd_get_drvdata(struct qcom_smd_channel *channel)
87 {
88 /* This shouldn't be possible */
89 WARN_ON(1);
90 return NULL;
91 }
92
93 void qcom_smd_set_drvdata(struct qcom_smd_channel *channel, void *data)
94 {
95 /* This shouldn't be possible */
96 WARN_ON(1);
97 }
98
99 static inline int qcom_smd_send(struct qcom_smd_channel *channel,
100 const void *data, int len)
101 {
102 /* This shouldn't be possible */
103 WARN_ON(1);
104 return -ENXIO;
105 }
106
107 #endif
108
109 #define module_qcom_smd_driver(__smd_driver) \
110 module_driver(__smd_driver, qcom_smd_driver_register, \
111 qcom_smd_driver_unregister)
112
113
114 #endif
This page took 0.035539 seconds and 5 git commands to generate.