Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 281273
b: refs/heads/master
c: 1932432
h: refs/heads/master
i:
  281271: 1ba4c97
v: v3
  • Loading branch information
Greg Kroah-Hartman committed Dec 8, 2011
1 parent 42eeaf0 commit 711c783
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 73 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: a1e44d6ac5577b78ec85833b22d58345b2758ebb
refs/heads/master: 19324328ad202b350c3803aa2bea65ff5f043d7f
6 changes: 3 additions & 3 deletions trunk/drivers/staging/iio/accel/sca3000_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1166,9 +1166,9 @@ static int __devinit sca3000_probe(struct spi_device *spi)
if (ret < 0)
goto error_unregister_dev;
if (indio_dev->buffer) {
iio_scan_mask_set(indio_dev->buffer, 0);
iio_scan_mask_set(indio_dev->buffer, 1);
iio_scan_mask_set(indio_dev->buffer, 2);
iio_scan_mask_set(indio_dev, indio_dev->buffer, 0);
iio_scan_mask_set(indio_dev, indio_dev->buffer, 1);
iio_scan_mask_set(indio_dev, indio_dev->buffer, 2);
}

if (spi->irq) {
Expand Down
11 changes: 4 additions & 7 deletions trunk/drivers/staging/iio/accel/sca3000_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ static ssize_t sca3000_query_ring_int(struct device *dev,
{
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret, val;
struct iio_buffer *ring = dev_get_drvdata(dev);
struct iio_dev *indio_dev = ring->indio_dev;
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct sca3000_state *st = iio_priv(indio_dev);

mutex_lock(&st->lock);
Expand All @@ -179,8 +178,7 @@ static ssize_t sca3000_set_ring_int(struct device *dev,
const char *buf,
size_t len)
{
struct iio_buffer *ring = dev_get_drvdata(dev);
struct iio_dev *indio_dev = ring->indio_dev;
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct sca3000_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
long val;
Expand Down Expand Up @@ -221,8 +219,7 @@ static ssize_t sca3000_show_buffer_scale(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct iio_buffer *ring = dev_get_drvdata(dev);
struct iio_dev *indio_dev = ring->indio_dev;
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct sca3000_state *st = iio_priv(indio_dev);

return sprintf(buf, "0.%06d\n", 4*st->info->scale);
Expand Down Expand Up @@ -267,7 +264,7 @@ static struct iio_buffer *sca3000_rb_allocate(struct iio_dev *indio_dev)
buf = &ring->buf;
buf->stufftoread = 0;
buf->attrs = &sca3000_ring_attr;
iio_buffer_init(buf, indio_dev);
iio_buffer_init(buf);

return buf;
}
Expand Down
23 changes: 11 additions & 12 deletions trunk/drivers/staging/iio/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ struct iio_buffer;
* @mark_in_use: reference counting, typically to prevent module removal
* @unmark_in_use: reduce reference count when no longer using buffer
* @store_to: actually store stuff to the buffer
* @read_last: get the last element stored
* @read_first_n: try to get a specified number of elements (must exist)
* @mark_param_change: notify buffer that some relevant parameter has changed
* Often this means the underlying storage may need to
Expand All @@ -48,7 +47,6 @@ struct iio_buffer_access_funcs {
void (*unmark_in_use)(struct iio_buffer *buffer);

int (*store_to)(struct iio_buffer *buffer, u8 *data, s64 timestamp);
int (*read_last)(struct iio_buffer *buffer, u8 *data);
int (*read_first_n)(struct iio_buffer *buffer,
size_t n,
char __user *buf);
Expand All @@ -67,21 +65,25 @@ struct iio_buffer_access_funcs {

/**
* struct iio_buffer - general buffer structure
* @indio_dev: industrial I/O device structure
* @length: [DEVICE] number of datums in buffer
* @bytes_per_datum: [DEVICE] size of individual datum including timestamp
* @scan_el_attrs: [DRIVER] control of scan elements if that scan mode
* control method is used
* @scan_mask: [INTERN] bitmask used in masking scan mode elements
* @scan_index_timestamp:[INTERN] cache of the index to the timestamp
* @scan_timestamp: [INTERN] does the scan mode include a timestamp
* @access: [DRIVER] buffer access functions associated with the
* implementation.
* @scan_el_dev_attr_list:[INTERN] list of scan element related attributes.
* @scan_el_group: [DRIVER] attribute group for those attributes not
* created from the iio_chan_info array.
* @pollq: [INTERN] wait queue to allow for polling on the buffer.
* @stufftoread: [INTERN] flag to indicate new data.
* @flags: [INTERN] file ops related flags including busy flag.
* @demux_list: [INTERN] list of operations required to demux the scan.
* @demux_bounce: [INTERN] buffer for doing gather from incoming scan.
**/
struct iio_buffer {
struct iio_dev *indio_dev;
int length;
int bytes_per_datum;
struct attribute_group *scan_el_attrs;
Expand All @@ -102,10 +104,8 @@ struct iio_buffer {
/**
* iio_buffer_init() - Initialize the buffer structure
* @buffer: buffer to be initialized
* @indio_dev: the iio device the buffer is assocated with
**/
void iio_buffer_init(struct iio_buffer *buffer,
struct iio_dev *indio_dev);
void iio_buffer_init(struct iio_buffer *buffer);

void iio_buffer_deinit(struct iio_buffer *buffer);

Expand All @@ -122,17 +122,16 @@ static inline void __iio_update_buffer(struct iio_buffer *buffer,
buffer->length = length;
}

int iio_scan_mask_query(struct iio_buffer *buffer, int bit);
int iio_scan_mask_query(struct iio_dev *indio_dev,
struct iio_buffer *buffer, int bit);

/**
* iio_scan_mask_set() - set particular bit in the scan mask
* @buffer: the buffer whose scan mask we are interested in
* @bit: the bit to be set.
**/
int iio_scan_mask_set(struct iio_buffer *buffer, int bit);

#define to_iio_buffer(d) \
container_of(d, struct iio_buffer, dev)
int iio_scan_mask_set(struct iio_dev *indio_dev,
struct iio_buffer *buffer, int bit);

/**
* iio_push_to_buffer() - push to a registered buffer.
Expand Down
15 changes: 10 additions & 5 deletions trunk/drivers/staging/iio/gyro/adis16260_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,11 +632,16 @@ static int __devinit adis16260_probe(struct spi_device *spi)
}
if (indio_dev->buffer) {
/* Set default scan mode */
iio_scan_mask_set(indio_dev->buffer, ADIS16260_SCAN_SUPPLY);
iio_scan_mask_set(indio_dev->buffer, ADIS16260_SCAN_GYRO);
iio_scan_mask_set(indio_dev->buffer, ADIS16260_SCAN_AUX_ADC);
iio_scan_mask_set(indio_dev->buffer, ADIS16260_SCAN_TEMP);
iio_scan_mask_set(indio_dev->buffer, ADIS16260_SCAN_ANGL);
iio_scan_mask_set(indio_dev, indio_dev->buffer,
ADIS16260_SCAN_SUPPLY);
iio_scan_mask_set(indio_dev, indio_dev->buffer,
ADIS16260_SCAN_GYRO);
iio_scan_mask_set(indio_dev, indio_dev->buffer,
ADIS16260_SCAN_AUX_ADC);
iio_scan_mask_set(indio_dev, indio_dev->buffer,
ADIS16260_SCAN_TEMP);
iio_scan_mask_set(indio_dev, indio_dev->buffer,
ADIS16260_SCAN_ANGL);
}
if (spi->irq) {
ret = adis16260_probe_trigger(indio_dev);
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/staging/iio/impedance-analyzer/ad5933.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,8 @@ static int __devinit ad5933_probe(struct i2c_client *client,
goto error_unreg_ring;

/* enable both REAL and IMAG channels by default */
iio_scan_mask_set(indio_dev->buffer, 0);
iio_scan_mask_set(indio_dev->buffer, 1);
iio_scan_mask_set(indio_dev, indio_dev->buffer, 0);
iio_scan_mask_set(indio_dev, indio_dev->buffer, 1);

ret = ad5933_setup(st);
if (ret)
Expand Down
15 changes: 7 additions & 8 deletions trunk/drivers/staging/iio/industrialio-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ void iio_chrdev_buffer_release(struct iio_dev *indio_dev)
rb->access->unmark_in_use(rb);
}

void iio_buffer_init(struct iio_buffer *buffer, struct iio_dev *indio_dev)
void iio_buffer_init(struct iio_buffer *buffer)
{
INIT_LIST_HEAD(&buffer->demux_list);
buffer->indio_dev = indio_dev;
init_waitqueue_head(&buffer->pollq);
}
EXPORT_SYMBOL(iio_buffer_init);
Expand Down Expand Up @@ -158,15 +157,15 @@ static ssize_t iio_scan_el_store(struct device *dev,
ret = -EBUSY;
goto error_ret;
}
ret = iio_scan_mask_query(buffer, this_attr->address);
ret = iio_scan_mask_query(indio_dev, buffer, this_attr->address);
if (ret < 0)
goto error_ret;
if (!state && ret) {
ret = iio_scan_mask_clear(buffer, this_attr->address);
if (ret)
goto error_ret;
} else if (state && !ret) {
ret = iio_scan_mask_set(buffer, this_attr->address);
ret = iio_scan_mask_set(indio_dev, buffer, this_attr->address);
if (ret)
goto error_ret;
}
Expand Down Expand Up @@ -578,9 +577,9 @@ EXPORT_SYMBOL(iio_sw_buffer_preenable);
* @buffer: the buffer whose scan mask we are interested in
* @bit: the bit to be set.
**/
int iio_scan_mask_set(struct iio_buffer *buffer, int bit)
int iio_scan_mask_set(struct iio_dev *indio_dev,
struct iio_buffer *buffer, int bit)
{
struct iio_dev *indio_dev = buffer->indio_dev;
unsigned long *mask;
unsigned long *trialmask;

Expand Down Expand Up @@ -615,9 +614,9 @@ int iio_scan_mask_set(struct iio_buffer *buffer, int bit)
};
EXPORT_SYMBOL_GPL(iio_scan_mask_set);

int iio_scan_mask_query(struct iio_buffer *buffer, int bit)
int iio_scan_mask_query(struct iio_dev *indio_dev,
struct iio_buffer *buffer, int bit)
{
struct iio_dev *indio_dev = buffer->indio_dev;
long *mask;

if (bit > indio_dev->masklength)
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/staging/iio/kfifo_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct iio_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev)
if (!kf)
return NULL;
kf->update_needed = true;
iio_buffer_init(&kf->buffer, indio_dev);
iio_buffer_init(&kf->buffer);
kf->buffer.attrs = &iio_kfifo_attribute_group;
__iio_init_kfifo(kf);

Expand Down
35 changes: 1 addition & 34 deletions trunk/drivers/staging/iio/ring_sw.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* @data: the ring buffer memory
* @read_p: read pointer (oldest available)
* @write_p: write pointer
* @last_written_p: read pointer (newest available)
* @half_p: half buffer length behind write_p (event generation)
* @use_count: reference count to prevent resizing when in use
* @update_needed: flag to indicated change in size requested
Expand All @@ -37,7 +36,6 @@ struct iio_sw_ring_buffer {
unsigned char *data;
unsigned char *read_p;
unsigned char *write_p;
unsigned char *last_written_p;
/* used to act as a point at which to signal an event */
unsigned char *half_p;
int use_count;
Expand All @@ -56,7 +54,6 @@ static inline int __iio_allocate_sw_ring_buffer(struct iio_sw_ring_buffer *ring,
ring->data = kmalloc(length*ring->buf.bytes_per_datum, GFP_ATOMIC);
ring->read_p = NULL;
ring->write_p = NULL;
ring->last_written_p = NULL;
ring->half_p = NULL;
return ring->data ? 0 : -ENOMEM;
}
Expand Down Expand Up @@ -115,7 +112,6 @@ static int iio_store_to_sw_ring(struct iio_sw_ring_buffer *ring,
* Always valid as either points to latest or second latest value.
* Before this runs it is null and read attempts fail with -EAGAIN.
*/
ring->last_written_p = ring->write_p;
barrier();
/* temp_ptr used to ensure we never have an invalid pointer
* it may be slightly lagging, but never invalid
Expand Down Expand Up @@ -293,34 +289,6 @@ static int iio_store_to_sw_rb(struct iio_buffer *r,
return iio_store_to_sw_ring(ring, data, timestamp);
}

static int iio_read_last_from_sw_ring(struct iio_sw_ring_buffer *ring,
unsigned char *data)
{
unsigned char *last_written_p_copy;

iio_mark_sw_rb_in_use(&ring->buf);
again:
barrier();
last_written_p_copy = ring->last_written_p;
barrier(); /*unnessecary? */
/* Check there is anything here */
if (last_written_p_copy == NULL)
return -EAGAIN;
memcpy(data, last_written_p_copy, ring->buf.bytes_per_datum);

if (unlikely(ring->last_written_p != last_written_p_copy))
goto again;

iio_unmark_sw_rb_in_use(&ring->buf);
return 0;
}

static int iio_read_last_from_sw_rb(struct iio_buffer *r,
unsigned char *data)
{
return iio_read_last_from_sw_ring(iio_to_sw_ring(r), data);
}

static int iio_request_update_sw_rb(struct iio_buffer *r)
{
int ret = 0;
Expand Down Expand Up @@ -405,7 +373,7 @@ struct iio_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev)
return NULL;
ring->update_needed = true;
buf = &ring->buf;
iio_buffer_init(buf, indio_dev);
iio_buffer_init(buf);
__iio_init_sw_ring_buffer(ring);
buf->attrs = &iio_ring_attribute_group;

Expand All @@ -423,7 +391,6 @@ const struct iio_buffer_access_funcs ring_sw_access_funcs = {
.mark_in_use = &iio_mark_sw_rb_in_use,
.unmark_in_use = &iio_unmark_sw_rb_in_use,
.store_to = &iio_store_to_sw_rb,
.read_last = &iio_read_last_from_sw_rb,
.read_first_n = &iio_read_first_n_sw_rb,
.mark_param_change = &iio_mark_update_needed_sw_rb,
.request_update = &iio_request_update_sw_rb,
Expand Down

0 comments on commit 711c783

Please sign in to comment.