aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-06-17 21:16:55 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-06-17 21:16:55 -0400
commit4b337c5f245b6587ba844ac7bb13c313a2912f7b (patch)
tree999c6a6580b76a083c8efb9dabff709d1c49fcd0 /drivers/char
parent492b057c426e4aa747484958e18e9da29003985d (diff)
parent3fe0344faf7fdcb158bd5c1a9aec960a8d70c8e8 (diff)
Merge commit 'origin/master' into next
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/hvcs.c6
-rw-r--r--drivers/char/hw_random/Kconfig13
-rw-r--r--drivers/char/hw_random/Makefile1
-rw-r--r--drivers/char/hw_random/core.c1
-rw-r--r--drivers/char/hw_random/tx4939-rng.c184
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c4
-rw-r--r--drivers/char/misc.c15
-rw-r--r--drivers/char/raw.c6
-rw-r--r--drivers/char/vt.c13
9 files changed, 229 insertions, 14 deletions
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 2724d628527f..266b858b8f85 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -347,7 +347,7 @@ static void __exit hvcs_module_exit(void);
347 347
348static inline struct hvcs_struct *from_vio_dev(struct vio_dev *viod) 348static inline struct hvcs_struct *from_vio_dev(struct vio_dev *viod)
349{ 349{
350 return viod->dev.driver_data; 350 return dev_get_drvdata(&viod->dev);
351} 351}
352/* The sysfs interface for the driver and devices */ 352/* The sysfs interface for the driver and devices */
353 353
@@ -785,7 +785,7 @@ static int __devinit hvcs_probe(
785 kref_init(&hvcsd->kref); 785 kref_init(&hvcsd->kref);
786 786
787 hvcsd->vdev = dev; 787 hvcsd->vdev = dev;
788 dev->dev.driver_data = hvcsd; 788 dev_set_drvdata(&dev->dev, hvcsd);
789 789
790 hvcsd->index = index; 790 hvcsd->index = index;
791 791
@@ -831,7 +831,7 @@ static int __devinit hvcs_probe(
831 831
832static int __devexit hvcs_remove(struct vio_dev *dev) 832static int __devexit hvcs_remove(struct vio_dev *dev)
833{ 833{
834 struct hvcs_struct *hvcsd = dev->dev.driver_data; 834 struct hvcs_struct *hvcsd = dev_get_drvdata(&dev->dev);
835 unsigned long flags; 835 unsigned long flags;
836 struct tty_struct *tty; 836 struct tty_struct *tty;
837 837
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index f4b3f7293feb..ce66a70184f7 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -149,6 +149,19 @@ config HW_RANDOM_VIRTIO
149 To compile this driver as a module, choose M here: the 149 To compile this driver as a module, choose M here: the
150 module will be called virtio-rng. If unsure, say N. 150 module will be called virtio-rng. If unsure, say N.
151 151
152config HW_RANDOM_TX4939
153 tristate "TX4939 Random Number Generator support"
154 depends on HW_RANDOM && SOC_TX4939
155 default HW_RANDOM
156 ---help---
157 This driver provides kernel-side support for the Random Number
158 Generator hardware found on TX4939 SoC.
159
160 To compile this driver as a module, choose M here: the
161 module will be called tx4939-rng.
162
163 If unsure, say Y.
164
152config HW_RANDOM_MXC_RNGA 165config HW_RANDOM_MXC_RNGA
153 tristate "Freescale i.MX RNGA Random Number Generator" 166 tristate "Freescale i.MX RNGA Random Number Generator"
154 depends on HW_RANDOM && ARCH_HAS_RNGA 167 depends on HW_RANDOM && ARCH_HAS_RNGA
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
index fd1ecd2f6731..676828ba8123 100644
--- a/drivers/char/hw_random/Makefile
+++ b/drivers/char/hw_random/Makefile
@@ -15,4 +15,5 @@ obj-$(CONFIG_HW_RANDOM_IXP4XX) += ixp4xx-rng.o
15obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.o 15obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.o
16obj-$(CONFIG_HW_RANDOM_PASEMI) += pasemi-rng.o 16obj-$(CONFIG_HW_RANDOM_PASEMI) += pasemi-rng.o
17obj-$(CONFIG_HW_RANDOM_VIRTIO) += virtio-rng.o 17obj-$(CONFIG_HW_RANDOM_VIRTIO) += virtio-rng.o
18obj-$(CONFIG_HW_RANDOM_TX4939) += tx4939-rng.o
18obj-$(CONFIG_HW_RANDOM_MXC_RNGA) += mxc-rnga.o 19obj-$(CONFIG_HW_RANDOM_MXC_RNGA) += mxc-rnga.o
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index e5d583c84e4f..fc93e2fc7c71 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -153,6 +153,7 @@ static const struct file_operations rng_chrdev_ops = {
153static struct miscdevice rng_miscdev = { 153static struct miscdevice rng_miscdev = {
154 .minor = RNG_MISCDEV_MINOR, 154 .minor = RNG_MISCDEV_MINOR,
155 .name = RNG_MODULE_NAME, 155 .name = RNG_MODULE_NAME,
156 .devnode = "hwrng",
156 .fops = &rng_chrdev_ops, 157 .fops = &rng_chrdev_ops,
157}; 158};
158 159
diff --git a/drivers/char/hw_random/tx4939-rng.c b/drivers/char/hw_random/tx4939-rng.c
new file mode 100644
index 000000000000..544d9085a8e8
--- /dev/null
+++ b/drivers/char/hw_random/tx4939-rng.c
@@ -0,0 +1,184 @@
1/*
2 * RNG driver for TX4939 Random Number Generators (RNG)
3 *
4 * Copyright (C) 2009 Atsushi Nemoto <anemo@mba.ocn.ne.jp>
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/module.h>
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/delay.h>
14#include <linux/io.h>
15#include <linux/platform_device.h>
16#include <linux/hw_random.h>
17
18#define TX4939_RNG_RCSR 0x00000000
19#define TX4939_RNG_ROR(n) (0x00000018 + (n) * 8)
20
21#define TX4939_RNG_RCSR_INTE 0x00000008
22#define TX4939_RNG_RCSR_RST 0x00000004
23#define TX4939_RNG_RCSR_FIN 0x00000002
24#define TX4939_RNG_RCSR_ST 0x00000001
25
26struct tx4939_rng {
27 struct hwrng rng;
28 void __iomem *base;
29 u64 databuf[3];
30 unsigned int data_avail;
31};
32
33static void rng_io_start(void)
34{
35#ifndef CONFIG_64BIT
36 /*
37 * readq is reading a 64-bit register using a 64-bit load. On
38 * a 32-bit kernel however interrupts or any other processor
39 * exception would clobber the upper 32-bit of the processor
40 * register so interrupts need to be disabled.
41 */
42 local_irq_disable();
43#endif
44}
45
46static void rng_io_end(void)
47{
48#ifndef CONFIG_64BIT
49 local_irq_enable();
50#endif
51}
52
53static u64 read_rng(void __iomem *base, unsigned int offset)
54{
55 return ____raw_readq(base + offset);
56}
57
58static void write_rng(u64 val, void __iomem *base, unsigned int offset)
59{
60 return ____raw_writeq(val, base + offset);
61}
62
63static int tx4939_rng_data_present(struct hwrng *rng, int wait)
64{
65 struct tx4939_rng *rngdev = container_of(rng, struct tx4939_rng, rng);
66 int i;
67
68 if (rngdev->data_avail)
69 return rngdev->data_avail;
70 for (i = 0; i < 20; i++) {
71 rng_io_start();
72 if (!(read_rng(rngdev->base, TX4939_RNG_RCSR)
73 & TX4939_RNG_RCSR_ST)) {
74 rngdev->databuf[0] =
75 read_rng(rngdev->base, TX4939_RNG_ROR(0));
76 rngdev->databuf[1] =
77 read_rng(rngdev->base, TX4939_RNG_ROR(1));
78 rngdev->databuf[2] =
79 read_rng(rngdev->base, TX4939_RNG_ROR(2));
80 rngdev->data_avail =
81 sizeof(rngdev->databuf) / sizeof(u32);
82 /* Start RNG */
83 write_rng(TX4939_RNG_RCSR_ST,
84 rngdev->base, TX4939_RNG_RCSR);
85 wait = 0;
86 }
87 rng_io_end();
88 if (!wait)
89 break;
90 /* 90 bus clock cycles by default for generation */
91 ndelay(90 * 5);
92 }
93 return rngdev->data_avail;
94}
95
96static int tx4939_rng_data_read(struct hwrng *rng, u32 *buffer)
97{
98 struct tx4939_rng *rngdev = container_of(rng, struct tx4939_rng, rng);
99
100 rngdev->data_avail--;
101 *buffer = *((u32 *)&rngdev->databuf + rngdev->data_avail);
102 return sizeof(u32);
103}
104
105static int __init tx4939_rng_probe(struct platform_device *dev)
106{
107 struct tx4939_rng *rngdev;
108 struct resource *r;
109 int i;
110
111 r = platform_get_resource(dev, IORESOURCE_MEM, 0);
112 if (!r)
113 return -EBUSY;
114 rngdev = devm_kzalloc(&dev->dev, sizeof(*rngdev), GFP_KERNEL);
115 if (!rngdev)
116 return -ENOMEM;
117 if (!devm_request_mem_region(&dev->dev, r->start, resource_size(r),
118 dev_name(&dev->dev)))
119 return -EBUSY;
120 rngdev->base = devm_ioremap(&dev->dev, r->start, resource_size(r));
121 if (!rngdev->base)
122 return -EBUSY;
123
124 rngdev->rng.name = dev_name(&dev->dev);
125 rngdev->rng.data_present = tx4939_rng_data_present;
126 rngdev->rng.data_read = tx4939_rng_data_read;
127
128 rng_io_start();
129 /* Reset RNG */
130 write_rng(TX4939_RNG_RCSR_RST, rngdev->base, TX4939_RNG_RCSR);
131 write_rng(0, rngdev->base, TX4939_RNG_RCSR);
132 /* Start RNG */
133 write_rng(TX4939_RNG_RCSR_ST, rngdev->base, TX4939_RNG_RCSR);
134 rng_io_end();
135 /*
136 * Drop first two results. From the datasheet:
137 * The quality of the random numbers generated immediately
138 * after reset can be insufficient. Therefore, do not use
139 * random numbers obtained from the first and second
140 * generations; use the ones from the third or subsequent
141 * generation.
142 */
143 for (i = 0; i < 2; i++) {
144 rngdev->data_avail = 0;
145 if (!tx4939_rng_data_present(&rngdev->rng, 1))
146 return -EIO;
147 }
148
149 platform_set_drvdata(dev, rngdev);
150 return hwrng_register(&rngdev->rng);
151}
152
153static int __exit tx4939_rng_remove(struct platform_device *dev)
154{
155 struct tx4939_rng *rngdev = platform_get_drvdata(dev);
156
157 hwrng_unregister(&rngdev->rng);
158 platform_set_drvdata(dev, NULL);
159 return 0;
160}
161
162static struct platform_driver tx4939_rng_driver = {
163 .driver = {
164 .name = "tx4939-rng",
165 .owner = THIS_MODULE,
166 },
167 .remove = tx4939_rng_remove,
168};
169
170static int __init tx4939rng_init(void)
171{
172 return platform_driver_probe(&tx4939_rng_driver, tx4939_rng_probe);
173}
174
175static void __exit tx4939rng_exit(void)
176{
177 platform_driver_unregister(&tx4939_rng_driver);
178}
179
180module_init(tx4939rng_init);
181module_exit(tx4939rng_exit);
182
183MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver for TX4939");
184MODULE_LICENSE("GPL");
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 259644646b82..d2e698096ace 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2375,14 +2375,14 @@ static int __devinit ipmi_of_probe(struct of_device *dev,
2375 info->io.addr_data, info->io.regsize, info->io.regspacing, 2375 info->io.addr_data, info->io.regsize, info->io.regspacing,
2376 info->irq); 2376 info->irq);
2377 2377
2378 dev->dev.driver_data = (void *) info; 2378 dev_set_drvdata(&dev->dev, info);
2379 2379
2380 return try_smi_init(info); 2380 return try_smi_init(info);
2381} 2381}
2382 2382
2383static int __devexit ipmi_of_remove(struct of_device *dev) 2383static int __devexit ipmi_of_remove(struct of_device *dev)
2384{ 2384{
2385 cleanup_one_si(dev->dev.driver_data); 2385 cleanup_one_si(dev_get_drvdata(&dev->dev));
2386 return 0; 2386 return 0;
2387} 2387}
2388 2388
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index a5e0db9d7662..62c99fa59e2b 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -168,7 +168,6 @@ static const struct file_operations misc_fops = {
168 .open = misc_open, 168 .open = misc_open,
169}; 169};
170 170
171
172/** 171/**
173 * misc_register - register a miscellaneous device 172 * misc_register - register a miscellaneous device
174 * @misc: device structure 173 * @misc: device structure
@@ -217,8 +216,8 @@ int misc_register(struct miscdevice * misc)
217 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7); 216 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
218 dev = MKDEV(MISC_MAJOR, misc->minor); 217 dev = MKDEV(MISC_MAJOR, misc->minor);
219 218
220 misc->this_device = device_create(misc_class, misc->parent, dev, NULL, 219 misc->this_device = device_create(misc_class, misc->parent, dev,
221 "%s", misc->name); 220 misc, "%s", misc->name);
222 if (IS_ERR(misc->this_device)) { 221 if (IS_ERR(misc->this_device)) {
223 err = PTR_ERR(misc->this_device); 222 err = PTR_ERR(misc->this_device);
224 goto out; 223 goto out;
@@ -264,6 +263,15 @@ int misc_deregister(struct miscdevice *misc)
264EXPORT_SYMBOL(misc_register); 263EXPORT_SYMBOL(misc_register);
265EXPORT_SYMBOL(misc_deregister); 264EXPORT_SYMBOL(misc_deregister);
266 265
266static char *misc_nodename(struct device *dev)
267{
268 struct miscdevice *c = dev_get_drvdata(dev);
269
270 if (c->devnode)
271 return kstrdup(c->devnode, GFP_KERNEL);
272 return NULL;
273}
274
267static int __init misc_init(void) 275static int __init misc_init(void)
268{ 276{
269 int err; 277 int err;
@@ -279,6 +287,7 @@ static int __init misc_init(void)
279 err = -EIO; 287 err = -EIO;
280 if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) 288 if (register_chrdev(MISC_MAJOR,"misc",&misc_fops))
281 goto fail_printk; 289 goto fail_printk;
290 misc_class->nodename = misc_nodename;
282 return 0; 291 return 0;
283 292
284fail_printk: 293fail_printk:
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index db32f0e4c7dd..05f9d18b9361 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -261,6 +261,11 @@ static const struct file_operations raw_ctl_fops = {
261 261
262static struct cdev raw_cdev; 262static struct cdev raw_cdev;
263 263
264static char *raw_nodename(struct device *dev)
265{
266 return kasprintf(GFP_KERNEL, "raw/%s", dev_name(dev));
267}
268
264static int __init raw_init(void) 269static int __init raw_init(void)
265{ 270{
266 dev_t dev = MKDEV(RAW_MAJOR, 0); 271 dev_t dev = MKDEV(RAW_MAJOR, 0);
@@ -284,6 +289,7 @@ static int __init raw_init(void)
284 ret = PTR_ERR(raw_class); 289 ret = PTR_ERR(raw_class);
285 goto error_region; 290 goto error_region;
286 } 291 }
292 raw_class->nodename = raw_nodename;
287 device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl"); 293 device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
288 294
289 return 0; 295 return 0;
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index c796a86ab7f3..d9113b4c76e3 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -171,8 +171,9 @@ int do_poke_blanked_console;
171int console_blanked; 171int console_blanked;
172 172
173static int vesa_blank_mode; /* 0:none 1:suspendV 2:suspendH 3:powerdown */ 173static int vesa_blank_mode; /* 0:none 1:suspendV 2:suspendH 3:powerdown */
174static int blankinterval = 10*60*HZ;
175static int vesa_off_interval; 174static int vesa_off_interval;
175static int blankinterval = 10*60;
176core_param(consoleblank, blankinterval, int, 0444);
176 177
177static DECLARE_WORK(console_work, console_callback); 178static DECLARE_WORK(console_work, console_callback);
178 179
@@ -1485,7 +1486,7 @@ static void setterm_command(struct vc_data *vc)
1485 update_attr(vc); 1486 update_attr(vc);
1486 break; 1487 break;
1487 case 9: /* set blanking interval */ 1488 case 9: /* set blanking interval */
1488 blankinterval = ((vc->vc_par[1] < 60) ? vc->vc_par[1] : 60) * 60 * HZ; 1489 blankinterval = ((vc->vc_par[1] < 60) ? vc->vc_par[1] : 60) * 60;
1489 poke_blanked_console(); 1490 poke_blanked_console();
1490 break; 1491 break;
1491 case 10: /* set bell frequency in Hz */ 1492 case 10: /* set bell frequency in Hz */
@@ -2871,7 +2872,7 @@ static int __init con_init(void)
2871 2872
2872 if (blankinterval) { 2873 if (blankinterval) {
2873 blank_state = blank_normal_wait; 2874 blank_state = blank_normal_wait;
2874 mod_timer(&console_timer, jiffies + blankinterval); 2875 mod_timer(&console_timer, jiffies + (blankinterval * HZ));
2875 } 2876 }
2876 2877
2877 for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) { 2878 for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
@@ -3677,7 +3678,7 @@ void do_unblank_screen(int leaving_gfx)
3677 return; /* but leave console_blanked != 0 */ 3678 return; /* but leave console_blanked != 0 */
3678 3679
3679 if (blankinterval) { 3680 if (blankinterval) {
3680 mod_timer(&console_timer, jiffies + blankinterval); 3681 mod_timer(&console_timer, jiffies + (blankinterval * HZ));
3681 blank_state = blank_normal_wait; 3682 blank_state = blank_normal_wait;
3682 } 3683 }
3683 3684
@@ -3711,7 +3712,7 @@ void unblank_screen(void)
3711static void blank_screen_t(unsigned long dummy) 3712static void blank_screen_t(unsigned long dummy)
3712{ 3713{
3713 if (unlikely(!keventd_up())) { 3714 if (unlikely(!keventd_up())) {
3714 mod_timer(&console_timer, jiffies + blankinterval); 3715 mod_timer(&console_timer, jiffies + (blankinterval * HZ));
3715 return; 3716 return;
3716 } 3717 }
3717 blank_timer_expired = 1; 3718 blank_timer_expired = 1;
@@ -3741,7 +3742,7 @@ void poke_blanked_console(void)
3741 if (console_blanked) 3742 if (console_blanked)
3742 unblank_screen(); 3743 unblank_screen();
3743 else if (blankinterval) { 3744 else if (blankinterval) {
3744 mod_timer(&console_timer, jiffies + blankinterval); 3745 mod_timer(&console_timer, jiffies + (blankinterval * HZ));
3745 blank_state = blank_normal_wait; 3746 blank_state = blank_normal_wait;
3746 } 3747 }
3747} 3748}