[PATCH] (4/4) use system get_random_bytes in hdlcdrv

From: Stephen Hemminger (terhi.victor@logonet.com)
Date: Fri Sep 19 2003 - 23:38:09 EEST

  • Next message: Andi Kleen: "Re: [PATCH] (4/4) use system get_random_bytes in hdlcdrv"

    Real random numbers aren't important here, but having custom
    random number generate seems silly when linux kernel has good
    way to get random data.

    diff -Nru a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
    --- a/drivers/net/hamradio/hdlcdrv.c Fri Sep 19 13:18:58 2003
    +++ b/drivers/net/hamradio/hdlcdrv.c Fri Sep 19 13:18:58 2003
    @@ -52,6 +52,7 @@
     #include <linux/slab.h>
     #include <linux/errno.h>
     #include <linux/init.h>
    +#include <linux/random.h>
     #include <asm/bitops.h>
     #include <asm/uaccess.h>
     
    @@ -434,18 +435,10 @@
     
     /* ---------------------------------------------------------------------- */
     
    -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)
     {
    + u8 prand;
    +
             if (!s || s->magic != HDLCDRV_MAGIC || s->hdlctx.ptt || !s->skb)
                     return;
             if (s->ch_params.fulldup) {
    @@ -459,7 +452,9 @@
             if ((--s->hdlctx.slotcnt) > 0)
                     return;
             s->hdlctx.slotcnt = s->ch_params.slottime;
    - if ((random_num() % 256) > s->ch_params.ppersist)
    +
    + get_random_bytes(&prand, sizeof(prand));
    + if (prand > s->ch_params.ppersist)
                     return;
             start_tx(dev, s);
     }
    -
    To unsubscribe from this list: send the line "unsubscribe linux-hams" in
    the body of a message to bencekg@roskapostia.tunk.net
    More majordomo info at http://vger.kernel.org/majordomo-info.html



    This archive was generated by hypermail 2b30 : Fri Sep 19 2003 - 23:39:07 EEST