Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1578421

Re: [PATCH v1] platform/x86: intel_pmc_ipc: fix division in 32-bit case

From Andy Shevchenko <andy.shevchenko@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v1] platform/x86: intel_pmc_ipc: fix division in 32-bit case
Date 2017-02-10 13:10 +0100
Message-ID <t9ibx-3dS-45@gated-at.bofh.it> (permalink)
References <t8CYF-2tE-23@gated-at.bofh.it> <t9b0l-71o-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Feb 10, 2017 at 6:24 AM, Rajneesh Bhardwaj
<rajneesh.bhardwaj@intel.com> wrote:
> On Wed, Feb 08, 2017 at 06:00:28PM +0200, Andy Shevchenko wrote:
>> On 32-bit x86 platforms we can't do 64-bit divisions:
>>
>>       ERROR: "__udivdi3" [drivers/platform/x86/intel_pmc_ipc.ko] undefined!
>>
>> Replace plain division by do_div() macro call.
>>
>> Reported-by: Darren Hart <dvhart@infradead.org>
>> Cc: Shanth Murthy <shanth.murthy@intel.com>
>> Cc: Rajneesh Bhardwaj <rajneesh.bhardwaj@intel.com>
>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> ---
>>  drivers/platform/x86/intel_pmc_ipc.c | 7 ++++++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
>> index 46202b6e7c87..8ad4d7b43423 100644
>> --- a/drivers/platform/x86/intel_pmc_ipc.c
>> +++ b/drivers/platform/x86/intel_pmc_ipc.c
>> @@ -62,7 +62,12 @@
>>  #define GCR_TELEM_SHLW_S0IX_OFFSET   0x1080
>>
>>  /* Residency with clock rate at 19.2MHz to usecs */
>> -#define S0IX_RESIDENCY_IN_USECS(d, s)                (((d) + (s)) * 10 / 192)
>> +#define S0IX_RESIDENCY_IN_USECS(d, s)                \
>> +({                                           \
>> +     u64 result = 10ull * ((d) + (s));       \
>> +     do_div(result, 192);                    \
>> +     result;                                 \
>> +})
>>
>
> Looks good, we verified it. We are planning to squash this one and send V2.
> Hope thats fine?

Please, do!

-- 
With Best Regards,
Andy Shevchenko

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v1] platform/x86: intel_pmc_ipc: fix division in 32-bit case Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-02-08 17:10 +0100
  Re: [PATCH v1] platform/x86: intel_pmc_ipc: fix division in 32-bit  case Rajneesh Bhardwaj <rajneesh.bhardwaj@intel.com> - 2017-02-10 05:30 +0100
    Re: [PATCH v1] platform/x86: intel_pmc_ipc: fix division in 32-bit case Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-02-10 13:10 +0100

csiph-web