[PATCH] nouveau/nvkm/subdev/clk/gk20a.c: fix wrong do_div() usage
Thierry Reding
thierry.reding at gmail.com
Fri Dec 4 09:38:01 PST 2015
On Tue, Nov 03, 2015 at 05:01:46PM -0500, Nicolas Pitre wrote:
> do_div() must only be used with a u64 dividend.
>
> Signed-off-by: Nicolas Pitre <nico at linaro.org>
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c
> index 254094ab7f..5da2aa8cc3 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c
> @@ -141,9 +141,8 @@ gk20a_pllg_calc_rate(struct gk20a_clk *clk)
>
> rate = clk->parent_rate * clk->n;
> divider = clk->m * pl_to_div[clk->pl];
> - do_div(rate, divider);
>
> - return rate / 2;
> + return rate / divider / 2;
> }
>
> static int
This causes build breakage on 32-bit ARM. I'm also confused by the
commit message because the code that I'm looking at has u64 rate and u32
divider, which matches the types given in include/asm-generic/div64.h:
* The semantics of do_div() are:
*
* uint32_t do_div(uint64_t *n, uint32_t base)
* {
* uint32_t remainder = *n % base;
* *n = *n / base;
* return remainder;
* }
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/dri-devel/attachments/20151204/f67eefbf/attachment.sig>
More information about the dri-devel
mailing list