All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bmp280: use correct routine for division
@ 2014-10-23 13:08 Vlad Dogaru
  2014-10-23 14:00 ` Daniel Baluta
  0 siblings, 1 reply; 2+ messages in thread
From: Vlad Dogaru @ 2014-10-23 13:08 UTC (permalink / raw)
  To: jic23, linux-iio; +Cc: Vlad Dogaru

The proper way to divide two signed 64-bit values is to use div4_s64.

Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
---
 drivers/iio/pressure/bmp280.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/pressure/bmp280.c b/drivers/iio/pressure/bmp280.c
index fb91cb3..ce29ff9 100644
--- a/drivers/iio/pressure/bmp280.c
+++ b/drivers/iio/pressure/bmp280.c
@@ -239,7 +239,7 @@ static u32 bmp280_compensate_press(struct bmp280_data *data,
 		return 0;
 
 	p = ((((s64) 1048576 - adc_press) << 31) - var2) * 3125;
-	do_div(p, var1);
+	p = div64_s64(p, var1);
 	var1 = (((s64) comp->dig_p9) * (p >> 13) * (p >> 13)) >> 25;
 	var2 = (((s64) comp->dig_p8) * p) >> 19;
 	p = ((p + var1 + var2) >> 8) + (((s64) comp->dig_p7) << 4);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] bmp280: use correct routine for division
  2014-10-23 13:08 [PATCH] bmp280: use correct routine for division Vlad Dogaru
@ 2014-10-23 14:00 ` Daniel Baluta
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Baluta @ 2014-10-23 14:00 UTC (permalink / raw)
  To: Vlad Dogaru; +Cc: Jonathan Cameron, linux-iio

On Thu, Oct 23, 2014 at 4:08 PM, Vlad Dogaru <vlad.dogaru@intel.com> wrote:
> The proper way to divide two signed 64-bit values is to use div4_s64.

s/div4_s64/div64_s64

Otherwise, it looks good to me. Thanks Vlad!

>
> Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
> ---
>  drivers/iio/pressure/bmp280.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/pressure/bmp280.c b/drivers/iio/pressure/bmp280.c
> index fb91cb3..ce29ff9 100644
> --- a/drivers/iio/pressure/bmp280.c
> +++ b/drivers/iio/pressure/bmp280.c
> @@ -239,7 +239,7 @@ static u32 bmp280_compensate_press(struct bmp280_data *data,
>                 return 0;
>
>         p = ((((s64) 1048576 - adc_press) << 31) - var2) * 3125;
> -       do_div(p, var1);
> +       p = div64_s64(p, var1);
>         var1 = (((s64) comp->dig_p9) * (p >> 13) * (p >> 13)) >> 25;
>         var2 = (((s64) comp->dig_p8) * p) >> 19;
>         p = ((p + var1 + var2) >> 8) + (((s64) comp->dig_p7) << 4);
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-10-23 14:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-23 13:08 [PATCH] bmp280: use correct routine for division Vlad Dogaru
2014-10-23 14:00 ` Daniel Baluta

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.