diff options
-rw-r--r-- | drivers/staging/iio/accel/sca3000_ring.c | 8 | ||||
-rw-r--r-- | drivers/staging/iio/industrialio-ring.c | 12 | ||||
-rw-r--r-- | drivers/staging/iio/kfifo_buf.c | 8 | ||||
-rw-r--r-- | drivers/staging/iio/kfifo_buf.h | 10 | ||||
-rw-r--r-- | drivers/staging/iio/ring_generic.h | 10 | ||||
-rw-r--r-- | drivers/staging/iio/ring_sw.c | 13 | ||||
-rw-r--r-- | drivers/staging/iio/ring_sw.h | 14 |
7 files changed, 38 insertions, 37 deletions
diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c index a730a7638de..b505e70429a 100644 --- a/drivers/staging/iio/accel/sca3000_ring.c +++ b/drivers/staging/iio/accel/sca3000_ring.c | |||
@@ -35,7 +35,7 @@ | |||
35 | */ | 35 | */ |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * sca3000_rip_hw_rb() - main ring access function, pulls data from ring | 38 | * sca3000_read_first_n_hw_rb() - main ring access, pulls data from ring |
39 | * @r: the ring | 39 | * @r: the ring |
40 | * @count: number of samples to try and pull | 40 | * @count: number of samples to try and pull |
41 | * @data: output the actual samples pulled from the hw ring | 41 | * @data: output the actual samples pulled from the hw ring |
@@ -46,8 +46,8 @@ | |||
46 | * can only be inferred approximately from ring buffer events such as 50% full | 46 | * can only be inferred approximately from ring buffer events such as 50% full |
47 | * and knowledge of when buffer was last emptied. This is left to userspace. | 47 | * and knowledge of when buffer was last emptied. This is left to userspace. |
48 | **/ | 48 | **/ |
49 | static int sca3000_rip_hw_rb(struct iio_ring_buffer *r, | 49 | static int sca3000_read_first_n_hw_rb(struct iio_ring_buffer *r, |
50 | size_t count, u8 **data, int *dead_offset) | 50 | size_t count, u8 **data, int *dead_offset) |
51 | { | 51 | { |
52 | struct iio_hw_ring_buffer *hw_ring = iio_to_hw_ring_buf(r); | 52 | struct iio_hw_ring_buffer *hw_ring = iio_to_hw_ring_buf(r); |
53 | struct iio_dev *indio_dev = hw_ring->private; | 53 | struct iio_dev *indio_dev = hw_ring->private; |
@@ -283,7 +283,7 @@ int sca3000_configure_ring(struct iio_dev *indio_dev) | |||
283 | indio_dev->modes |= INDIO_RING_HARDWARE_BUFFER; | 283 | indio_dev->modes |= INDIO_RING_HARDWARE_BUFFER; |
284 | 284 | ||
285 | indio_dev->ring->scan_el_attrs = &sca3000_scan_el_group; | 285 | indio_dev->ring->scan_el_attrs = &sca3000_scan_el_group; |
286 | indio_dev->ring->access.rip_lots = &sca3000_rip_hw_rb; | 286 | indio_dev->ring->access.read_first_n = &sca3000_read_first_n_hw_rb; |
287 | indio_dev->ring->access.get_length = &sca3000_ring_get_length; | 287 | indio_dev->ring->access.get_length = &sca3000_ring_get_length; |
288 | indio_dev->ring->access.get_bytes_per_datum = &sca3000_ring_get_bytes_per_datum; | 288 | indio_dev->ring->access.get_bytes_per_datum = &sca3000_ring_get_bytes_per_datum; |
289 | 289 | ||
diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c index bd4373ae066..3f6bee00a47 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-ring.c | |||
@@ -88,27 +88,27 @@ static int iio_ring_release(struct inode *inode, struct file *filp) | |||
88 | } | 88 | } |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * iio_ring_rip_outer() - chrdev read for ring buffer access | 91 | * iio_ring_read_first_n_outer() - chrdev read for ring buffer access |
92 | * | 92 | * |
93 | * This function relies on all ring buffer implementations having an | 93 | * This function relies on all ring buffer implementations having an |
94 | * iio_ring _bufer as their first element. | 94 | * iio_ring _bufer as their first element. |
95 | **/ | 95 | **/ |
96 | static ssize_t iio_ring_rip_outer(struct file *filp, char __user *buf, | 96 | static ssize_t iio_ring_read_first_n_outer(struct file *filp, char __user *buf, |
97 | size_t count, loff_t *f_ps) | 97 | size_t n, loff_t *f_ps) |
98 | { | 98 | { |
99 | struct iio_ring_buffer *rb = filp->private_data; | 99 | struct iio_ring_buffer *rb = filp->private_data; |
100 | int ret, dead_offset; | 100 | int ret, dead_offset; |
101 | 101 | ||
102 | /* rip lots must exist. */ | 102 | /* rip lots must exist. */ |
103 | if (!rb->access.rip_lots) | 103 | if (!rb->access.read_first_n) |
104 | return -EINVAL; | 104 | return -EINVAL; |
105 | ret = rb->access.rip_lots(rb, count, buf, &dead_offset); | 105 | ret = rb->access.read_first_n(rb, n, buf, &dead_offset); |
106 | 106 | ||
107 | return ret; | 107 | return ret; |
108 | } | 108 | } |
109 | 109 | ||
110 | static const struct file_operations iio_ring_fileops = { | 110 | static const struct file_operations iio_ring_fileops = { |
111 | .read = iio_ring_rip_outer, | 111 | .read = iio_ring_read_first_n_outer, |
112 | .release = iio_ring_release, | 112 | .release = iio_ring_release, |
113 | .open = iio_ring_open, | 113 | .open = iio_ring_open, |
114 | .owner = THIS_MODULE, | 114 | .owner = THIS_MODULE, |
diff --git a/drivers/staging/iio/kfifo_buf.c b/drivers/staging/iio/kfifo_buf.c index a56c0cbba94..74c93f707a3 100644 --- a/drivers/staging/iio/kfifo_buf.c +++ b/drivers/staging/iio/kfifo_buf.c | |||
@@ -181,16 +181,16 @@ int iio_store_to_kfifo(struct iio_ring_buffer *r, u8 *data, s64 timestamp) | |||
181 | } | 181 | } |
182 | EXPORT_SYMBOL(iio_store_to_kfifo); | 182 | EXPORT_SYMBOL(iio_store_to_kfifo); |
183 | 183 | ||
184 | int iio_rip_kfifo(struct iio_ring_buffer *r, | 184 | int iio_read_first_n_kfifo(struct iio_ring_buffer *r, |
185 | size_t count, char __user *buf, int *deadoffset) | 185 | size_t n, char __user *buf, int *deadoffset) |
186 | { | 186 | { |
187 | int ret, copied; | 187 | int ret, copied; |
188 | struct iio_kfifo *kf = iio_to_kfifo(r); | 188 | struct iio_kfifo *kf = iio_to_kfifo(r); |
189 | 189 | ||
190 | *deadoffset = 0; | 190 | *deadoffset = 0; |
191 | ret = kfifo_to_user(&kf->kf, buf, r->bytes_per_datum*count, &copied); | 191 | ret = kfifo_to_user(&kf->kf, buf, r->bytes_per_datum*n, &copied); |
192 | 192 | ||
193 | return copied; | 193 | return copied; |
194 | } | 194 | } |
195 | EXPORT_SYMBOL(iio_rip_kfifo); | 195 | EXPORT_SYMBOL(iio_read_first_n_kfifo); |
196 | MODULE_LICENSE("GPL"); | 196 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/staging/iio/kfifo_buf.h b/drivers/staging/iio/kfifo_buf.h index 8064383bf7c..457010d8af8 100644 --- a/drivers/staging/iio/kfifo_buf.h +++ b/drivers/staging/iio/kfifo_buf.h | |||
@@ -21,10 +21,10 @@ void iio_mark_kfifo_in_use(struct iio_ring_buffer *r); | |||
21 | void iio_unmark_kfifo_in_use(struct iio_ring_buffer *r); | 21 | void iio_unmark_kfifo_in_use(struct iio_ring_buffer *r); |
22 | 22 | ||
23 | int iio_store_to_kfifo(struct iio_ring_buffer *r, u8 *data, s64 timestamp); | 23 | int iio_store_to_kfifo(struct iio_ring_buffer *r, u8 *data, s64 timestamp); |
24 | int iio_rip_kfifo(struct iio_ring_buffer *r, | 24 | int iio_read_first_n_kfifo(struct iio_ring_buffer *r, |
25 | size_t count, | 25 | size_t n, |
26 | char __user *buf, | 26 | char __user *buf, |
27 | int *dead_offset); | 27 | int *dead_offset); |
28 | 28 | ||
29 | int iio_request_update_kfifo(struct iio_ring_buffer *r); | 29 | int iio_request_update_kfifo(struct iio_ring_buffer *r); |
30 | int iio_mark_update_needed_kfifo(struct iio_ring_buffer *r); | 30 | int iio_mark_update_needed_kfifo(struct iio_ring_buffer *r); |
@@ -40,7 +40,7 @@ static inline void iio_kfifo_register_funcs(struct iio_ring_access_funcs *ra) | |||
40 | ra->unmark_in_use = &iio_unmark_kfifo_in_use; | 40 | ra->unmark_in_use = &iio_unmark_kfifo_in_use; |
41 | 41 | ||
42 | ra->store_to = &iio_store_to_kfifo; | 42 | ra->store_to = &iio_store_to_kfifo; |
43 | ra->rip_lots = &iio_rip_kfifo; | 43 | ra->read_first_n = &iio_read_first_n_kfifo; |
44 | 44 | ||
45 | ra->mark_param_change = &iio_mark_update_needed_kfifo; | 45 | ra->mark_param_change = &iio_mark_update_needed_kfifo; |
46 | ra->request_update = &iio_request_update_kfifo; | 46 | ra->request_update = &iio_request_update_kfifo; |
diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h index 32948e55dc8..780c6aac6ec 100644 --- a/drivers/staging/iio/ring_generic.h +++ b/drivers/staging/iio/ring_generic.h | |||
@@ -44,7 +44,7 @@ int iio_push_or_escallate_ring_event(struct iio_ring_buffer *ring_buf, | |||
44 | * @unmark_in_use: reduce reference count when no longer using ring buffer | 44 | * @unmark_in_use: reduce reference count when no longer using ring buffer |
45 | * @store_to: actually store stuff to the ring buffer | 45 | * @store_to: actually store stuff to the ring buffer |
46 | * @read_last: get the last element stored | 46 | * @read_last: get the last element stored |
47 | * @rip_lots: try to get a specified number of elements (must exist) | 47 | * @read_first_n: try to get a specified number of elements (must exist) |
48 | * @mark_param_change: notify ring that some relevant parameter has changed | 48 | * @mark_param_change: notify ring that some relevant parameter has changed |
49 | * Often this means the underlying storage may need to | 49 | * Often this means the underlying storage may need to |
50 | * change. | 50 | * change. |
@@ -71,10 +71,10 @@ struct iio_ring_access_funcs { | |||
71 | 71 | ||
72 | int (*store_to)(struct iio_ring_buffer *ring, u8 *data, s64 timestamp); | 72 | int (*store_to)(struct iio_ring_buffer *ring, u8 *data, s64 timestamp); |
73 | int (*read_last)(struct iio_ring_buffer *ring, u8 *data); | 73 | int (*read_last)(struct iio_ring_buffer *ring, u8 *data); |
74 | int (*rip_lots)(struct iio_ring_buffer *ring, | 74 | int (*read_first_n)(struct iio_ring_buffer *ring, |
75 | size_t count, | 75 | size_t n, |
76 | char __user *buf, | 76 | char __user *buf, |
77 | int *dead_offset); | 77 | int *dead_offset); |
78 | 78 | ||
79 | int (*mark_param_change)(struct iio_ring_buffer *ring); | 79 | int (*mark_param_change)(struct iio_ring_buffer *ring); |
80 | int (*request_update)(struct iio_ring_buffer *ring); | 80 | int (*request_update)(struct iio_ring_buffer *ring); |
diff --git a/drivers/staging/iio/ring_sw.c b/drivers/staging/iio/ring_sw.c index b71ce390064..ea0015eee13 100644 --- a/drivers/staging/iio/ring_sw.c +++ b/drivers/staging/iio/ring_sw.c | |||
@@ -152,8 +152,8 @@ error_ret: | |||
152 | return ret; | 152 | return ret; |
153 | } | 153 | } |
154 | 154 | ||
155 | int iio_rip_sw_rb(struct iio_ring_buffer *r, | 155 | int iio_read_first_n_sw_rb(struct iio_ring_buffer *r, |
156 | size_t count, char __user *buf, int *dead_offset) | 156 | size_t n, char __user *buf, int *dead_offset) |
157 | { | 157 | { |
158 | struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r); | 158 | struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r); |
159 | 159 | ||
@@ -166,15 +166,16 @@ int iio_rip_sw_rb(struct iio_ring_buffer *r, | |||
166 | * read something that is not a whole number of bpds. | 166 | * read something that is not a whole number of bpds. |
167 | * Return an error. | 167 | * Return an error. |
168 | */ | 168 | */ |
169 | if (count % ring->buf.bytes_per_datum) { | 169 | if (n % ring->buf.bytes_per_datum) { |
170 | ret = -EINVAL; | 170 | ret = -EINVAL; |
171 | printk(KERN_INFO "Ring buffer read request not whole number of" | 171 | printk(KERN_INFO "Ring buffer read request not whole number of" |
172 | "samples: Request bytes %zd, Current bytes per datum %d\n", | 172 | "samples: Request bytes %zd, Current bytes per datum %d\n", |
173 | count, ring->buf.bytes_per_datum); | 173 | n, ring->buf.bytes_per_datum); |
174 | goto error_ret; | 174 | goto error_ret; |
175 | } | 175 | } |
176 | /* Limit size to whole of ring buffer */ | 176 | /* Limit size to whole of ring buffer */ |
177 | bytes_to_rip = min((size_t)(ring->buf.bytes_per_datum*ring->buf.length), count); | 177 | bytes_to_rip = min((size_t)(ring->buf.bytes_per_datum*ring->buf.length), |
178 | n); | ||
178 | 179 | ||
179 | data = kmalloc(bytes_to_rip, GFP_KERNEL); | 180 | data = kmalloc(bytes_to_rip, GFP_KERNEL); |
180 | if (data == NULL) { | 181 | if (data == NULL) { |
@@ -278,7 +279,7 @@ error_ret: | |||
278 | 279 | ||
279 | return ret; | 280 | return ret; |
280 | } | 281 | } |
281 | EXPORT_SYMBOL(iio_rip_sw_rb); | 282 | EXPORT_SYMBOL(iio_read_first_n_sw_rb); |
282 | 283 | ||
283 | int iio_store_to_sw_rb(struct iio_ring_buffer *r, u8 *data, s64 timestamp) | 284 | int iio_store_to_sw_rb(struct iio_ring_buffer *r, u8 *data, s64 timestamp) |
284 | { | 285 | { |
diff --git a/drivers/staging/iio/ring_sw.h b/drivers/staging/iio/ring_sw.h index 13341c1e35f..ee86020493f 100644 --- a/drivers/staging/iio/ring_sw.h +++ b/drivers/staging/iio/ring_sw.h | |||
@@ -93,17 +93,17 @@ int iio_read_last_from_sw_rb(struct iio_ring_buffer *r, u8 *data); | |||
93 | int iio_store_to_sw_rb(struct iio_ring_buffer *r, u8 *data, s64 timestamp); | 93 | int iio_store_to_sw_rb(struct iio_ring_buffer *r, u8 *data, s64 timestamp); |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * iio_rip_sw_rb() - attempt to read data from the ring buffer | 96 | * iio_read_first_n_sw_rb() - attempt to read data from the ring buffer |
97 | * @r: ring buffer instance | 97 | * @r: ring buffer instance |
98 | * @count: number of datum's to try and read | 98 | * @n: number of datum's to try and read |
99 | * @buf: userspace buffer into which data is copied | 99 | * @buf: userspace buffer into which data is copied |
100 | * @dead_offset: how much of the stored data was possibly invalidated by | 100 | * @dead_offset: how much of the stored data was possibly invalidated by |
101 | * the end of the copy. | 101 | * the end of the copy. |
102 | **/ | 102 | **/ |
103 | int iio_rip_sw_rb(struct iio_ring_buffer *r, | 103 | int iio_read_first_n_sw_rb(struct iio_ring_buffer *r, |
104 | size_t count, | 104 | size_t n, |
105 | char __user *buf, | 105 | char __user *buf, |
106 | int *dead_offset); | 106 | int *dead_offset); |
107 | 107 | ||
108 | /** | 108 | /** |
109 | * iio_request_update_sw_rb() - update params if update needed | 109 | * iio_request_update_sw_rb() - update params if update needed |
@@ -161,7 +161,7 @@ static inline void iio_ring_sw_register_funcs(struct iio_ring_access_funcs *ra) | |||
161 | 161 | ||
162 | ra->store_to = &iio_store_to_sw_rb; | 162 | ra->store_to = &iio_store_to_sw_rb; |
163 | ra->read_last = &iio_read_last_from_sw_rb; | 163 | ra->read_last = &iio_read_last_from_sw_rb; |
164 | ra->rip_lots = &iio_rip_sw_rb; | 164 | ra->read_first_n = &iio_read_first_n_sw_rb; |
165 | 165 | ||
166 | ra->mark_param_change = &iio_mark_update_needed_sw_rb; | 166 | ra->mark_param_change = &iio_mark_update_needed_sw_rb; |
167 | ra->request_update = &iio_request_update_sw_rb; | 167 | ra->request_update = &iio_request_update_sw_rb; |