Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
59317747
Commit
59317747
authored
Dec 21, 2005
by
Dmitry Torokhov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Input: pcspkr - register with driver core as a platfrom device
Signed-off-by:
Dmitry Torokhov
<
dtor@mail.ru
>
parent
1f1a91e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
6 deletions
+80
-6
drivers/input/misc/pcspkr.c
drivers/input/misc/pcspkr.c
+80
-6
No files found.
drivers/input/misc/pcspkr.c
View file @
59317747
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include <linux/module.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/init.h>
#include <linux/input.h>
#include <linux/input.h>
#include <linux/platform_device.h>
#include <asm/8253pit.h>
#include <asm/8253pit.h>
#include <asm/io.h>
#include <asm/io.h>
...
@@ -23,8 +24,7 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
...
@@ -23,8 +24,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
struct
input_dev
*
pcspkr_dev
;
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
)
...
@@ -64,8 +64,11 @@ static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int c
...
@@ -64,8 +64,11 @@ static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int c
return
0
;
return
0
;
}
}
static
int
__
init
pcspkr_init
(
void
)
static
int
__
devinit
pcspkr_probe
(
struct
platform_device
*
dev
)
{
{
struct
input_dev
*
pcspkr_dev
;
int
err
;
pcspkr_dev
=
input_allocate_device
();
pcspkr_dev
=
input_allocate_device
();
if
(
!
pcspkr_dev
)
if
(
!
pcspkr_dev
)
return
-
ENOMEM
;
return
-
ENOMEM
;
...
@@ -76,22 +79,93 @@ static int __init pcspkr_init(void)
...
@@ -76,22 +79,93 @@ static int __init pcspkr_init(void)
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
;
pcspkr_dev
->
cdev
.
dev
=
&
dev
->
dev
;
pcspkr_dev
->
evbit
[
0
]
=
BIT
(
EV_SND
);
pcspkr_dev
->
evbit
[
0
]
=
BIT
(
EV_SND
);
pcspkr_dev
->
sndbit
[
0
]
=
BIT
(
SND_BELL
)
|
BIT
(
SND_TONE
);
pcspkr_dev
->
sndbit
[
0
]
=
BIT
(
SND_BELL
)
|
BIT
(
SND_TONE
);
pcspkr_dev
->
event
=
pcspkr_event
;
pcspkr_dev
->
event
=
pcspkr_event
;
input_register_device
(
pcspkr_dev
);
err
=
input_register_device
(
pcspkr_dev
);
if
(
err
)
{
input_free_device
(
pcspkr_dev
);
return
err
;
}
platform_set_drvdata
(
dev
,
pcspkr_dev
);
return
0
;
return
0
;
}
}
static
void
__exit
pcspkr_exit
(
void
)
static
int
__devexit
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
)
{
pcspkr_event
(
NULL
,
EV_SND
,
SND_BELL
,
0
);
return
0
;
}
static
void
pcspkr_shutdown
(
struct
platform_device
*
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
);
}
}
static
struct
platform_driver
pcspkr_platform_driver
=
{
.
driver
=
{
.
name
=
"pcspkr"
,
.
owner
=
THIS_MODULE
,
},
.
probe
=
pcspkr_probe
,
.
remove
=
__devexit_p
(
pcspkr_remove
),
.
suspend
=
pcspkr_suspend
,
.
shutdown
=
pcspkr_shutdown
,
};
static
int
__init
pcspkr_init
(
void
)
{
int
err
;
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
)
{
platform_device_unregister
(
pcspkr_platform_device
);
platform_driver_unregister
(
&
pcspkr_platform_driver
);
}
module_init
(
pcspkr_init
);
module_init
(
pcspkr_init
);
module_exit
(
pcspkr_exit
);
module_exit
(
pcspkr_exit
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment