mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Eva Rachel Retuya <eraretuya@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-iio@vger.kernel.org
Cc: Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	linux-kernel@vger.kernel.org, abhiram@cs.utah.edu
Subject: Re: [PATCH] staging: iio: tsl2x7x_core: Fix standard deviation calculation
Date: Sat, 25 Mar 2017 16:48:10 +0000	[thread overview]
Message-ID: <93c079ae-26f2-5d99-36a3-8d8cffbd99ef@kernel.org> (raw)
In-Reply-To: <1490009225-10268-1-git-send-email-eraretuya@gmail.com>

On 20/03/17 11:27, Eva Rachel Retuya wrote:
> 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>
I've applied this to the togreg branch of iio.git rather than sending
as a quick fix for the simple reason that nothing currently uses the
value once it has been computed that I can immediately see!

That whole chunk of code probably just wants to be ripped out in
the longer term.

Jonathan
> ---
>  drivers/staging/iio/light/tsl2x7x_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c
> index ea15bc1..197201a 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);
>  }
>  
>  /**
> 

      reply	other threads:[~2017-03-25 16:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-20 11:27 Eva Rachel Retuya
2017-03-25 16:48 ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=93c079ae-26f2-5d99-36a3-8d8cffbd99ef@kernel.org \
    --to=jic23@kernel.org \
    --cc=abhiram@cs.utah.edu \
    --cc=eraretuya@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®