Linux IIO development
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Muhammad Usama Anjum <usama.anjum@collabora.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Mihail Chindris <mihail.chindris@analog.com>,
	"open list:IIO SUBSYSTEM AND DRIVERS" <linux-iio@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	Collabora Kernel ML <kernel@collabora.com>,
	kernel-janitors <kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] drivers:iio:dac make expression evaluation 64-bit
Date: Thu, 23 Dec 2021 17:38:19 +0100	[thread overview]
Message-ID: <16f84d86-4135-8a19-c5e1-3fbe8db78947@metafoo.de> (raw)
In-Reply-To: <eb59f405-24c6-69b8-beb1-465bfb783f61@collabora.com>

On 12/23/21 5:34 PM, Muhammad Usama Anjum wrote:
> On 12/22/21 11:49 PM, Andy Shevchenko wrote:
>> On Wed, Dec 22, 2021 at 5:59 PM Muhammad Usama Anjum
>> <usama.anjum@collabora.com> wrote:
>>> Two 32-bit values are being evaluated using 32-bit arithmetic and then
>>> passed to s64 type. It is wrong. Expression should be evaluated using
>>> 64-bit arithmetic and then passed.
>> ...
>>
>>>          dac->ch_data[ch].scale_dec = DIV_ROUND_CLOSEST((s64)rem * 1000000,
>>>                                                          65536);
>> Shouldn't the above be fixed as well? Has anybody tried to compile on
>> 32-bit arch this?
> No, it correct already. In this case, rem is being typecasted to s64 and
> then multiplied with a 32-bit number, 1000000. Thus 64-bit arithmetic is
> being performed here.

What Andy means is that this needs to be DIV_S64_ROUND_CLOSEST() to work 
on 32-bit platforms. But it is clearly unrelated to your change and 
should be in its own patch.


  reply	other threads:[~2021-12-23 16:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-21 19:20 [PATCH] drivers:iio:dac make expression evaluation 64-bit Muhammad Usama Anjum
2021-12-22 18:49 ` Andy Shevchenko
2021-12-23 16:34   ` Muhammad Usama Anjum
2021-12-23 16:38     ` Lars-Peter Clausen [this message]
2022-01-04 10:28       ` Chindris, Mihail
2022-01-05 13:39 ` Dan Carpenter
2022-01-05 15:36   ` Sa, Nuno

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=16f84d86-4135-8a19-c5e1-3fbe8db78947@metafoo.de \
    --to=lars@metafoo.de \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=jic23@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kernel@collabora.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mihail.chindris@analog.com \
    --cc=usama.anjum@collabora.com \
    /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