aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-12-21 00:52:29 -0500
committerDmitry Torokhov <dtor_core@ameritech.net>2005-12-21 00:52:29 -0500
commit1f75e6bdfa011c0c2afa65ed1585200a3bc92ddf (patch)
treeda9d53473c8551ab365816388c4502d23f402052 /drivers
parent59317747359dbc26af920813b3df358333a3840c (diff)
Input: m68kspkr - register with driver core as a platfrom device
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/misc/m68kspkr.c102
1 files changed, 85 insertions, 17 deletions
diff --git a/drivers/input/misc/m68kspkr.c b/drivers/input/misc/m68kspkr.c
index 04489ad7702a..8d6c3837badb 100644
--- a/drivers/input/misc/m68kspkr.c
+++ b/drivers/input/misc/m68kspkr.c
@@ -17,6 +17,7 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/input.h> 19#include <linux/input.h>
20#include <linux/platform_device.h>
20#include <asm/machdep.h> 21#include <asm/machdep.h>
21#include <asm/io.h> 22#include <asm/io.h>
22 23
@@ -24,7 +25,7 @@ MODULE_AUTHOR("Richard Zidlicky <rz@linux-m68k.org>");
24MODULE_DESCRIPTION("m68k beeper driver"); 25MODULE_DESCRIPTION("m68k beeper driver");
25MODULE_LICENSE("GPL"); 26MODULE_LICENSE("GPL");
26 27
27static struct input_dev *m68kspkr_dev; 28static struct platform_device *m68kspkr_platform_device;
28 29
29static int m68kspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 30static int m68kspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
30{ 31{
@@ -47,36 +48,103 @@ static int m68kspkr_event(struct input_dev *dev, unsigned int type, unsigned int
47 return 0; 48 return 0;
48} 49}
49 50
51static int __devinit m68kspkr_probe(struct platform_device *dev)
52{
53 struct input_dev *input_dev;
54 int err;
55
56 input_dev = input_allocate_device();
57 if (!input_dev)
58 return -ENOMEM;
59
60 input_dev->name = "m68k beeper";
61 input_dev->phys = "m68k/generic";
62 input_dev->id.bustype = BUS_HOST;
63 input_dev->id.vendor = 0x001f;
64 input_dev->id.product = 0x0001;
65 input_dev->id.version = 0x0100;
66 input_dev->cdev.dev = &dev->dev;
67
68 input_dev->evbit[0] = BIT(EV_SND);
69 input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
70 input_dev->event = m68kspkr_event;
71
72 err = input_register_device(input_dev);
73 if (err) {
74 input_free_device(input_dev);
75 return err;
76 }
77
78 platform_set_drvdata(dev, input_dev);
79
80 return 0;
81}
82
83static int __devexit m68kspkr_remove(struct platform_device *dev)
84{
85 struct input_dev *input_dev = platform_get_drvdata(dev);
86
87 input_unregister_device(input_dev);
88 platform_set_drvdata(dev, NULL);
89 /* turn off the speaker */
90 m68kspkr_event(NULL, EV_SND, SND_BELL, 0);
91
92 return 0;
93}
94
95static void m68kspkr_shutdown(struct platform_device *dev)
96{
97 /* turn off the speaker */
98 m68kspkr_event(NULL, EV_SND, SND_BELL, 0);
99}
100
101static struct platform_driver m68kspkr_platform_driver = {
102 .driver = {
103 .name = "m68kspkr",
104 .owner = THIS_MODULE,
105 },
106 .probe = m68kspkr_probe,
107 .remove = __devexit_p(m68kspkr_remove),
108 .shutdown = m68kspkr_shutdown,
109};
110
50static int __init m68kspkr_init(void) 111static int __init m68kspkr_init(void)
51{ 112{
52 if (!mach_beep) { 113 int err;
114
115 if (!mach_beep) {
53 printk(KERN_INFO "m68kspkr: no lowlevel beep support\n"); 116 printk(KERN_INFO "m68kspkr: no lowlevel beep support\n");
54 return -ENODEV; 117 return -ENODEV;
55 } 118 }
56 119
57 m68kspkr_dev = input_allocate_device(); 120 err = platform_driver_register(&m68kspkr_platform_driver);
58 if (!m68kspkr_dev) 121 if (err)
59 return -ENOMEM; 122 return err;
60
61 m68kspkr_dev->name = "m68k beeper";
62 m68kspkr_dev->phys = "m68k/generic";
63 m68kspkr_dev->id.bustype = BUS_HOST;
64 m68kspkr_dev->id.vendor = 0x001f;
65 m68kspkr_dev->id.product = 0x0001;
66 m68kspkr_dev->id.version = 0x0100;
67 123
68 m68kspkr_dev->evbit[0] = BIT(EV_SND); 124 m68kspkr_platform_device = platform_device_alloc("m68kspkr", -1);
69 m68kspkr_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); 125 if (!m68kspkr_platform_device) {
70 m68kspkr_dev->event = m68kspkr_event; 126 err = -ENOMEM;
127 goto err_unregister_driver;
128 }
71 129
72 input_register_device(m68kspkr_dev); 130 err = platform_device_add(m68kspkr_platform_device);
131 if (err)
132 goto err_free_device;
73 133
74 return 0; 134 return 0;
135
136 err_free_device:
137 platform_device_put(m68kspkr_platform_device);
138 err_unregister_driver:
139 platform_driver_unregister(&m68kspkr_platform_driver);
140
141 return err;
75} 142}
76 143
77static void __exit m68kspkr_exit(void) 144static void __exit m68kspkr_exit(void)
78{ 145{
79 input_unregister_device(m68kspkr_dev); 146 platform_device_unregister(m68kspkr_platform_device);
147 platform_driver_unregister(&m68kspkr_platform_driver);
80} 148}
81 149
82module_init(m68kspkr_init); 150module_init(m68kspkr_init);