aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/iio/adc
diff options
context:
space:
mode:
authorManuel Stahl <manuel.stahl@iis.fraunhofer.de>2010-08-31 05:32:52 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-08-31 14:42:02 -0400
commitbf32963cbeb5d34fa32a4c1eeed1163ab1b4501c (patch)
tree221c5e12d26142d6b8b5a3cfff844c9ed9ad3899 /drivers/staging/iio/adc
parent07e6229e42e4d679cdbaada8f7966491c69710e7 (diff)
staging: iio move scan_elements into ring buffer
tested with sca3000, adis16400 Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/adc')
-rw-r--r--drivers/staging/iio/adc/max1363_core.c1
-rw-r--r--drivers/staging/iio/adc/max1363_ring.c18
2 files changed, 10 insertions, 9 deletions
diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c
index 6435e509dd5..1dc428fc0cc 100644
--- a/drivers/staging/iio/adc/max1363_core.c
+++ b/drivers/staging/iio/adc/max1363_core.c
@@ -1631,7 +1631,6 @@ static int __devinit max1363_probe(struct i2c_client *client,
1631 st->indio_dev->attrs = st->chip_info->dev_attrs; 1631 st->indio_dev->attrs = st->chip_info->dev_attrs;
1632 1632
1633 /* Todo: this shouldn't be here. */ 1633 /* Todo: this shouldn't be here. */
1634 st->indio_dev->scan_el_attrs = st->chip_info->scan_attrs;
1635 st->indio_dev->dev_data = (void *)(st); 1634 st->indio_dev->dev_data = (void *)(st);
1636 st->indio_dev->driver_module = THIS_MODULE; 1635 st->indio_dev->driver_module = THIS_MODULE;
1637 st->indio_dev->modes = INDIO_DIRECT_MODE; 1636 st->indio_dev->modes = INDIO_DIRECT_MODE;
diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c
index edac0ba6652..1d6ce54e9a8 100644
--- a/drivers/staging/iio/adc/max1363_ring.c
+++ b/drivers/staging/iio/adc/max1363_ring.c
@@ -30,6 +30,7 @@
30/* Todo: test this */ 30/* Todo: test this */
31int max1363_single_channel_from_ring(long mask, struct max1363_state *st) 31int max1363_single_channel_from_ring(long mask, struct max1363_state *st)
32{ 32{
33 struct iio_ring_buffer *ring = st->indio_dev->ring;
33 unsigned long numvals; 34 unsigned long numvals;
34 int count = 0, ret; 35 int count = 0, ret;
35 u8 *ring_data; 36 u8 *ring_data;
@@ -44,8 +45,7 @@ int max1363_single_channel_from_ring(long mask, struct max1363_state *st)
44 ret = -ENOMEM; 45 ret = -ENOMEM;
45 goto error_ret; 46 goto error_ret;
46 } 47 }
47 ret = st->indio_dev->ring->access.read_last(st->indio_dev->ring, 48 ret = ring->access.read_last(ring, ring_data);
48 ring_data);
49 if (ret) 49 if (ret)
50 goto error_free_ring_data; 50 goto error_free_ring_data;
51 /* Need a count of channels prior to this one */ 51 /* Need a count of channels prior to this one */
@@ -77,6 +77,7 @@ error_ret:
77static int max1363_ring_preenable(struct iio_dev *indio_dev) 77static int max1363_ring_preenable(struct iio_dev *indio_dev)
78{ 78{
79 struct max1363_state *st = indio_dev->dev_data; 79 struct max1363_state *st = indio_dev->dev_data;
80 struct iio_ring_buffer *ring = indio_dev->ring;
80 size_t d_size; 81 size_t d_size;
81 unsigned long numvals; 82 unsigned long numvals;
82 83
@@ -84,7 +85,7 @@ static int max1363_ring_preenable(struct iio_dev *indio_dev)
84 * Need to figure out the current mode based upon the requested 85 * Need to figure out the current mode based upon the requested
85 * scan mask in iio_dev 86 * scan mask in iio_dev
86 */ 87 */
87 st->current_mode = max1363_match_mode(st->indio_dev->scan_mask, 88 st->current_mode = max1363_match_mode(ring->scan_mask,
88 st->chip_info); 89 st->chip_info);
89 if (!st->current_mode) 90 if (!st->current_mode)
90 return -EINVAL; 91 return -EINVAL;
@@ -92,14 +93,14 @@ static int max1363_ring_preenable(struct iio_dev *indio_dev)
92 max1363_set_scan_mode(st); 93 max1363_set_scan_mode(st);
93 94
94 numvals = hweight_long(st->current_mode->modemask); 95 numvals = hweight_long(st->current_mode->modemask);
95 if (indio_dev->ring->access.set_bytes_per_datum) { 96 if (ring->access.set_bytes_per_datum) {
96 if (st->chip_info->bits != 8) 97 if (st->chip_info->bits != 8)
97 d_size = numvals*2 + sizeof(s64); 98 d_size = numvals*2 + sizeof(s64);
98 else 99 else
99 d_size = numvals + sizeof(s64); 100 d_size = numvals + sizeof(s64);
100 if (d_size % 8) 101 if (d_size % 8)
101 d_size += 8 - (d_size % 8); 102 d_size += 8 - (d_size % 8);
102 indio_dev->ring->access.set_bytes_per_datum(indio_dev->ring, d_size); 103 ring->access.set_bytes_per_datum(ring, d_size);
103 } 104 }
104 105
105 return 0; 106 return 0;
@@ -135,7 +136,7 @@ static void max1363_poll_bh_to_ring(struct work_struct *work_s)
135 struct max1363_state *st = container_of(work_s, struct max1363_state, 136 struct max1363_state *st = container_of(work_s, struct max1363_state,
136 poll_work); 137 poll_work);
137 struct iio_dev *indio_dev = st->indio_dev; 138 struct iio_dev *indio_dev = st->indio_dev;
138 struct iio_sw_ring_buffer *ring = iio_to_sw_ring(indio_dev->ring); 139 struct iio_sw_ring_buffer *sw_ring = iio_to_sw_ring(indio_dev->ring);
139 s64 time_ns; 140 s64 time_ns;
140 __u8 *rxbuf; 141 __u8 *rxbuf;
141 int b_sent; 142 int b_sent;
@@ -175,7 +176,7 @@ static void max1363_poll_bh_to_ring(struct work_struct *work_s)
175 176
176 memcpy(rxbuf + d_size - sizeof(s64), &time_ns, sizeof(time_ns)); 177 memcpy(rxbuf + d_size - sizeof(s64), &time_ns, sizeof(time_ns));
177 178
178 indio_dev->ring->access.store_to(&ring->buf, rxbuf, time_ns); 179 indio_dev->ring->access.store_to(&sw_ring->buf, rxbuf, time_ns);
179done: 180done:
180 kfree(rxbuf); 181 kfree(rxbuf);
181 atomic_dec(&st->protect_ring); 182 atomic_dec(&st->protect_ring);
@@ -193,12 +194,13 @@ int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev)
193 goto error_ret; 194 goto error_ret;
194 } 195 }
195 /* Effectively select the ring buffer implementation */ 196 /* Effectively select the ring buffer implementation */
196 iio_ring_sw_register_funcs(&st->indio_dev->ring->access); 197 iio_ring_sw_register_funcs(&indio_dev->ring->access);
197 ret = iio_alloc_pollfunc(indio_dev, NULL, &max1363_poll_func_th); 198 ret = iio_alloc_pollfunc(indio_dev, NULL, &max1363_poll_func_th);
198 if (ret) 199 if (ret)
199 goto error_deallocate_sw_rb; 200 goto error_deallocate_sw_rb;
200 201
201 /* Ring buffer functions - here trigger setup related */ 202 /* Ring buffer functions - here trigger setup related */
203 indio_dev->ring->scan_el_attrs = st->chip_info->scan_attrs;
202 indio_dev->ring->postenable = &iio_triggered_ring_postenable; 204 indio_dev->ring->postenable = &iio_triggered_ring_postenable;
203 indio_dev->ring->preenable = &max1363_ring_preenable; 205 indio_dev->ring->preenable = &max1363_ring_preenable;
204 indio_dev->ring->predisable = &iio_triggered_ring_predisable; 206 indio_dev->ring->predisable = &iio_triggered_ring_predisable;