Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 249776
b: refs/heads/master
c: b26a218
h: refs/heads/master
v: v3
  • Loading branch information
Jonathan Cameron authored and Greg Kroah-Hartman committed May 19, 2011
1 parent 68dca9b commit 232a125
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 25888dc51163a566f8c8f18a84c100851d12738c
refs/heads/master: b26a2188e0464f5962caff62074c91ef1c92056a
5 changes: 1 addition & 4 deletions trunk/drivers/staging/iio/accel/sca3000_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,13 @@ static int sca3000_read_data(struct sca3000_state *st,
* @r: the ring
* @count: number of samples to try and pull
* @data: output the actual samples pulled from the hw ring
* @dead_offset: cheating a bit here: Set to 1 so as to allow for the
* leading byte used in bus comms.
*
* Currently does not provide timestamps. As the hardware doesn't add them they
* can only be inferred approximately from ring buffer events such as 50% full
* and knowledge of when buffer was last emptied. This is left to userspace.
**/
static int sca3000_read_first_n_hw_rb(struct iio_ring_buffer *r,
size_t count, char __user *buf,
int *dead_offset)
size_t count, char __user *buf)
{
struct iio_hw_ring_buffer *hw_ring = iio_to_hw_ring_buf(r);
struct iio_dev *indio_dev = hw_ring->private;
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/staging/iio/industrialio-ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ static ssize_t iio_ring_read_first_n_outer(struct file *filp, char __user *buf,
size_t n, loff_t *f_ps)
{
struct iio_ring_buffer *rb = filp->private_data;
int ret, dead_offset;
int ret;

/* rip lots must exist. */
if (!rb->access.read_first_n)
return -EINVAL;
ret = rb->access.read_first_n(rb, n, buf, &dead_offset);
ret = rb->access.read_first_n(rb, n, buf);

return ret;
}
Expand Down
3 changes: 1 addition & 2 deletions trunk/drivers/staging/iio/kfifo_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,11 @@ int iio_store_to_kfifo(struct iio_ring_buffer *r, u8 *data, s64 timestamp)
EXPORT_SYMBOL(iio_store_to_kfifo);

int iio_read_first_n_kfifo(struct iio_ring_buffer *r,
size_t n, char __user *buf, int *deadoffset)
size_t n, char __user *buf)
{
int ret, copied;
struct iio_kfifo *kf = iio_to_kfifo(r);

*deadoffset = 0;
ret = kfifo_to_user(&kf->kf, buf, r->bytes_per_datum*n, &copied);

return copied;
Expand Down
3 changes: 1 addition & 2 deletions trunk/drivers/staging/iio/kfifo_buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ void iio_unmark_kfifo_in_use(struct iio_ring_buffer *r);
int iio_store_to_kfifo(struct iio_ring_buffer *r, u8 *data, s64 timestamp);
int iio_read_first_n_kfifo(struct iio_ring_buffer *r,
size_t n,
char __user *buf,
int *dead_offset);
char __user *buf);

int iio_request_update_kfifo(struct iio_ring_buffer *r);
int iio_mark_update_needed_kfifo(struct iio_ring_buffer *r);
Expand Down
3 changes: 1 addition & 2 deletions trunk/drivers/staging/iio/ring_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ struct iio_ring_access_funcs {
int (*read_last)(struct iio_ring_buffer *ring, u8 *data);
int (*read_first_n)(struct iio_ring_buffer *ring,
size_t n,
char __user *buf,
int *dead_offset);
char __user *buf);

int (*mark_param_change)(struct iio_ring_buffer *ring);
int (*request_update)(struct iio_ring_buffer *ring);
Expand Down
15 changes: 7 additions & 8 deletions trunk/drivers/staging/iio/ring_sw.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,13 @@ static int iio_store_to_sw_ring(struct iio_sw_ring_buffer *ring,
}

int iio_read_first_n_sw_rb(struct iio_ring_buffer *r,
size_t n, char __user *buf, int *dead_offset)
size_t n, char __user *buf)
{
struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r);

u8 *initial_read_p, *initial_write_p, *current_read_p, *end_read_p;
u8 *data;
int ret, max_copied;
int bytes_to_rip;
int ret, max_copied, bytes_to_rip, dead_offset;

/* A userspace program has probably made an error if it tries to
* read something that is not a whole number of bpds.
Expand Down Expand Up @@ -227,17 +226,17 @@ int iio_read_first_n_sw_rb(struct iio_ring_buffer *r,
current_read_p = ring->read_p;

if (initial_read_p <= current_read_p)
*dead_offset = current_read_p - initial_read_p;
dead_offset = current_read_p - initial_read_p;
else
*dead_offset = ring->buf.length*ring->buf.bytes_per_datum
dead_offset = ring->buf.length*ring->buf.bytes_per_datum
- (initial_read_p - current_read_p);

/* possible issue if the initial write has been lapped or indeed
* the point we were reading to has been passed */
/* No valid data read.
* In this case the read pointer is already correct having been
* pushed further than we would look. */
if (max_copied - *dead_offset < 0) {
if (max_copied - dead_offset < 0) {
ret = 0;
goto error_free_data_cpy;
}
Expand All @@ -253,9 +252,9 @@ int iio_read_first_n_sw_rb(struct iio_ring_buffer *r,
while (ring->read_p != end_read_p)
ring->read_p = end_read_p;

ret = max_copied - *dead_offset;
ret = max_copied - dead_offset;

if (copy_to_user(buf, data + *dead_offset, ret)) {
if (copy_to_user(buf, data + dead_offset, ret)) {
ret = -EFAULT;
goto error_free_data_cpy;
}
Expand Down
4 changes: 1 addition & 3 deletions trunk/drivers/staging/iio/ring_sw.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,11 @@ int iio_store_to_sw_rb(struct iio_ring_buffer *r, u8 *data, s64 timestamp);
* @r: ring buffer instance
* @n: number of datum's to try and read
* @buf: userspace buffer into which data is copied
* @dead_offset: how much of the stored data was possibly invalidated by
* the end of the copy.
**/
int iio_read_first_n_sw_rb(struct iio_ring_buffer *r,
size_t n,
char __user *buf,
int *dead_offset);
char __user *buf);

/**
* iio_request_update_sw_rb() - update params if update needed
Expand Down

0 comments on commit 232a125

Please sign in to comment.