Merge branch 'fixes' of git://ftp.arm.linux.org.uk/~rmk/linux-arm

Pull ARM fixes from Russell King:
 "A couple of ARM fixes from Linus for the ICST clock generator code"

[ "Linus" here is Linus Walleij.  Name-stealer.

       Linus "there can be only one" Torvalds ]

* 'fixes' of git://ftp.arm.linux.org.uk/~rmk/linux-arm:
  ARM: 8519/1: ICST: try other dividends than 1
  ARM: 8517/1: ICST: avoid arithmetic overflow in icst_hz()
This commit is contained in:
Linus Torvalds 2016-02-14 10:46:47 -08:00
commit be3f4e0fb3
1 changed files with 7 additions and 2 deletions

View File

@ -16,7 +16,7 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <asm/div64.h>
#include <asm/hardware/icst.h> #include <asm/hardware/icst.h>
/* /*
@ -29,7 +29,11 @@ EXPORT_SYMBOL(icst525_s2div);
unsigned long icst_hz(const struct icst_params *p, struct icst_vco vco) unsigned long icst_hz(const struct icst_params *p, struct icst_vco vco)
{ {
return p->ref * 2 * (vco.v + 8) / ((vco.r + 2) * p->s2div[vco.s]); u64 dividend = p->ref * 2 * (u64)(vco.v + 8);
u32 divisor = (vco.r + 2) * p->s2div[vco.s];
do_div(dividend, divisor);
return (unsigned long)dividend;
} }
EXPORT_SYMBOL(icst_hz); EXPORT_SYMBOL(icst_hz);
@ -58,6 +62,7 @@ icst_hz_to_vco(const struct icst_params *p, unsigned long freq)
if (f > p->vco_min && f <= p->vco_max) if (f > p->vco_min && f <= p->vco_max)
break; break;
i++;
} while (i < 8); } while (i < 8);
if (i >= 8) if (i >= 8)