~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise-security

« back to all changes in this revision

Viewing changes to drivers/char/hw_random/n2-drv.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2011-12-06 15:56:07 UTC
  • Revision ID: package-import@ubuntu.com-20111206155607-pcf44kv5fmhk564f
Tags: 3.2.0-1401.1
[ Paolo Pisati ]

* Rebased on top of Ubuntu-3.2.0-3.8
* Tilt-tracking @ ef2487af4bb15bdd0689631774b5a5e3a59f74e2
* Delete debian.ti-omap4/control, it shoudln't be tracked
* Fix architecture spelling (s/armel/armhf/)
* [Config] Update configs following 3.2 import
* [Config] Fix compilation: disable CODA and ARCH_OMAP3
* [Config] Fix compilation: disable Ethernet Faraday
* Update series to precise

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* n2-drv.c: Niagara-2 RNG driver.
2
2
 *
3
 
 * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
 
3
 * Copyright (C) 2008, 2011 David S. Miller <davem@davemloft.net>
4
4
 */
5
5
 
6
6
#include <linux/kernel.h>
22
22
 
23
23
#define DRV_MODULE_NAME         "n2rng"
24
24
#define PFX DRV_MODULE_NAME     ": "
25
 
#define DRV_MODULE_VERSION      "0.1"
26
 
#define DRV_MODULE_RELDATE      "May 15, 2008"
 
25
#define DRV_MODULE_VERSION      "0.2"
 
26
#define DRV_MODULE_RELDATE      "July 27, 2011"
27
27
 
28
28
static char version[] __devinitdata =
29
29
        DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
623
623
static int __devinit n2rng_probe(struct platform_device *op)
624
624
{
625
625
        const struct of_device_id *match;
626
 
        int victoria_falls;
 
626
        int multi_capable;
627
627
        int err = -ENOMEM;
628
628
        struct n2rng *np;
629
629
 
630
630
        match = of_match_device(n2rng_match, &op->dev);
631
631
        if (!match)
632
632
                return -EINVAL;
633
 
        victoria_falls = (match->data != NULL);
 
633
        multi_capable = (match->data != NULL);
634
634
 
635
635
        n2rng_driver_version();
636
636
        np = kzalloc(sizeof(*np), GFP_KERNEL);
640
640
 
641
641
        INIT_DELAYED_WORK(&np->work, n2rng_work);
642
642
 
643
 
        if (victoria_falls)
644
 
                np->flags |= N2RNG_FLAG_VF;
 
643
        if (multi_capable)
 
644
                np->flags |= N2RNG_FLAG_MULTI;
645
645
 
646
646
        err = -ENODEV;
647
647
        np->hvapi_major = 2;
658
658
                }
659
659
        }
660
660
 
661
 
        if (np->flags & N2RNG_FLAG_VF) {
 
661
        if (np->flags & N2RNG_FLAG_MULTI) {
662
662
                if (np->hvapi_major < 2) {
663
 
                        dev_err(&op->dev, "VF RNG requires HVAPI major "
664
 
                                "version 2 or later, got %lu\n",
 
663
                        dev_err(&op->dev, "multi-unit-capable RNG requires "
 
664
                                "HVAPI major version 2 or later, got %lu\n",
665
665
                                np->hvapi_major);
666
666
                        goto out_hvapi_unregister;
667
667
                }
688
688
                goto out_free_units;
689
689
 
690
690
        dev_info(&op->dev, "Found %s RNG, units: %d\n",
691
 
                 ((np->flags & N2RNG_FLAG_VF) ?
692
 
                  "Victoria Falls" : "Niagara2"),
 
691
                 ((np->flags & N2RNG_FLAG_MULTI) ?
 
692
                  "multi-unit-capable" : "single-unit"),
693
693
                 np->num_units);
694
694
 
695
695
        np->hwrng.name = "n2rng";
751
751
                .compatible     = "SUNW,vf-rng",
752
752
                .data           = (void *) 1,
753
753
        },
 
754
        {
 
755
                .name           = "random-number-generator",
 
756
                .compatible     = "SUNW,kt-rng",
 
757
                .data           = (void *) 1,
 
758
        },
754
759
        {},
755
760
};
756
761
MODULE_DEVICE_TABLE(of, n2rng_match);