aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/industrialio-buffer.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-08-25 14:09:35 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-08-25 14:09:35 -0400
commit39bdc95871b57828b3bbefc0280a1a80a6b63d9e (patch)
treefb4cc664f4e07d1e49f60e743cc80096bc973182 /drivers/iio/industrialio-buffer.c
parented7f92da59f24dd966555efef978fe14085b3318 (diff)
parentff9e7621586ff8b86a18cfbb7c437c277ebc1970 (diff)
Merge tag 'iio-for-3.18a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into work-next
Jonathan writes: 1st round of new IIO drivers, functionality and cleanups for the 3.18 cycle. Maintainer Updates * Add 3 designated reviewers for IIO. Lars, Peter and Hartmut have been actively reviewing a lot of patches for a while now so this reflects the status quo. These three are probably the only reason I keep my head above the water! New drivers and device support * max5821 DAC * Rockchip SARADC * TI ADC128S052 ADC * BMC150 Accelerometer * exynos ADC driver gains support for s3c24xx and s3c64xx parts. * kxcjk-1013 gainst range control and runtime PM support to drive down it's power usage. Driver removals * Drop ad5930, ad99850, ad9852, ad9910 and ad9951 drivers on the simple basis that they drivers just provided a register write function with no compliant user space ABI whatsoever. Much better to drop them and start again for these in the fullness of time. Core Enhancements * Join together neighbouring elements in the demux units that feeds the binary interfaces. This cuts down on the number of individual copies needed when splitting out individual channels from the incoming channel scans. * Other demux related cleanups such as using roundup instead of a local implementation. Cleanups * Drop an unnecessary double setting of the owner field in xilinx adc. * Some more patches to use managed (devm) interfaces to cut down on complexity of removal code. * adis16060 coding style fixlets. * Fix some incorrect error returns in the Xilinx ADC driver. * Coding style fixlets for various accelerometer drivers. * Some sparse warning fixes to do with endianness and sign of variables. * Fix an incorrect and entirely pointless use of sizeof on a dynamic pointer in hid-sensor-magn-3d by dropping the relevant code.
Diffstat (limited to 'drivers/iio/industrialio-buffer.c')
-rw-r--r--drivers/iio/industrialio-buffer.c63
1 files changed, 33 insertions, 30 deletions
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 0472ee268271..f971f79103ec 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -942,13 +942,34 @@ int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data)
942} 942}
943EXPORT_SYMBOL_GPL(iio_push_to_buffers); 943EXPORT_SYMBOL_GPL(iio_push_to_buffers);
944 944
945static int iio_buffer_add_demux(struct iio_buffer *buffer,
946 struct iio_demux_table **p, unsigned int in_loc, unsigned int out_loc,
947 unsigned int length)
948{
949
950 if (*p && (*p)->from + (*p)->length == in_loc &&
951 (*p)->to + (*p)->length == out_loc) {
952 (*p)->length += length;
953 } else {
954 *p = kmalloc(sizeof(**p), GFP_KERNEL);
955 if (*p == NULL)
956 return -ENOMEM;
957 (*p)->from = in_loc;
958 (*p)->to = out_loc;
959 (*p)->length = length;
960 list_add_tail(&(*p)->l, &buffer->demux_list);
961 }
962
963 return 0;
964}
965
945static int iio_buffer_update_demux(struct iio_dev *indio_dev, 966static int iio_buffer_update_demux(struct iio_dev *indio_dev,
946 struct iio_buffer *buffer) 967 struct iio_buffer *buffer)
947{ 968{
948 const struct iio_chan_spec *ch; 969 const struct iio_chan_spec *ch;
949 int ret, in_ind = -1, out_ind, length; 970 int ret, in_ind = -1, out_ind, length;
950 unsigned in_loc = 0, out_loc = 0; 971 unsigned in_loc = 0, out_loc = 0;
951 struct iio_demux_table *p; 972 struct iio_demux_table *p = NULL;
952 973
953 /* Clear out any old demux */ 974 /* Clear out any old demux */
954 iio_buffer_demux_free(buffer); 975 iio_buffer_demux_free(buffer);
@@ -979,14 +1000,7 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
979 else 1000 else
980 length = ch->scan_type.storagebits / 8; 1001 length = ch->scan_type.storagebits / 8;
981 /* Make sure we are aligned */ 1002 /* Make sure we are aligned */
982 in_loc += length; 1003 in_loc = roundup(in_loc, length) + length;
983 if (in_loc % length)
984 in_loc += length - in_loc % length;
985 }
986 p = kmalloc(sizeof(*p), GFP_KERNEL);
987 if (p == NULL) {
988 ret = -ENOMEM;
989 goto error_clear_mux_table;
990 } 1004 }
991 ch = iio_find_channel_from_si(indio_dev, in_ind); 1005 ch = iio_find_channel_from_si(indio_dev, in_ind);
992 if (ch->scan_type.repeat > 1) 1006 if (ch->scan_type.repeat > 1)
@@ -994,24 +1008,16 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
994 ch->scan_type.repeat; 1008 ch->scan_type.repeat;
995 else 1009 else
996 length = ch->scan_type.storagebits / 8; 1010 length = ch->scan_type.storagebits / 8;
997 if (out_loc % length) 1011 out_loc = roundup(out_loc, length);
998 out_loc += length - out_loc % length; 1012 in_loc = roundup(in_loc, length);
999 if (in_loc % length) 1013 ret = iio_buffer_add_demux(buffer, &p, in_loc, out_loc, length);
1000 in_loc += length - in_loc % length; 1014 if (ret)
1001 p->from = in_loc; 1015 goto error_clear_mux_table;
1002 p->to = out_loc;
1003 p->length = length;
1004 list_add_tail(&p->l, &buffer->demux_list);
1005 out_loc += length; 1016 out_loc += length;
1006 in_loc += length; 1017 in_loc += length;
1007 } 1018 }
1008 /* Relies on scan_timestamp being last */ 1019 /* Relies on scan_timestamp being last */
1009 if (buffer->scan_timestamp) { 1020 if (buffer->scan_timestamp) {
1010 p = kmalloc(sizeof(*p), GFP_KERNEL);
1011 if (p == NULL) {
1012 ret = -ENOMEM;
1013 goto error_clear_mux_table;
1014 }
1015 ch = iio_find_channel_from_si(indio_dev, 1021 ch = iio_find_channel_from_si(indio_dev,
1016 indio_dev->scan_index_timestamp); 1022 indio_dev->scan_index_timestamp);
1017 if (ch->scan_type.repeat > 1) 1023 if (ch->scan_type.repeat > 1)
@@ -1019,14 +1025,11 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
1019 ch->scan_type.repeat; 1025 ch->scan_type.repeat;
1020 else 1026 else
1021 length = ch->scan_type.storagebits / 8; 1027 length = ch->scan_type.storagebits / 8;
1022 if (out_loc % length) 1028 out_loc = roundup(out_loc, length);
1023 out_loc += length - out_loc % length; 1029 in_loc = roundup(in_loc, length);
1024 if (in_loc % length) 1030 ret = iio_buffer_add_demux(buffer, &p, in_loc, out_loc, length);
1025 in_loc += length - in_loc % length; 1031 if (ret)
1026 p->from = in_loc; 1032 goto error_clear_mux_table;
1027 p->to = out_loc;
1028 p->length = length;
1029 list_add_tail(&p->l, &buffer->demux_list);
1030 out_loc += length; 1033 out_loc += length;
1031 in_loc += length; 1034 in_loc += length;
1032 } 1035 }