diff options
Diffstat (limited to 'drivers/input/misc/pcspkr.c')
| -rw-r--r-- | drivers/input/misc/pcspkr.c | 53 |
1 files changed, 19 insertions, 34 deletions
diff --git a/drivers/input/misc/pcspkr.c b/drivers/input/misc/pcspkr.c index 906bf5e8de8..674a2cfc3c0 100644 --- a/drivers/input/misc/pcspkr.c +++ b/drivers/input/misc/pcspkr.c @@ -14,22 +14,16 @@ #include <linux/kernel.h> #include <linux/module.h> -#include <linux/init.h> +#include <linux/i8253.h> #include <linux/input.h> #include <linux/platform_device.h> -#include <asm/8253pit.h> +#include <linux/timex.h> #include <asm/io.h> MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); MODULE_DESCRIPTION("PC Speaker beeper driver"); MODULE_LICENSE("GPL"); - -#ifdef CONFIG_X86 -/* Use the global PIT lock ! */ -#include <asm/i8253.h> -#else -static DEFINE_SPINLOCK(i8253_lock); -#endif +MODULE_ALIAS("platform:pcspkr"); static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) { @@ -48,27 +42,27 @@ static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int c if (value > 20 && value < 32767) count = PIT_TICK_RATE / value; - spin_lock_irqsave(&i8253_lock, flags); + raw_spin_lock_irqsave(&i8253_lock, flags); if (count) { - /* enable counter 2 */ - outb_p(inb_p(0x61) | 3, 0x61); /* set command for counter 2, 2 byte write */ outb_p(0xB6, 0x43); /* select desired HZ */ outb_p(count & 0xff, 0x42); outb((count >> 8) & 0xff, 0x42); + /* enable counter 2 */ + outb_p(inb_p(0x61) | 3, 0x61); } else { /* disable counter 2 */ outb(inb_p(0x61) & 0xFC, 0x61); } - spin_unlock_irqrestore(&i8253_lock, flags); + raw_spin_unlock_irqrestore(&i8253_lock, flags); return 0; } -static int __devinit pcspkr_probe(struct platform_device *dev) +static int pcspkr_probe(struct platform_device *dev) { struct input_dev *pcspkr_dev; int err; @@ -85,8 +79,8 @@ static int __devinit pcspkr_probe(struct platform_device *dev) pcspkr_dev->id.version = 0x0100; pcspkr_dev->dev.parent = &dev->dev; - pcspkr_dev->evbit[0] = BIT(EV_SND); - pcspkr_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); + pcspkr_dev->evbit[0] = BIT_MASK(EV_SND); + pcspkr_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); pcspkr_dev->event = pcspkr_event; err = input_register_device(pcspkr_dev); @@ -100,19 +94,18 @@ static int __devinit pcspkr_probe(struct platform_device *dev) return 0; } -static int __devexit pcspkr_remove(struct platform_device *dev) +static int pcspkr_remove(struct platform_device *dev) { struct input_dev *pcspkr_dev = platform_get_drvdata(dev); input_unregister_device(pcspkr_dev); - platform_set_drvdata(dev, NULL); /* turn off the speaker */ pcspkr_event(NULL, EV_SND, SND_BELL, 0); return 0; } -static int pcspkr_suspend(struct platform_device *dev, pm_message_t state) +static int pcspkr_suspend(struct device *dev) { pcspkr_event(NULL, EV_SND, SND_BELL, 0); @@ -125,27 +118,19 @@ static void pcspkr_shutdown(struct platform_device *dev) pcspkr_event(NULL, EV_SND, SND_BELL, 0); } +static const struct dev_pm_ops pcspkr_pm_ops = { + .suspend = pcspkr_suspend, +}; + static struct platform_driver pcspkr_platform_driver = { .driver = { .name = "pcspkr", .owner = THIS_MODULE, + .pm = &pcspkr_pm_ops, }, .probe = pcspkr_probe, - .remove = __devexit_p(pcspkr_remove), - .suspend = pcspkr_suspend, + .remove = pcspkr_remove, .shutdown = pcspkr_shutdown, }; +module_platform_driver(pcspkr_platform_driver); - -static int __init pcspkr_init(void) -{ - return platform_driver_register(&pcspkr_platform_driver); -} - -static void __exit pcspkr_exit(void) -{ - platform_driver_unregister(&pcspkr_platform_driver); -} - -module_init(pcspkr_init); -module_exit(pcspkr_exit); |
