All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] p54: Use do_div for 64-bit division to fix 32-bit kernels
@ 2011-08-25 21:47 Christian Lamparter
  2011-09-07  4:27 ` Calvin Walton
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Lamparter @ 2011-08-25 21:47 UTC (permalink / raw)
  To: linux-wireless; +Cc: linville

Use the do_div macro for 64-bit division. Otherwise, the module will
reference __udivdi3 under 32-bit kernels, which is not allowed in
kernel space.

Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
---
diff --git a/drivers/net/wireless/p54/txrx.c b/drivers/net/wireless/p54/txrx.c
index 44a3bd4..9865881 100644
--- a/drivers/net/wireless/p54/txrx.c
+++ b/drivers/net/wireless/p54/txrx.c
@@ -19,6 +19,7 @@
 #include <linux/init.h>
 #include <linux/firmware.h>
 #include <linux/etherdevice.h>
+#include <asm/div64.h>
 
 #include <net/mac80211.h>
 
@@ -582,10 +583,13 @@ static void p54_rx_stats(struct p54_common *priv, struct sk_buff *skb)
 	if (chan) {
 		struct survey_info *survey = &priv->survey[chan->hw_value];
 		survey->noise = clamp_t(s8, priv->noise, -128, 127);
-		survey->channel_time = priv->survey_raw.active / 1024;
-		survey->channel_time_tx = priv->survey_raw.tx / 1024;
-		survey->channel_time_busy = priv->survey_raw.cca / 1024 +
-			survey->channel_time_tx;
+		survey->channel_time = priv->survey_raw.active;
+		survey->channel_time_tx = priv->survey_raw.tx;
+		survey->channel_time_busy = priv->survey_raw.tx +
+			priv->survey_raw.cca;
+		do_div(survey->channel_time, 1024);
+		do_div(survey->channel_time_tx, 1024);
+		do_div(survey->channel_time_busy, 1024);
 	}
 
 	tmp = p54_find_and_unlink_skb(priv, hdr->req_id);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] p54: Use do_div for 64-bit division to fix 32-bit kernels
  2011-08-25 21:47 [PATCH] p54: Use do_div for 64-bit division to fix 32-bit kernels Christian Lamparter
@ 2011-09-07  4:27 ` Calvin Walton
  0 siblings, 0 replies; 2+ messages in thread
From: Calvin Walton @ 2011-09-07  4:27 UTC (permalink / raw)
  To: Christian Lamparter; +Cc: linux-wireless, linville

On Thu, 2011-08-25 at 23:47 +0200, Christian Lamparter wrote:
> Use the do_div macro for 64-bit division. Otherwise, the module will
> reference __udivdi3 under 32-bit kernels, which is not allowed in
> kernel space.
> 
> Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
> ---
> diff --git a/drivers/net/wireless/p54/txrx.c b/drivers/net/wireless/p54/txrx.c

> +		do_div(survey->channel_time, 1024);
> +		do_div(survey->channel_time_tx, 1024);
> +		do_div(survey->channel_time_busy, 1024);

You're doing a division by a power of two here, why not just use a
bit-shift operation ">> 10" instead of a full division operation?

-- 
Calvin Walton <calvin.walton@kepstin.ca>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-07  4:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-25 21:47 [PATCH] p54: Use do_div for 64-bit division to fix 32-bit kernels Christian Lamparter
2011-09-07  4:27 ` Calvin Walton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.