Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <abhiram@cs.utah.edu>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Eva Rachel Retuya and committed by
Jonathan Cameron
cf6c7732 d7ed89d5

+1 -1
+1 -1
drivers/staging/iio/light/tsl2x7x_core.c
··· 854 854 tmp = data[i] - statP->mean; 855 855 sample_sum += tmp * tmp; 856 856 } 857 - statP->stddev = int_sqrt((long)sample_sum) / length; 857 + statP->stddev = int_sqrt((long)sample_sum / length); 858 858 } 859 859 860 860 /**