Re: [patch 3/6] New Generic HW RNG (#2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 07, 2006 at 04:38:09PM +0200, Michael Buesch wrote:
> Add a driver for the x86 RNG.
> This driver is ported from the old hw_random.c
> 
[skip]
> +static int __init intel_init(struct hwrng *rng)

Cannot be __init anymore - now rng->init could be called at any time.

Also, there is another problem with putting this function into
rng->init - if another RNG has been registered when this module is
loaded, ->init will not be called during hwrng_register(), so the
module load will succeed even if the chipset does not have RNG
hardware.

> +{
> +	void __iomem *rng_mem;
> +	int rc;
> +	u8 hw_status;
> +
> +	DPRINTK ("ENTER\n");
> +
> +	rng_mem = ioremap (INTEL_RNG_ADDR, INTEL_RNG_ADDR_LEN);
> +	if (rng_mem == NULL) {
> +		printk (KERN_ERR PFX "cannot ioremap RNG Memory\n");
> +		rc = -EBUSY;
> +		goto err_out;
> +	}
> +	rng->priv = (unsigned long)rng_mem;
> +
> +	/* Check for Intel 82802 */
> +	hw_status = intel_hwstatus (rng_mem);
> +	if ((hw_status & INTEL_RNG_PRESENT) == 0) {
> +		printk (KERN_ERR PFX "RNG not detected\n");
> +		rc = -ENODEV;
> +		goto err_out_free_map;
> +	}
> +
> +	/* turn RNG h/w on, if it's off */
> +	if ((hw_status & INTEL_RNG_ENABLED) == 0)
> +		hw_status = intel_hwstatus_set (rng_mem, hw_status | INTEL_RNG_ENABLED);
> +	if ((hw_status & INTEL_RNG_ENABLED) == 0) {
> +		printk (KERN_ERR PFX "cannot enable RNG, aborting\n");
> +		rc = -EIO;
> +		goto err_out_free_map;
> +	}
> +
> +	DPRINTK ("EXIT, returning 0\n");
> +	return 0;
> +
> +err_out_free_map:
> +	iounmap (rng_mem);
> +err_out:
> +	DPRINTK ("EXIT, returning %d\n", rc);
> +	return rc;
> +}
> +
[skip]
> +static int __init amd_init(struct hwrng *rng)

Again, __init is wrong.

[skip]
> +static int __init via_init(struct hwrng *rng)

This __init is wrong too.

[skip]

Attachment: pgpeSNhQjI47O.pgp
Description: PGP signature


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux