diff options
Diffstat (limited to 'drivers/iio/buffer_cb.c')
-rw-r--r-- | drivers/iio/buffer_cb.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/iio/buffer_cb.c b/drivers/iio/buffer_cb.c index 841fec1e78b2..2d9c6f8c06db 100644 --- a/drivers/iio/buffer_cb.c +++ b/drivers/iio/buffer_cb.c | |||
@@ -12,17 +12,27 @@ struct iio_cb_buffer { | |||
12 | struct iio_channel *channels; | 12 | struct iio_channel *channels; |
13 | }; | 13 | }; |
14 | 14 | ||
15 | static int iio_buffer_cb_store_to(struct iio_buffer *buffer, const void *data) | 15 | static struct iio_cb_buffer *buffer_to_cb_buffer(struct iio_buffer *buffer) |
16 | { | 16 | { |
17 | struct iio_cb_buffer *cb_buff = container_of(buffer, | 17 | return container_of(buffer, struct iio_cb_buffer, buffer); |
18 | struct iio_cb_buffer, | 18 | } |
19 | buffer); | ||
20 | 19 | ||
20 | static int iio_buffer_cb_store_to(struct iio_buffer *buffer, const void *data) | ||
21 | { | ||
22 | struct iio_cb_buffer *cb_buff = buffer_to_cb_buffer(buffer); | ||
21 | return cb_buff->cb(data, cb_buff->private); | 23 | return cb_buff->cb(data, cb_buff->private); |
22 | } | 24 | } |
23 | 25 | ||
26 | static void iio_buffer_cb_release(struct iio_buffer *buffer) | ||
27 | { | ||
28 | struct iio_cb_buffer *cb_buff = buffer_to_cb_buffer(buffer); | ||
29 | kfree(cb_buff->buffer.scan_mask); | ||
30 | kfree(cb_buff); | ||
31 | } | ||
32 | |||
24 | static const struct iio_buffer_access_funcs iio_cb_access = { | 33 | static const struct iio_buffer_access_funcs iio_cb_access = { |
25 | .store_to = &iio_buffer_cb_store_to, | 34 | .store_to = &iio_buffer_cb_store_to, |
35 | .release = &iio_buffer_cb_release, | ||
26 | }; | 36 | }; |
27 | 37 | ||
28 | struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev, | 38 | struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev, |
@@ -104,9 +114,8 @@ EXPORT_SYMBOL_GPL(iio_channel_stop_all_cb); | |||
104 | 114 | ||
105 | void iio_channel_release_all_cb(struct iio_cb_buffer *cb_buff) | 115 | void iio_channel_release_all_cb(struct iio_cb_buffer *cb_buff) |
106 | { | 116 | { |
107 | kfree(cb_buff->buffer.scan_mask); | ||
108 | iio_channel_release_all(cb_buff->channels); | 117 | iio_channel_release_all(cb_buff->channels); |
109 | kfree(cb_buff); | 118 | iio_buffer_put(&cb_buff->buffer); |
110 | } | 119 | } |
111 | EXPORT_SYMBOL_GPL(iio_channel_release_all_cb); | 120 | EXPORT_SYMBOL_GPL(iio_channel_release_all_cb); |
112 | 121 | ||