提交 e5c6c8e4 编写于 作者: M Michael Neuling 提交者: Dmitry Torokhov

Input: pcspkr - separate device and driver registration

The current pcspkr code combines the device and driver registration.
This patch splits these, putting the device registration in the arch
specific code.

PowerPC and MIPS only have the pcspkr present sometimes.
Signed-off-by: NMichael Neuling <mikey@neuling.org>
Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NDmitry Torokhov <dtor@mail.ru>
上级 aaef685d
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/platform_device.h>
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
...@@ -1484,3 +1485,20 @@ alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr) ...@@ -1484,3 +1485,20 @@ alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
#endif #endif
return NOTIFY_DONE; return NOTIFY_DONE;
} }
static __init int add_pcspkr(void)
{
struct platform_device *pd;
int ret;
pd = platform_device_alloc("pcspkr", -1);
if (!pd)
return -ENOMEM;
ret = platform_device_add(pd);
if (ret)
platform_device_put(pd);
return ret;
}
device_initcall(add_pcspkr);
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/initrd.h> #include <linux/initrd.h>
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/platform_device.h>
#include <linux/console.h> #include <linux/console.h>
#include <linux/mca.h> #include <linux/mca.h>
#include <linux/root_dev.h> #include <linux/root_dev.h>
...@@ -1634,6 +1635,23 @@ void __init setup_arch(char **cmdline_p) ...@@ -1634,6 +1635,23 @@ void __init setup_arch(char **cmdline_p)
#endif #endif
} }
static __init int add_pcspkr(void)
{
struct platform_device *pd;
int ret;
pd = platform_device_alloc("pcspkr", -1);
if (!pd)
return -ENOMEM;
ret = platform_device_add(pd);
if (ret)
platform_device_put(pd);
return ret;
}
device_initcall(add_pcspkr);
#include "setup_arch_post.h" #include "setup_arch_post.h"
/* /*
* Local Variables: * Local Variables:
......
...@@ -233,6 +233,7 @@ config MACH_JAZZ ...@@ -233,6 +233,7 @@ config MACH_JAZZ
select ARC32 select ARC32
select ARCH_MAY_HAVE_PC_FDC select ARCH_MAY_HAVE_PC_FDC
select GENERIC_ISA_DMA select GENERIC_ISA_DMA
select I8253
select I8259 select I8259
select ISA select ISA
select SYS_HAS_CPU_R4X00 select SYS_HAS_CPU_R4X00
...@@ -530,6 +531,7 @@ config QEMU ...@@ -530,6 +531,7 @@ config QEMU
select DMA_COHERENT select DMA_COHERENT
select GENERIC_ISA_DMA select GENERIC_ISA_DMA
select HAVE_STD_PC_SERIAL_PORT select HAVE_STD_PC_SERIAL_PORT
select I8253
select I8259 select I8259
select ISA select ISA
select SWAP_IO_SPACE select SWAP_IO_SPACE
...@@ -714,6 +716,7 @@ config SNI_RM200_PCI ...@@ -714,6 +716,7 @@ config SNI_RM200_PCI
select HAVE_STD_PC_SERIAL_PORT select HAVE_STD_PC_SERIAL_PORT
select HW_HAS_EISA select HW_HAS_EISA
select HW_HAS_PCI select HW_HAS_PCI
select I8253
select I8259 select I8259
select ISA select ISA
select SYS_HAS_CPU_R4X00 select SYS_HAS_CPU_R4X00
...@@ -1711,6 +1714,9 @@ config MMU ...@@ -1711,6 +1714,9 @@ config MMU
bool bool
default y default y
config I8253
bool
source "drivers/pcmcia/Kconfig" source "drivers/pcmcia/Kconfig"
source "drivers/pci/hotplug/Kconfig" source "drivers/pci/hotplug/Kconfig"
......
...@@ -59,6 +59,8 @@ obj-$(CONFIG_PROC_FS) += proc.o ...@@ -59,6 +59,8 @@ obj-$(CONFIG_PROC_FS) += proc.o
obj-$(CONFIG_64BIT) += cpu-bugs64.o obj-$(CONFIG_64BIT) += cpu-bugs64.o
obj-$(CONFIG_I8253) += i8253.o
CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi) CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
EXTRA_AFLAGS := $(CFLAGS) EXTRA_AFLAGS := $(CFLAGS)
/*
* Copyright (C) 2006 IBM Corporation
*
* Implements device information for i8253 timer chip
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation
*/
#include <linux/platform_device.h>
static __init int add_pcspkr(void)
{
struct platform_device *pd;
int ret;
pd = platform_device_alloc("pcspkr", -1);
if (!pd)
return -ENOMEM;
ret = platform_device_add(pd);
if (ret)
platform_device_put(pd);
return ret;
}
device_initcall(add_pcspkr);
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/reboot.h> #include <linux/reboot.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/initrd.h> #include <linux/initrd.h>
#include <linux/platform_device.h>
#include <linux/ide.h> #include <linux/ide.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/ioport.h> #include <linux/ioport.h>
...@@ -469,3 +470,26 @@ static int __init early_xmon(char *p) ...@@ -469,3 +470,26 @@ static int __init early_xmon(char *p)
} }
early_param("xmon", early_xmon); early_param("xmon", early_xmon);
#endif #endif
static __init int add_pcspkr(void)
{
struct device_node *np;
struct platform_device *pd;
int ret;
np = of_find_compatible_node(NULL, NULL, "pnpPNP,100");
of_node_put(np);
if (!np)
return -ENODEV;
pd = platform_device_alloc("pcspkr", -1);
if (!pd)
return -ENOMEM;
ret = platform_device_add(pd);
if (ret)
platform_device_put(pd);
return ret;
}
device_initcall(add_pcspkr);
...@@ -24,7 +24,6 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); ...@@ -24,7 +24,6 @@ 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 struct platform_device *pcspkr_platform_device;
static DEFINE_SPINLOCK(i8253_beep_lock); static DEFINE_SPINLOCK(i8253_beep_lock);
static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
...@@ -135,35 +134,11 @@ static struct platform_driver pcspkr_platform_driver = { ...@@ -135,35 +134,11 @@ static struct platform_driver pcspkr_platform_driver = {
static int __init pcspkr_init(void) static int __init pcspkr_init(void)
{ {
int err; return platform_driver_register(&pcspkr_platform_driver);
err = platform_driver_register(&pcspkr_platform_driver);
if (err)
return err;
pcspkr_platform_device = platform_device_alloc("pcspkr", -1);
if (!pcspkr_platform_device) {
err = -ENOMEM;
goto err_unregister_driver;
}
err = platform_device_add(pcspkr_platform_device);
if (err)
goto err_free_device;
return 0;
err_free_device:
platform_device_put(pcspkr_platform_device);
err_unregister_driver:
platform_driver_unregister(&pcspkr_platform_driver);
return err;
} }
static void __exit pcspkr_exit(void) static void __exit pcspkr_exit(void)
{ {
platform_device_unregister(pcspkr_platform_device);
platform_driver_unregister(&pcspkr_platform_driver); platform_driver_unregister(&pcspkr_platform_driver);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册