staging: iio: tsl2x7x_core: Fix standard deviation calculation
authorEva Rachel Retuya <eraretuya@gmail.com>
Mon, 20 Mar 2017 11:27:05 +0000 (19:27 +0800)
committerJonathan Cameron <jic23@kernel.org>
Sat, 25 Mar 2017 16:47:13 +0000 (16:47 +0000)
Standard deviation is calculated as the square root of the variance
where variance is the mean of sample_sum and length. Correct the
computation of statP->stddev in accordance to the proper calculation.

Fixes: 3c97c08b5735 ("staging: iio: add TAOS tsl2x7x driver")
Reported-by: Abhiram Balasubramanian <abhiram@cs.utah.edu>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/light/tsl2x7x_core.c

index ea15bc1..197201a 100644 (file)
@@ -854,7 +854,7 @@ void tsl2x7x_prox_calculate(int *data, int length,
                tmp = data[i] - statP->mean;
                sample_sum += tmp * tmp;
        }
-       statP->stddev = int_sqrt((long)sample_sum) / length;
+       statP->stddev = int_sqrt((long)sample_sum / length);
 }
 
 /**