Commit 76b7cddf authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Greg Kroah-Hartman

[PATCH] Input: convert driver/input/misc to dynamic input_dev allocation

Input: convert driver/input/misc to dynamic input_dev allocation

This is required for input_dev sysfs integration
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 88789672
...@@ -24,9 +24,7 @@ MODULE_AUTHOR("Richard Zidlicky <rz@linux-m68k.org>"); ...@@ -24,9 +24,7 @@ MODULE_AUTHOR("Richard Zidlicky <rz@linux-m68k.org>");
MODULE_DESCRIPTION("m68k beeper driver"); MODULE_DESCRIPTION("m68k beeper driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static char m68kspkr_name[] = "m68k beeper"; static struct input_dev *m68kspkr_dev;
static char m68kspkr_phys[] = "m68k/generic";
static struct input_dev m68kspkr_dev;
static int m68kspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) static int m68kspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
{ {
...@@ -51,32 +49,34 @@ static int m68kspkr_event(struct input_dev *dev, unsigned int type, unsigned int ...@@ -51,32 +49,34 @@ static int m68kspkr_event(struct input_dev *dev, unsigned int type, unsigned int
static int __init m68kspkr_init(void) static int __init m68kspkr_init(void)
{ {
if (!mach_beep){ if (!mach_beep) {
printk("%s: no lowlevel beep support\n", m68kspkr_name); printk(KERN_INFO "m68kspkr: no lowlevel beep support\n");
return -1; return -ENODEV;
} }
m68kspkr_dev.evbit[0] = BIT(EV_SND); m68kspkr_dev = input_allocate_device();
m68kspkr_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); if (!m68kspkr_dev)
m68kspkr_dev.event = m68kspkr_event; return -ENOMEM;
m68kspkr_dev.name = m68kspkr_name; m68kspkr_dev->name = "m68k beeper";
m68kspkr_dev.phys = m68kspkr_phys; m68kspkr_dev->phys = "m68k/generic";
m68kspkr_dev.id.bustype = BUS_HOST; m68kspkr_dev->id.bustype = BUS_HOST;
m68kspkr_dev.id.vendor = 0x001f; m68kspkr_dev->id.vendor = 0x001f;
m68kspkr_dev.id.product = 0x0001; m68kspkr_dev->id.product = 0x0001;
m68kspkr_dev.id.version = 0x0100; m68kspkr_dev->id.version = 0x0100;
input_register_device(&m68kspkr_dev); m68kspkr_dev->evbit[0] = BIT(EV_SND);
m68kspkr_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
m68kspkr_dev->event = m68kspkr_event;
printk(KERN_INFO "input: %s\n", m68kspkr_name); input_register_device(m68kspkr_dev);
return 0; return 0;
} }
static void __exit m68kspkr_exit(void) static void __exit m68kspkr_exit(void)
{ {
input_unregister_device(&m68kspkr_dev); input_unregister_device(m68kspkr_dev);
} }
module_init(m68kspkr_init); module_init(m68kspkr_init);
......
...@@ -23,9 +23,7 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); ...@@ -23,9 +23,7 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
MODULE_DESCRIPTION("PC Speaker beeper driver"); MODULE_DESCRIPTION("PC Speaker beeper driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static char pcspkr_name[] = "PC Speaker"; static struct input_dev *pcspkr_dev;
static char pcspkr_phys[] = "isa0061/input0";
static struct input_dev pcspkr_dev;
static DEFINE_SPINLOCK(i8253_beep_lock); static DEFINE_SPINLOCK(i8253_beep_lock);
...@@ -68,27 +66,29 @@ static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int c ...@@ -68,27 +66,29 @@ static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int c
static int __init pcspkr_init(void) static int __init pcspkr_init(void)
{ {
pcspkr_dev.evbit[0] = BIT(EV_SND); pcspkr_dev = input_allocate_device();
pcspkr_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); if (!pcspkr_dev)
pcspkr_dev.event = pcspkr_event; return -ENOMEM;
pcspkr_dev.name = pcspkr_name; pcspkr_dev->name = "PC Speaker";
pcspkr_dev.phys = pcspkr_phys; pcspkr_dev->name = "isa0061/input0";
pcspkr_dev.id.bustype = BUS_ISA; pcspkr_dev->id.bustype = BUS_ISA;
pcspkr_dev.id.vendor = 0x001f; pcspkr_dev->id.vendor = 0x001f;
pcspkr_dev.id.product = 0x0001; pcspkr_dev->id.product = 0x0001;
pcspkr_dev.id.version = 0x0100; pcspkr_dev->id.version = 0x0100;
input_register_device(&pcspkr_dev); pcspkr_dev->evbit[0] = BIT(EV_SND);
pcspkr_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
pcspkr_dev->event = pcspkr_event;
printk(KERN_INFO "input: %s\n", pcspkr_name); input_register_device(pcspkr_dev);
return 0; return 0;
} }
static void __exit pcspkr_exit(void) static void __exit pcspkr_exit(void)
{ {
input_unregister_device(&pcspkr_dev); input_unregister_device(pcspkr_dev);
/* turn off the speaker */ /* turn off the speaker */
pcspkr_event(NULL, EV_SND, SND_BELL, 0); pcspkr_event(NULL, EV_SND, SND_BELL, 0);
} }
......
...@@ -17,28 +17,24 @@ ...@@ -17,28 +17,24 @@
#endif #endif
MODULE_AUTHOR("David S. Miller <davem@redhat.com>"); MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
MODULE_DESCRIPTION("PC Speaker beeper driver"); MODULE_DESCRIPTION("Sparc Speaker beeper driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static unsigned long beep_iobase; static unsigned long beep_iobase;
static struct input_dev *sparcspkr_dev;
static char *sparcspkr_isa_name = "Sparc ISA Speaker";
static char *sparcspkr_ebus_name = "Sparc EBUS Speaker";
static char *sparcspkr_phys = "sparc/input0";
static struct input_dev sparcspkr_dev;
DEFINE_SPINLOCK(beep_lock); DEFINE_SPINLOCK(beep_lock);
static void __init init_sparcspkr_struct(void) static void __init init_sparcspkr_struct(void)
{ {
sparcspkr_dev.evbit[0] = BIT(EV_SND); sparcspkr_dev->evbit[0] = BIT(EV_SND);
sparcspkr_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); sparcspkr_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
sparcspkr_dev.phys = sparcspkr_phys; sparcspkr_dev->phys = "sparc/input0";
sparcspkr_dev.id.bustype = BUS_ISA; sparcspkr_dev->id.bustype = BUS_ISA;
sparcspkr_dev.id.vendor = 0x001f; sparcspkr_dev->id.vendor = 0x001f;
sparcspkr_dev.id.product = 0x0001; sparcspkr_dev->id.product = 0x0001;
sparcspkr_dev.id.version = 0x0100; sparcspkr_dev->id.version = 0x0100;
} }
static int ebus_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) static int ebus_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
...@@ -84,14 +80,15 @@ static int __init init_ebus_beep(struct linux_ebus_device *edev) ...@@ -84,14 +80,15 @@ static int __init init_ebus_beep(struct linux_ebus_device *edev)
{ {
beep_iobase = edev->resource[0].start; beep_iobase = edev->resource[0].start;
init_sparcspkr_struct(); sparcspkr_dev = input_allocate_device();
if (!sparcspkr_dev)
return -ENOMEM;
sparcspkr_dev.name = sparcspkr_ebus_name; sparcspkr_dev->name = "Sparc EBUS Speaker";
sparcspkr_dev.event = ebus_spkr_event; sparcspkr_dev->event = ebus_spkr_event;
input_register_device(&sparcspkr_dev); input_register_device(sparcspkr_dev);
printk(KERN_INFO "input: %s\n", sparcspkr_ebus_name);
return 0; return 0;
} }
...@@ -137,15 +134,17 @@ static int __init init_isa_beep(struct sparc_isa_device *isa_dev) ...@@ -137,15 +134,17 @@ static int __init init_isa_beep(struct sparc_isa_device *isa_dev)
{ {
beep_iobase = isa_dev->resource.start; beep_iobase = isa_dev->resource.start;
sparcspkr_dev = input_allocate_device();
if (!sparcspkr_dev)
return -ENOMEM;
init_sparcspkr_struct(); init_sparcspkr_struct();
sparcspkr_dev.name = sparcspkr_isa_name; sparcspkr_dev->name = "Sparc ISA Speaker";
sparcspkr_dev.event = isa_spkr_event; sparcspkr_dev->event = isa_spkr_event;
sparcspkr_dev.id.bustype = BUS_ISA;
input_register_device(&sparcspkr_dev); input_register_device(&sparcspkr_dev);
printk(KERN_INFO "input: %s\n", sparcspkr_isa_name);
return 0; return 0;
} }
#endif #endif
...@@ -182,7 +181,7 @@ static int __init sparcspkr_init(void) ...@@ -182,7 +181,7 @@ static int __init sparcspkr_init(void)
static void __exit sparcspkr_exit(void) static void __exit sparcspkr_exit(void)
{ {
input_unregister_device(&sparcspkr_dev); input_unregister_device(sparcspkr_dev);
} }
module_init(sparcspkr_init); module_init(sparcspkr_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment