From: Eva Rachel Retuya Date: Mon, 20 Mar 2017 11:27:05 +0000 (+0800) Subject: staging: iio: tsl2x7x_core: Fix standard deviation calculation X-Git-Tag: v4.12-rc1~84^2~283^2~32 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=cf6c77323a96fc40309cc8a4921ef206cccdd961;p=karo-tx-linux.git staging: iio: tsl2x7x_core: Fix standard deviation calculation 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 Signed-off-by: Eva Rachel Retuya Signed-off-by: Jonathan Cameron --- diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c index ea15bc1c300c..197201a70d59 100644 --- a/drivers/staging/iio/light/tsl2x7x_core.c +++ b/drivers/staging/iio/light/tsl2x7x_core.c @@ -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); } /**