aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/apm-emulation.c5
-rw-r--r--drivers/char/bsr.c2
-rw-r--r--drivers/char/hpet.c6
-rw-r--r--drivers/char/hw_random/Kconfig2
-rw-r--r--drivers/char/hw_random/amd-rng.c9
-rw-r--r--drivers/char/hw_random/n2-drv.c7
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c7
-rw-r--r--drivers/char/mem.c42
-rw-r--r--drivers/char/raw.c34
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c14
11 files changed, 86 insertions, 44 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index ad59b4e0a9b5..49502bc5360a 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -523,7 +523,7 @@ config RAW_DRIVER
523 with the O_DIRECT flag. 523 with the O_DIRECT flag.
524 524
525config MAX_RAW_DEVS 525config MAX_RAW_DEVS
526 int "Maximum number of RAW devices to support (1-8192)" 526 int "Maximum number of RAW devices to support (1-65536)"
527 depends on RAW_DRIVER 527 depends on RAW_DRIVER
528 default "256" 528 default "256"
529 help 529 help
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index 45b987c9889e..548708c4b2b8 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -126,7 +126,6 @@ struct apm_user {
126/* 126/*
127 * Local variables 127 * Local variables
128 */ 128 */
129static DEFINE_MUTEX(apm_mutex);
130static atomic_t suspend_acks_pending = ATOMIC_INIT(0); 129static atomic_t suspend_acks_pending = ATOMIC_INIT(0);
131static atomic_t userspace_notification_inhibit = ATOMIC_INIT(0); 130static atomic_t userspace_notification_inhibit = ATOMIC_INIT(0);
132static int apm_disabled; 131static int apm_disabled;
@@ -275,7 +274,6 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg)
275 if (!as->suser || !as->writer) 274 if (!as->suser || !as->writer)
276 return -EPERM; 275 return -EPERM;
277 276
278 mutex_lock(&apm_mutex);
279 switch (cmd) { 277 switch (cmd) {
280 case APM_IOC_SUSPEND: 278 case APM_IOC_SUSPEND:
281 mutex_lock(&state_lock); 279 mutex_lock(&state_lock);
@@ -336,7 +334,6 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg)
336 mutex_unlock(&state_lock); 334 mutex_unlock(&state_lock);
337 break; 335 break;
338 } 336 }
339 mutex_unlock(&apm_mutex);
340 337
341 return err; 338 return err;
342} 339}
@@ -371,7 +368,6 @@ static int apm_open(struct inode * inode, struct file * filp)
371{ 368{
372 struct apm_user *as; 369 struct apm_user *as;
373 370
374 mutex_lock(&apm_mutex);
375 as = kzalloc(sizeof(*as), GFP_KERNEL); 371 as = kzalloc(sizeof(*as), GFP_KERNEL);
376 if (as) { 372 if (as) {
377 /* 373 /*
@@ -391,7 +387,6 @@ static int apm_open(struct inode * inode, struct file * filp)
391 387
392 filp->private_data = as; 388 filp->private_data = as;
393 } 389 }
394 mutex_unlock(&apm_mutex);
395 390
396 return as ? 0 : -ENOMEM; 391 return as ? 0 : -ENOMEM;
397} 392}
diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c
index a4a6c2f044b5..cf39bc08ce08 100644
--- a/drivers/char/bsr.c
+++ b/drivers/char/bsr.c
@@ -295,7 +295,7 @@ static int bsr_create_devs(struct device_node *bn)
295static int __init bsr_init(void) 295static int __init bsr_init(void)
296{ 296{
297 struct device_node *np; 297 struct device_node *np;
298 dev_t bsr_dev = MKDEV(bsr_major, 0); 298 dev_t bsr_dev;
299 int ret = -ENODEV; 299 int ret = -ENODEV;
300 int result; 300 int result;
301 301
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 7066e801b9d3..051474c65b78 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -84,8 +84,6 @@ static struct clocksource clocksource_hpet = {
84 .rating = 250, 84 .rating = 250,
85 .read = read_hpet, 85 .read = read_hpet,
86 .mask = CLOCKSOURCE_MASK(64), 86 .mask = CLOCKSOURCE_MASK(64),
87 .mult = 0, /* to be calculated */
88 .shift = 10,
89 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 87 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
90}; 88};
91static struct clocksource *hpet_clocksource; 89static struct clocksource *hpet_clocksource;
@@ -934,9 +932,7 @@ int hpet_alloc(struct hpet_data *hdp)
934 if (!hpet_clocksource) { 932 if (!hpet_clocksource) {
935 hpet_mctr = (void __iomem *)&hpetp->hp_hpet->hpet_mc; 933 hpet_mctr = (void __iomem *)&hpetp->hp_hpet->hpet_mc;
936 CLKSRC_FSYS_MMIO_SET(clocksource_hpet.fsys_mmio, hpet_mctr); 934 CLKSRC_FSYS_MMIO_SET(clocksource_hpet.fsys_mmio, hpet_mctr);
937 clocksource_hpet.mult = clocksource_hz2mult(hpetp->hp_tick_freq, 935 clocksource_register_hz(&clocksource_hpet, hpetp->hp_tick_freq);
938 clocksource_hpet.shift);
939 clocksource_register(&clocksource_hpet);
940 hpetp->hp_clocksource = &clocksource_hpet; 936 hpetp->hp_clocksource = &clocksource_hpet;
941 hpet_clocksource = &clocksource_hpet; 937 hpet_clocksource = &clocksource_hpet;
942 } 938 }
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index beecd1cf9b99..a60043b3e409 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -49,7 +49,7 @@ config HW_RANDOM_INTEL
49 49
50config HW_RANDOM_AMD 50config HW_RANDOM_AMD
51 tristate "AMD HW Random Number Generator support" 51 tristate "AMD HW Random Number Generator support"
52 depends on HW_RANDOM && X86 && PCI 52 depends on HW_RANDOM && (X86 || PPC_MAPLE) && PCI
53 default HW_RANDOM 53 default HW_RANDOM
54 ---help--- 54 ---help---
55 This driver provides kernel-side support for the Random Number 55 This driver provides kernel-side support for the Random Number
diff --git a/drivers/char/hw_random/amd-rng.c b/drivers/char/hw_random/amd-rng.c
index 0d8c5788b8e4..c6af038682f1 100644
--- a/drivers/char/hw_random/amd-rng.c
+++ b/drivers/char/hw_random/amd-rng.c
@@ -133,6 +133,12 @@ found:
133 pmbase &= 0x0000FF00; 133 pmbase &= 0x0000FF00;
134 if (pmbase == 0) 134 if (pmbase == 0)
135 goto out; 135 goto out;
136 if (!request_region(pmbase + 0xF0, 8, "AMD HWRNG")) {
137 dev_err(&pdev->dev, "AMD HWRNG region 0x%x already in use!\n",
138 pmbase + 0xF0);
139 err = -EBUSY;
140 goto out;
141 }
136 amd_rng.priv = (unsigned long)pmbase; 142 amd_rng.priv = (unsigned long)pmbase;
137 amd_pdev = pdev; 143 amd_pdev = pdev;
138 144
@@ -141,6 +147,7 @@ found:
141 if (err) { 147 if (err) {
142 printk(KERN_ERR PFX "RNG registering failed (%d)\n", 148 printk(KERN_ERR PFX "RNG registering failed (%d)\n",
143 err); 149 err);
150 release_region(pmbase + 0xF0, 8);
144 goto out; 151 goto out;
145 } 152 }
146out: 153out:
@@ -149,6 +156,8 @@ out:
149 156
150static void __exit mod_exit(void) 157static void __exit mod_exit(void)
151{ 158{
159 u32 pmbase = (unsigned long)amd_rng.priv;
160 release_region(pmbase + 0xF0, 8);
152 hwrng_unregister(&amd_rng); 161 hwrng_unregister(&amd_rng);
153} 162}
154 163
diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c
index 43ac61978d8b..ac6739e085e3 100644
--- a/drivers/char/hw_random/n2-drv.c
+++ b/drivers/char/hw_random/n2-drv.c
@@ -619,15 +619,18 @@ static void __devinit n2rng_driver_version(void)
619 pr_info("%s", version); 619 pr_info("%s", version);
620} 620}
621 621
622static const struct of_device_id n2rng_match[];
622static int __devinit n2rng_probe(struct platform_device *op) 623static int __devinit n2rng_probe(struct platform_device *op)
623{ 624{
625 const struct of_device_id *match;
624 int victoria_falls; 626 int victoria_falls;
625 int err = -ENOMEM; 627 int err = -ENOMEM;
626 struct n2rng *np; 628 struct n2rng *np;
627 629
628 if (!op->dev.of_match) 630 match = of_match_device(n2rng_match, &op->dev);
631 if (!match)
629 return -EINVAL; 632 return -EINVAL;
630 victoria_falls = (op->dev.of_match->data != NULL); 633 victoria_falls = (match->data != NULL);
631 634
632 n2rng_driver_version(); 635 n2rng_driver_version();
633 np = kzalloc(sizeof(*np), GFP_KERNEL); 636 np = kzalloc(sizeof(*np), GFP_KERNEL);
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index cc6c9b2546a3..64c6b8530615 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2554,9 +2554,11 @@ static struct pci_driver ipmi_pci_driver = {
2554}; 2554};
2555#endif /* CONFIG_PCI */ 2555#endif /* CONFIG_PCI */
2556 2556
2557static struct of_device_id ipmi_match[];
2557static int __devinit ipmi_probe(struct platform_device *dev) 2558static int __devinit ipmi_probe(struct platform_device *dev)
2558{ 2559{
2559#ifdef CONFIG_OF 2560#ifdef CONFIG_OF
2561 const struct of_device_id *match;
2560 struct smi_info *info; 2562 struct smi_info *info;
2561 struct resource resource; 2563 struct resource resource;
2562 const __be32 *regsize, *regspacing, *regshift; 2564 const __be32 *regsize, *regspacing, *regshift;
@@ -2566,7 +2568,8 @@ static int __devinit ipmi_probe(struct platform_device *dev)
2566 2568
2567 dev_info(&dev->dev, "probing via device tree\n"); 2569 dev_info(&dev->dev, "probing via device tree\n");
2568 2570
2569 if (!dev->dev.of_match) 2571 match = of_match_device(ipmi_match, &dev->dev);
2572 if (!match)
2570 return -EINVAL; 2573 return -EINVAL;
2571 2574
2572 ret = of_address_to_resource(np, 0, &resource); 2575 ret = of_address_to_resource(np, 0, &resource);
@@ -2601,7 +2604,7 @@ static int __devinit ipmi_probe(struct platform_device *dev)
2601 return -ENOMEM; 2604 return -ENOMEM;
2602 } 2605 }
2603 2606
2604 info->si_type = (enum si_type) dev->dev.of_match->data; 2607 info->si_type = (enum si_type) match->data;
2605 info->addr_source = SI_DEVICETREE; 2608 info->addr_source = SI_DEVICETREE;
2606 info->irq_setup = std_irq_setup; 2609 info->irq_setup = std_irq_setup;
2607 2610
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 436a99017998..8fc04b4f311f 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -806,29 +806,41 @@ static const struct file_operations oldmem_fops = {
806}; 806};
807#endif 807#endif
808 808
809static ssize_t kmsg_write(struct file *file, const char __user *buf, 809static ssize_t kmsg_writev(struct kiocb *iocb, const struct iovec *iv,
810 size_t count, loff_t *ppos) 810 unsigned long count, loff_t pos)
811{ 811{
812 char *tmp; 812 char *line, *p;
813 ssize_t ret; 813 int i;
814 ssize_t ret = -EFAULT;
815 size_t len = iov_length(iv, count);
814 816
815 tmp = kmalloc(count + 1, GFP_KERNEL); 817 line = kmalloc(len + 1, GFP_KERNEL);
816 if (tmp == NULL) 818 if (line == NULL)
817 return -ENOMEM; 819 return -ENOMEM;
818 ret = -EFAULT; 820
819 if (!copy_from_user(tmp, buf, count)) { 821 /*
820 tmp[count] = 0; 822 * copy all vectors into a single string, to ensure we do
821 ret = printk("%s", tmp); 823 * not interleave our log line with other printk calls
822 if (ret > count) 824 */
823 /* printk can add a prefix */ 825 p = line;
824 ret = count; 826 for (i = 0; i < count; i++) {
827 if (copy_from_user(p, iv[i].iov_base, iv[i].iov_len))
828 goto out;
829 p += iv[i].iov_len;
825 } 830 }
826 kfree(tmp); 831 p[0] = '\0';
832
833 ret = printk("%s", line);
834 /* printk can add a prefix */
835 if (ret > len)
836 ret = len;
837out:
838 kfree(line);
827 return ret; 839 return ret;
828} 840}
829 841
830static const struct file_operations kmsg_fops = { 842static const struct file_operations kmsg_fops = {
831 .write = kmsg_write, 843 .aio_write = kmsg_writev,
832 .llseek = noop_llseek, 844 .llseek = noop_llseek,
833}; 845};
834 846
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index b4b9d5a47885..b33e8ea314ed 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -21,6 +21,7 @@
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/gfp.h> 22#include <linux/gfp.h>
23#include <linux/compat.h> 23#include <linux/compat.h>
24#include <linux/vmalloc.h>
24 25
25#include <asm/uaccess.h> 26#include <asm/uaccess.h>
26 27
@@ -30,10 +31,15 @@ struct raw_device_data {
30}; 31};
31 32
32static struct class *raw_class; 33static struct class *raw_class;
33static struct raw_device_data raw_devices[MAX_RAW_MINORS]; 34static struct raw_device_data *raw_devices;
34static DEFINE_MUTEX(raw_mutex); 35static DEFINE_MUTEX(raw_mutex);
35static const struct file_operations raw_ctl_fops; /* forward declaration */ 36static const struct file_operations raw_ctl_fops; /* forward declaration */
36 37
38static int max_raw_minors = MAX_RAW_MINORS;
39
40module_param(max_raw_minors, int, 0);
41MODULE_PARM_DESC(max_raw_minors, "Maximum number of raw devices (1-65536)");
42
37/* 43/*
38 * Open/close code for raw IO. 44 * Open/close code for raw IO.
39 * 45 *
@@ -125,7 +131,7 @@ static int bind_set(int number, u64 major, u64 minor)
125 struct raw_device_data *rawdev; 131 struct raw_device_data *rawdev;
126 int err = 0; 132 int err = 0;
127 133
128 if (number <= 0 || number >= MAX_RAW_MINORS) 134 if (number <= 0 || number >= max_raw_minors)
129 return -EINVAL; 135 return -EINVAL;
130 136
131 if (MAJOR(dev) != major || MINOR(dev) != minor) 137 if (MAJOR(dev) != major || MINOR(dev) != minor)
@@ -312,14 +318,27 @@ static int __init raw_init(void)
312 dev_t dev = MKDEV(RAW_MAJOR, 0); 318 dev_t dev = MKDEV(RAW_MAJOR, 0);
313 int ret; 319 int ret;
314 320
315 ret = register_chrdev_region(dev, MAX_RAW_MINORS, "raw"); 321 if (max_raw_minors < 1 || max_raw_minors > 65536) {
322 printk(KERN_WARNING "raw: invalid max_raw_minors (must be"
323 " between 1 and 65536), using %d\n", MAX_RAW_MINORS);
324 max_raw_minors = MAX_RAW_MINORS;
325 }
326
327 raw_devices = vmalloc(sizeof(struct raw_device_data) * max_raw_minors);
328 if (!raw_devices) {
329 printk(KERN_ERR "Not enough memory for raw device structures\n");
330 ret = -ENOMEM;
331 goto error;
332 }
333 memset(raw_devices, 0, sizeof(struct raw_device_data) * max_raw_minors);
334
335 ret = register_chrdev_region(dev, max_raw_minors, "raw");
316 if (ret) 336 if (ret)
317 goto error; 337 goto error;
318 338
319 cdev_init(&raw_cdev, &raw_fops); 339 cdev_init(&raw_cdev, &raw_fops);
320 ret = cdev_add(&raw_cdev, dev, MAX_RAW_MINORS); 340 ret = cdev_add(&raw_cdev, dev, max_raw_minors);
321 if (ret) { 341 if (ret) {
322 kobject_put(&raw_cdev.kobj);
323 goto error_region; 342 goto error_region;
324 } 343 }
325 344
@@ -336,8 +355,9 @@ static int __init raw_init(void)
336 return 0; 355 return 0;
337 356
338error_region: 357error_region:
339 unregister_chrdev_region(dev, MAX_RAW_MINORS); 358 unregister_chrdev_region(dev, max_raw_minors);
340error: 359error:
360 vfree(raw_devices);
341 return ret; 361 return ret;
342} 362}
343 363
@@ -346,7 +366,7 @@ static void __exit raw_exit(void)
346 device_destroy(raw_class, MKDEV(RAW_MAJOR, 0)); 366 device_destroy(raw_class, MKDEV(RAW_MAJOR, 0));
347 class_destroy(raw_class); 367 class_destroy(raw_class);
348 cdev_del(&raw_cdev); 368 cdev_del(&raw_cdev);
349 unregister_chrdev_region(MKDEV(RAW_MAJOR, 0), MAX_RAW_MINORS); 369 unregister_chrdev_region(MKDEV(RAW_MAJOR, 0), max_raw_minors);
350} 370}
351 371
352module_init(raw_init); 372module_init(raw_init);
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index d6412c16385f..39ccdeada791 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -715,13 +715,13 @@ static int __devexit hwicap_remove(struct device *dev)
715} 715}
716 716
717#ifdef CONFIG_OF 717#ifdef CONFIG_OF
718static int __devinit hwicap_of_probe(struct platform_device *op) 718static int __devinit hwicap_of_probe(struct platform_device *op,
719 const struct hwicap_driver_config *config)
719{ 720{
720 struct resource res; 721 struct resource res;
721 const unsigned int *id; 722 const unsigned int *id;
722 const char *family; 723 const char *family;
723 int rc; 724 int rc;
724 const struct hwicap_driver_config *config = op->dev.of_match->data;
725 const struct config_registers *regs; 725 const struct config_registers *regs;
726 726
727 727
@@ -751,20 +751,24 @@ static int __devinit hwicap_of_probe(struct platform_device *op)
751 regs); 751 regs);
752} 752}
753#else 753#else
754static inline int hwicap_of_probe(struct platform_device *op) 754static inline int hwicap_of_probe(struct platform_device *op,
755 const struct hwicap_driver_config *config)
755{ 756{
756 return -EINVAL; 757 return -EINVAL;
757} 758}
758#endif /* CONFIG_OF */ 759#endif /* CONFIG_OF */
759 760
761static const struct of_device_id __devinitconst hwicap_of_match[];
760static int __devinit hwicap_drv_probe(struct platform_device *pdev) 762static int __devinit hwicap_drv_probe(struct platform_device *pdev)
761{ 763{
764 const struct of_device_id *match;
762 struct resource *res; 765 struct resource *res;
763 const struct config_registers *regs; 766 const struct config_registers *regs;
764 const char *family; 767 const char *family;
765 768
766 if (pdev->dev.of_match) 769 match = of_match_device(hwicap_of_match, &pdev->dev);
767 return hwicap_of_probe(pdev); 770 if (match)
771 return hwicap_of_probe(pdev, match->data);
768 772
769 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 773 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
770 if (!res) 774 if (!res)