iio: st_sensors: Fix buffer copy
authorRobin van der Gracht <robin@protonic.nl>
Mon, 29 Sep 2014 13:00:07 +0000 (15:00 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Nov 2014 17:00:01 +0000 (09:00 -0800)
commit 4250c90b30b8bf2a1a21122ba0484f8f351f152d upstream.

Use byte_for_channel as iterator to properly initialize the buffer.

Signed-off-by: Robin van der Gracht <robin@protonic.nl>
Acked-by: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/common/st_sensors/st_sensors_buffer.c

index 1665c8e..e18bc67 100644 (file)
@@ -71,7 +71,7 @@ int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf)
                                goto st_sensors_free_memory;
                        }
 
-                       for (i = 0; i < n * num_data_channels; i++) {
+                       for (i = 0; i < n * byte_for_channel; i++) {
                                if (i < n)
                                        buf[i] = rx_array[i];
                                else