hwrng: pseries - Use KBUILD_MODNAME in pseries-rng.c
[deliverable/linux.git] / drivers / char / hw_random / pseries-rng.c
CommitLineData
649e9ea0
KY
1/*
2 * Copyright (C) 2010 Michael Neuling IBM Corporation
3 *
4 * Driver for the pseries hardware RNG for POWER7+ and above
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/module.h>
21#include <linux/hw_random.h>
22#include <asm/vio.h>
23
649e9ea0
KY
24
25static int pseries_rng_data_read(struct hwrng *rng, u32 *data)
26{
27 if (plpar_hcall(H_RANDOM, (unsigned long *)data) != H_SUCCESS) {
28 printk(KERN_ERR "pseries rng hcall error\n");
29 return 0;
30 }
31 return 8;
32}
33
34/**
35 * pseries_rng_get_desired_dma - Return desired DMA allocate for CMO operations
36 *
37 * This is a required function for a driver to operate in a CMO environment
38 * but this device does not make use of DMA allocations, return 0.
39 *
40 * Return value:
41 * Number of bytes of IO data the driver will need to perform well -> 0
42 */
43static unsigned long pseries_rng_get_desired_dma(struct vio_dev *vdev)
44{
45 return 0;
46};
47
48static struct hwrng pseries_rng = {
49cca7e0 49 .name = KBUILD_MODNAME,
649e9ea0
KY
50 .data_read = pseries_rng_data_read,
51};
52
53static int __init pseries_rng_probe(struct vio_dev *dev,
54 const struct vio_device_id *id)
55{
56 return hwrng_register(&pseries_rng);
57}
58
59static int __exit pseries_rng_remove(struct vio_dev *dev)
60{
61 hwrng_unregister(&pseries_rng);
62 return 0;
63}
64
65static struct vio_device_id pseries_rng_driver_ids[] = {
66 { "ibm,random-v1", "ibm,random"},
67 { "", "" }
68};
69MODULE_DEVICE_TABLE(vio, pseries_rng_driver_ids);
70
71static struct vio_driver pseries_rng_driver = {
49cca7e0 72 .name = KBUILD_MODNAME,
649e9ea0
KY
73 .probe = pseries_rng_probe,
74 .remove = pseries_rng_remove,
75 .get_desired_dma = pseries_rng_get_desired_dma,
76 .id_table = pseries_rng_driver_ids
77};
78
79static int __init rng_init(void)
80{
81 printk(KERN_INFO "Registering IBM pSeries RNG driver\n");
82 return vio_register_driver(&pseries_rng_driver);
83}
84
85module_init(rng_init);
86
87static void __exit rng_exit(void)
88{
89 vio_unregister_driver(&pseries_rng_driver);
90}
91module_exit(rng_exit);
92
93MODULE_LICENSE("GPL");
94MODULE_AUTHOR("Michael Neuling <mikey@neuling.org>");
95MODULE_DESCRIPTION("H/W RNG driver for IBM pSeries processors");
This page took 0.114697 seconds and 5 git commands to generate.