* [HAMRADIO] Replace local random function with random32()
@ 2007-02-16 11:55 Ralf Baechle
2007-02-16 12:28 ` Thomas Sailer
2007-02-20 16:18 ` Jeff Garzik
0 siblings, 2 replies; 3+ messages in thread
From: Ralf Baechle @ 2007-02-16 11:55 UTC (permalink / raw)
To: Jeff Garzik, David S. Miller; +Cc: Joe Perches, netdev, linux-hams
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index 153b6dc..84aa211 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -52,6 +52,7 @@
#include <linux/hdlcdrv.h>
#include <linux/baycom.h>
#include <linux/jiffies.h>
+#include <linux/random.h>
#include <net/ax25.h>
#include <asm/uaccess.h>
@@ -433,16 +434,6 @@ static void encode_hdlc(struct baycom_state *bc)
/* ---------------------------------------------------------------------- */
-static unsigned short random_seed;
-
-static inline unsigned short random_num(void)
-{
- random_seed = 28629 * random_seed + 157;
- return random_seed;
-}
-
-/* ---------------------------------------------------------------------- */
-
static int transmit(struct baycom_state *bc, int cnt, unsigned char stat)
{
struct parport *pp = bc->pdev->port;
@@ -464,7 +455,7 @@ static int transmit(struct baycom_state *bc, int cnt, unsigned char stat)
if ((--bc->hdlctx.slotcnt) > 0)
return 0;
bc->hdlctx.slotcnt = bc->ch_params.slottime;
- if ((random_num() % 256) > bc->ch_params.ppersist)
+ if ((random32() % 256) > bc->ch_params.ppersist)
return 0;
}
}
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index 452873e..f5a17ad 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -56,6 +56,7 @@
#include <linux/if_arp.h>
#include <linux/skbuff.h>
#include <linux/hdlcdrv.h>
+#include <linux/random.h>
#include <net/ax25.h>
#include <asm/uaccess.h>
@@ -371,16 +372,6 @@ static void start_tx(struct net_device *dev, struct hdlcdrv_state *s)
/* ---------------------------------------------------------------------- */
-static unsigned short random_seed;
-
-static inline unsigned short random_num(void)
-{
- random_seed = 28629 * random_seed + 157;
- return random_seed;
-}
-
-/* ---------------------------------------------------------------------- */
-
void hdlcdrv_arbitrate(struct net_device *dev, struct hdlcdrv_state *s)
{
if (!s || s->magic != HDLCDRV_MAGIC || s->hdlctx.ptt || !s->skb)
@@ -396,7 +387,7 @@ void hdlcdrv_arbitrate(struct net_device *dev, struct hdlcdrv_state *s)
if ((--s->hdlctx.slotcnt) > 0)
return;
s->hdlctx.slotcnt = s->ch_params.slottime;
- if ((random_num() % 256) > s->ch_params.ppersist)
+ if ((random32() % 256) > s->ch_params.ppersist)
return;
start_tx(dev, s);
}
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 6d74f08..efc0bcd 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -50,6 +50,7 @@
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/bitops.h>
+#include <linux/random.h>
#include <asm/io.h>
#include <asm/system.h>
#include <linux/interrupt.h>
@@ -566,14 +567,6 @@ static void yam_start_tx(struct net_device *dev, struct yam_port *yp)
ptt_on(dev);
}
-static unsigned short random_seed;
-
-static inline unsigned short random_num(void)
-{
- random_seed = 28629 * random_seed + 157;
- return random_seed;
-}
-
static void yam_arbitrate(struct net_device *dev)
{
struct yam_port *yp = netdev_priv(dev);
@@ -600,7 +593,7 @@ static void yam_arbitrate(struct net_device *dev)
yp->slotcnt = yp->slot / 10;
/* is random > persist ? */
- if ((random_num() % 256) > yp->pers)
+ if ((random32() % 256) > yp->pers)
return;
yam_start_tx(dev, yp);
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [HAMRADIO] Replace local random function with random32()
2007-02-16 11:55 [HAMRADIO] Replace local random function with random32() Ralf Baechle
@ 2007-02-16 12:28 ` Thomas Sailer
2007-02-20 16:18 ` Jeff Garzik
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Sailer @ 2007-02-16 12:28 UTC (permalink / raw)
To: Ralf Baechle
Cc: Jeff Garzik, David S. Miller, Joe Perches, netdev, linux-hams
On Fri, 2007-02-16 at 11:55 +0000, Ralf Baechle wrote:
> Signed-off-by: Joe Perches <joe@perches.com>
> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Acked-by: Thomas Sailer <t.sailer@alumni.ethz.ch>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [HAMRADIO] Replace local random function with random32()
2007-02-16 11:55 [HAMRADIO] Replace local random function with random32() Ralf Baechle
2007-02-16 12:28 ` Thomas Sailer
@ 2007-02-20 16:18 ` Jeff Garzik
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Garzik @ 2007-02-20 16:18 UTC (permalink / raw)
To: Ralf Baechle; +Cc: David S. Miller, Joe Perches, netdev, linux-hams
Ralf Baechle wrote:
> Signed-off-by: Joe Perches <joe@perches.com>
> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
applied
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-02-20 16:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-16 11:55 [HAMRADIO] Replace local random function with random32() Ralf Baechle
2007-02-16 12:28 ` Thomas Sailer
2007-02-20 16:18 ` Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).