drm/nouveau/volt: use kernel's 64-bit signed division function
authorAlexandre Courbot <acourbot@nvidia.com>
Fri, 16 Sep 2016 09:09:12 +0000 (18:09 +0900)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 12 Oct 2016 07:29:30 +0000 (17:29 +1000)
Doing direct 64 bit divisions in kernel code leads to references to
undefined symbols on 32 bit architectures. Replace such divisions with
calls to div64_s64 to make the module usable on 32 bit archs.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Karol Herbst <karolherbst@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nvkm/subdev/volt/base.c

index 90d234231eedeac26c7044cddbd32ffe91cf0ef7..e8569b04b55df316c3f1df9778aec4e37d089e96 100644 (file)
@@ -116,9 +116,9 @@ nvkm_volt_map(struct nvkm_volt *volt, u8 id, u8 temp)
                        return volt->speedo;
 
                if (ver == 0x10 || (ver == 0x20 && info.mode == 0)) {
-                       result  =  (s64)info.arg[0] / 10;
-                       result += ((s64)info.arg[1] * volt->speedo) / 10;
-                       result += ((s64)info.arg[2] * volt->speedo * volt->speedo) / 100000;
+                       result  = div64_s64((s64)info.arg[0], 10);
+                       result += div64_s64((s64)info.arg[1] * volt->speedo, 10);
+                       result += div64_s64((s64)info.arg[2] * volt->speedo * volt->speedo, 100000);
                } else if (ver == 0x20) {
                        switch (info.mode) {
                        /* 0x0 handled above! */