summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJohan Hovold <johan@hovoldconsulting.com>2015-04-16 09:53:59 +0200
committerGreg Kroah-Hartman <gregkh@google.com>2015-04-16 10:26:33 +0200
commit1ffc12be5549085faac2d6116f666cb9cbcb2930 (patch)
tree1f63afbd377d2e7c6255806c0cdd0110de2ef090 /drivers
parentdcd1dadd7ee32b3fd135904fac85c556bac5cbc5 (diff)
downloadlinux-1ffc12be5549085faac2d6116f666cb9cbcb2930.tar.bz2
greybus: loopback: fix 64-bit divisions
The code uses 64-bit divisions, which should be avoided, and also prevents the module from loading on 32-bit systems: gb_loopback: Unknown symbol __aeabi_uldivmod (err 0) Fix by using the kernel's 64-bit by 32-bit division implementation do_div. Compile tested only. I did not look very closely at the code itself. Perhaps this could be worked around in some other way, but this silences the linker warning and allows the module to be loaded. Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/greybus/loopback.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
index 9914b52c71ce..9860d64e50ba 100644
--- a/drivers/staging/greybus/loopback.c
+++ b/drivers/staging/greybus/loopback.c
@@ -13,6 +13,8 @@
#include <linux/delay.h>
#include <linux/random.h>
#include <linux/sizes.h>
+#include <asm/div64.h>
+
#include "greybus.h"
struct gb_loopback_stats {
@@ -248,12 +250,16 @@ static void gb_loopback_update_stats(struct gb_loopback_stats *stats,
u64 elapsed_nsecs)
{
u32 avg;
+ u64 tmp;
if (elapsed_nsecs >= NSEC_PER_SEC) {
- if (!stats->count)
- avg = stats->sum * (elapsed_nsecs / NSEC_PER_SEC);
- else
+ if (!stats->count) {
+ tmp = elapsed_nsecs;
+ do_div(tmp, NSEC_PER_SEC);
+ avg = stats->sum * tmp;
+ } else {
avg = stats->sum / stats->count;
+ }
if (stats->min > avg)
stats->min = avg;
if (stats->max < avg)
@@ -281,10 +287,11 @@ static void gb_loopback_latency_update(struct gb_loopback *gb,
struct timeval *tlat)
{
u32 lat;
- u64 nsecs;
+ u64 tmp;
- nsecs = timeval_to_ns(tlat);
- lat = nsecs / NSEC_PER_MSEC;
+ tmp = timeval_to_ns(tlat);
+ do_div(tmp, NSEC_PER_MSEC);
+ lat = tmp;
if (gb->latency.min > lat)
gb->latency.min = lat;