Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-davinci-2.6.23
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linux
linux-davinci-2.6.23
Commits
b3617350
Commit
b3617350
authored
Dec 16, 2006
by
Len Brown
Browse files
Options
Browse Files
Download
Plain Diff
Pull button into test branch
parents
fb766554
c0968f0e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
139 additions
and
85 deletions
+139
-85
drivers/acpi/Kconfig
drivers/acpi/Kconfig
+1
-0
drivers/acpi/button.c
drivers/acpi/button.c
+138
-85
No files found.
drivers/acpi/Kconfig
View file @
b3617350
...
@@ -97,6 +97,7 @@ config ACPI_BATTERY
...
@@ -97,6 +97,7 @@ config ACPI_BATTERY
config ACPI_BUTTON
config ACPI_BUTTON
tristate "Button"
tristate "Button"
depends on INPUT
default y
default y
help
help
This driver handles events on the power, sleep and lid buttons.
This driver handles events on the power, sleep and lid buttons.
...
...
drivers/acpi/button.c
View file @
b3617350
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#include <linux/types.h>
#include <linux/types.h>
#include <linux/proc_fs.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/seq_file.h>
#include <linux/input.h>
#include <acpi/acpi_bus.h>
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
#include <acpi/acpi_drivers.h>
...
@@ -62,7 +63,7 @@
...
@@ -62,7 +63,7 @@
#define _COMPONENT ACPI_BUTTON_COMPONENT
#define _COMPONENT ACPI_BUTTON_COMPONENT
ACPI_MODULE_NAME
(
"acpi_button"
)
ACPI_MODULE_NAME
(
"acpi_button"
)
MODULE_AUTHOR
(
"Paul Diefenbaugh"
);
MODULE_AUTHOR
(
"Paul Diefenbaugh"
);
MODULE_DESCRIPTION
(
ACPI_BUTTON_DRIVER_NAME
);
MODULE_DESCRIPTION
(
ACPI_BUTTON_DRIVER_NAME
);
MODULE_LICENSE
(
"GPL"
);
MODULE_LICENSE
(
"GPL"
);
...
@@ -83,7 +84,9 @@ static struct acpi_driver acpi_button_driver = {
...
@@ -83,7 +84,9 @@ static struct acpi_driver acpi_button_driver = {
struct
acpi_button
{
struct
acpi_button
{
struct
acpi_device
*
device
;
/* Fixed button kludge */
struct
acpi_device
*
device
;
/* Fixed button kludge */
u8
type
;
unsigned
int
type
;
struct
input_dev
*
input
;
char
phys
[
32
];
/* for input device */
unsigned
long
pushed
;
unsigned
long
pushed
;
};
};
...
@@ -109,8 +112,7 @@ static struct proc_dir_entry *acpi_button_dir;
...
@@ -109,8 +112,7 @@ static struct proc_dir_entry *acpi_button_dir;
static
int
acpi_button_info_seq_show
(
struct
seq_file
*
seq
,
void
*
offset
)
static
int
acpi_button_info_seq_show
(
struct
seq_file
*
seq
,
void
*
offset
)
{
{
struct
acpi_button
*
button
=
(
struct
acpi_button
*
)
seq
->
private
;
struct
acpi_button
*
button
=
seq
->
private
;
if
(
!
button
||
!
button
->
device
)
if
(
!
button
||
!
button
->
device
)
return
0
;
return
0
;
...
@@ -128,22 +130,17 @@ static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
...
@@ -128,22 +130,17 @@ static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
static
int
acpi_button_state_seq_show
(
struct
seq_file
*
seq
,
void
*
offset
)
static
int
acpi_button_state_seq_show
(
struct
seq_file
*
seq
,
void
*
offset
)
{
{
struct
acpi_button
*
button
=
(
struct
acpi_button
*
)
seq
->
private
;
struct
acpi_button
*
button
=
seq
->
private
;
acpi_status
status
;
acpi_status
status
;
unsigned
long
state
;
unsigned
long
state
;
if
(
!
button
||
!
button
->
device
)
if
(
!
button
||
!
button
->
device
)
return
0
;
return
0
;
status
=
acpi_evaluate_integer
(
button
->
device
->
handle
,
"_LID"
,
NULL
,
&
state
);
status
=
acpi_evaluate_integer
(
button
->
device
->
handle
,
"_LID"
,
NULL
,
&
state
);
if
(
ACPI_FAILURE
(
status
))
{
seq_printf
(
seq
,
"state: unsupported
\n
"
);
}
else
{
seq_printf
(
seq
,
"state: %s
\n
"
,
seq_printf
(
seq
,
"state: %s
\n
"
,
ACPI_FAILURE
(
status
)
?
"unsupported"
:
(
state
?
"open"
:
"closed"
));
(
state
?
"open"
:
"closed"
));
}
return
0
;
return
0
;
}
}
...
@@ -159,8 +156,7 @@ static struct proc_dir_entry *acpi_lid_dir;
...
@@ -159,8 +156,7 @@ static struct proc_dir_entry *acpi_lid_dir;
static
int
acpi_button_add_fs
(
struct
acpi_device
*
device
)
static
int
acpi_button_add_fs
(
struct
acpi_device
*
device
)
{
{
struct
proc_dir_entry
*
entry
=
NULL
;
struct
proc_dir_entry
*
entry
=
NULL
;
struct
acpi_button
*
button
=
NULL
;
struct
acpi_button
*
button
;
if
(
!
device
||
!
acpi_driver_data
(
device
))
if
(
!
device
||
!
acpi_driver_data
(
device
))
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -228,10 +224,8 @@ static int acpi_button_add_fs(struct acpi_device *device)
...
@@ -228,10 +224,8 @@ static int acpi_button_add_fs(struct acpi_device *device)
static
int
acpi_button_remove_fs
(
struct
acpi_device
*
device
)
static
int
acpi_button_remove_fs
(
struct
acpi_device
*
device
)
{
{
struct
acpi_button
*
button
=
NULL
;
struct
acpi_button
*
button
=
acpi_driver_data
(
device
);
button
=
acpi_driver_data
(
device
);
if
(
acpi_device_dir
(
device
))
{
if
(
acpi_device_dir
(
device
))
{
if
(
button
->
type
==
ACPI_BUTTON_TYPE_LID
)
if
(
button
->
type
==
ACPI_BUTTON_TYPE_LID
)
remove_proc_entry
(
ACPI_BUTTON_FILE_STATE
,
remove_proc_entry
(
ACPI_BUTTON_FILE_STATE
,
...
@@ -253,14 +247,34 @@ static int acpi_button_remove_fs(struct acpi_device *device)
...
@@ -253,14 +247,34 @@ static int acpi_button_remove_fs(struct acpi_device *device)
static
void
acpi_button_notify
(
acpi_handle
handle
,
u32
event
,
void
*
data
)
static
void
acpi_button_notify
(
acpi_handle
handle
,
u32
event
,
void
*
data
)
{
{
struct
acpi_button
*
button
=
(
struct
acpi_button
*
)
data
;
struct
acpi_button
*
button
=
data
;
struct
input_dev
*
input
;
if
(
!
button
||
!
button
->
device
)
if
(
!
button
||
!
button
->
device
)
return
;
return
;
switch
(
event
)
{
switch
(
event
)
{
case
ACPI_BUTTON_NOTIFY_STATUS
:
case
ACPI_BUTTON_NOTIFY_STATUS
:
input
=
button
->
input
;
if
(
button
->
type
==
ACPI_BUTTON_TYPE_LID
)
{
struct
acpi_handle
*
handle
=
button
->
device
->
handle
;
unsigned
long
state
;
if
(
!
ACPI_FAILURE
(
acpi_evaluate_integer
(
handle
,
"_LID"
,
NULL
,
&
state
)))
input_report_switch
(
input
,
SW_LID
,
!
state
);
}
else
{
int
keycode
=
test_bit
(
KEY_SLEEP
,
input
->
keybit
)
?
KEY_SLEEP
:
KEY_POWER
;
input_report_key
(
input
,
keycode
,
1
);
input_sync
(
input
);
input_report_key
(
input
,
keycode
,
0
);
}
input_sync
(
input
);
acpi_bus_generate_event
(
button
->
device
,
event
,
acpi_bus_generate_event
(
button
->
device
,
event
,
++
button
->
pushed
);
++
button
->
pushed
);
break
;
break
;
...
@@ -275,8 +289,7 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
...
@@ -275,8 +289,7 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
static
acpi_status
acpi_button_notify_fixed
(
void
*
data
)
static
acpi_status
acpi_button_notify_fixed
(
void
*
data
)
{
{
struct
acpi_button
*
button
=
(
struct
acpi_button
*
)
data
;
struct
acpi_button
*
button
=
data
;
if
(
!
button
)
if
(
!
button
)
return
AE_BAD_PARAMETER
;
return
AE_BAD_PARAMETER
;
...
@@ -286,24 +299,75 @@ static acpi_status acpi_button_notify_fixed(void *data)
...
@@ -286,24 +299,75 @@ static acpi_status acpi_button_notify_fixed(void *data)
return
AE_OK
;
return
AE_OK
;
}
}
static
int
acpi_button_add
(
struct
acpi_device
*
device
)
static
int
acpi_button_install_notify_handlers
(
struct
acpi_button
*
button
)
{
acpi_status
status
;
switch
(
button
->
type
)
{
case
ACPI_BUTTON_TYPE_POWERF
:
status
=
acpi_install_fixed_event_handler
(
ACPI_EVENT_POWER_BUTTON
,
acpi_button_notify_fixed
,
button
);
break
;
case
ACPI_BUTTON_TYPE_SLEEPF
:
status
=
acpi_install_fixed_event_handler
(
ACPI_EVENT_SLEEP_BUTTON
,
acpi_button_notify_fixed
,
button
);
break
;
default:
status
=
acpi_install_notify_handler
(
button
->
device
->
handle
,
ACPI_DEVICE_NOTIFY
,
acpi_button_notify
,
button
);
break
;
}
return
ACPI_FAILURE
(
status
)
?
-
ENODEV
:
0
;
}
static
void
acpi_button_remove_notify_handlers
(
struct
acpi_button
*
button
)
{
{
int
result
=
0
;
switch
(
button
->
type
)
{
acpi_status
status
=
AE_OK
;
case
ACPI_BUTTON_TYPE_POWERF
:
struct
acpi_button
*
button
=
NULL
;
acpi_remove_fixed_event_handler
(
ACPI_EVENT_POWER_BUTTON
,
acpi_button_notify_fixed
);
break
;
case
ACPI_BUTTON_TYPE_SLEEPF
:
acpi_remove_fixed_event_handler
(
ACPI_EVENT_SLEEP_BUTTON
,
acpi_button_notify_fixed
);
break
;
default:
acpi_remove_notify_handler
(
button
->
device
->
handle
,
ACPI_DEVICE_NOTIFY
,
acpi_button_notify
);
break
;
}
}
static
int
acpi_button_add
(
struct
acpi_device
*
device
)
{
int
error
;
struct
acpi_button
*
button
;
struct
input_dev
*
input
;
if
(
!
device
)
if
(
!
device
)
return
-
EINVAL
;
return
-
EINVAL
;
button
=
k
m
alloc
(
sizeof
(
struct
acpi_button
),
GFP_KERNEL
);
button
=
k
z
alloc
(
sizeof
(
struct
acpi_button
),
GFP_KERNEL
);
if
(
!
button
)
if
(
!
button
)
return
-
ENOMEM
;
return
-
ENOMEM
;
memset
(
button
,
0
,
sizeof
(
struct
acpi_button
));
button
->
device
=
device
;
button
->
device
=
device
;
acpi_driver_data
(
device
)
=
button
;
acpi_driver_data
(
device
)
=
button
;
button
->
input
=
input
=
input_allocate_device
();
if
(
!
input
)
{
error
=
-
ENOMEM
;
goto
err_free_button
;
}
/*
/*
* Determine the button type (via hid), as fixed-feature buttons
* Determine the button type (via hid), as fixed-feature buttons
* need to be handled a bit differently than generic-space.
* need to be handled a bit differently than generic-space.
...
@@ -338,39 +402,48 @@ static int acpi_button_add(struct acpi_device *device)
...
@@ -338,39 +402,48 @@ static int acpi_button_add(struct acpi_device *device)
}
else
{
}
else
{
printk
(
KERN_ERR
PREFIX
"Unsupported hid [%s]
\n
"
,
printk
(
KERN_ERR
PREFIX
"Unsupported hid [%s]
\n
"
,
acpi_device_hid
(
device
));
acpi_device_hid
(
device
));
result
=
-
ENODEV
;
error
=
-
ENODEV
;
goto
e
nd
;
goto
e
rr_free_input
;
}
}
result
=
acpi_button_add_fs
(
device
);
error
=
acpi_button_add_fs
(
device
);
if
(
result
)
if
(
error
)
goto
end
;
goto
err_free_input
;
error
=
acpi_button_install_notify_handlers
(
button
);
if
(
error
)
goto
err_remove_fs
;
snprintf
(
button
->
phys
,
sizeof
(
button
->
phys
),
"%s/button/input0"
,
acpi_device_hid
(
device
));
input
->
name
=
acpi_device_name
(
device
);
input
->
phys
=
button
->
phys
;
input
->
id
.
bustype
=
BUS_HOST
;
input
->
id
.
product
=
button
->
type
;
switch
(
button
->
type
)
{
switch
(
button
->
type
)
{
case
ACPI_BUTTON_TYPE_POWER
:
case
ACPI_BUTTON_TYPE_POWERF
:
case
ACPI_BUTTON_TYPE_POWERF
:
status
=
input
->
evbit
[
0
]
=
BIT
(
EV_KEY
);
acpi_install_fixed_event_handler
(
ACPI_EVENT_POWER_BUTTON
,
set_bit
(
KEY_POWER
,
input
->
keybit
);
acpi_button_notify_fixed
,
button
);
break
;
break
;
case
ACPI_BUTTON_TYPE_SLEEP
:
case
ACPI_BUTTON_TYPE_SLEEPF
:
case
ACPI_BUTTON_TYPE_SLEEPF
:
status
=
input
->
evbit
[
0
]
=
BIT
(
EV_KEY
);
acpi_install_fixed_event_handler
(
ACPI_EVENT_SLEEP_BUTTON
,
set_bit
(
KEY_SLEEP
,
input
->
keybit
);
acpi_button_notify_fixed
,
button
);
break
;
break
;
default:
status
=
acpi_install_notify_handler
(
device
->
handle
,
case
ACPI_BUTTON_TYPE_LID
:
ACPI_DEVICE_NOTIFY
,
input
->
evbit
[
0
]
=
BIT
(
EV_SW
);
acpi_button_notify
,
set_bit
(
SW_LID
,
input
->
swbit
);
button
);
break
;
break
;
}
}
if
(
ACPI_FAILURE
(
status
))
{
error
=
input_register_device
(
input
);
result
=
-
ENODEV
;
if
(
error
)
goto
end
;
goto
err_remove_handlers
;
}
if
(
device
->
wakeup
.
flags
.
valid
)
{
if
(
device
->
wakeup
.
flags
.
valid
)
{
/* Button's GPE is run-wake GPE */
/* Button's GPE is run-wake GPE */
...
@@ -385,47 +458,31 @@ static int acpi_button_add(struct acpi_device *device)
...
@@ -385,47 +458,31 @@ static int acpi_button_add(struct acpi_device *device)
printk
(
KERN_INFO
PREFIX
"%s [%s]
\n
"
,
printk
(
KERN_INFO
PREFIX
"%s [%s]
\n
"
,
acpi_device_name
(
device
),
acpi_device_bid
(
device
));
acpi_device_name
(
device
),
acpi_device_bid
(
device
));
end:
return
0
;
if
(
result
)
{
err_remove_handlers:
acpi_button_remove_notify_handlers
(
button
);
err_remove_fs:
acpi_button_remove_fs
(
device
);
acpi_button_remove_fs
(
device
);
err_free_input:
input_free_device
(
input
);
err_free_button:
kfree
(
button
);
kfree
(
button
);
}
return
error
;
return
result
;
}
}
static
int
acpi_button_remove
(
struct
acpi_device
*
device
,
int
type
)
static
int
acpi_button_remove
(
struct
acpi_device
*
device
,
int
type
)
{
{
acpi_status
status
=
0
;
struct
acpi_button
*
button
;
struct
acpi_button
*
button
=
NULL
;
if
(
!
device
||
!
acpi_driver_data
(
device
))
if
(
!
device
||
!
acpi_driver_data
(
device
))
return
-
EINVAL
;
return
-
EINVAL
;
button
=
acpi_driver_data
(
device
);
button
=
acpi_driver_data
(
device
);
/* Unregister for device notifications. */
acpi_button_remove_notify_handlers
(
button
);
switch
(
button
->
type
)
{
case
ACPI_BUTTON_TYPE_POWERF
:
status
=
acpi_remove_fixed_event_handler
(
ACPI_EVENT_POWER_BUTTON
,
acpi_button_notify_fixed
);
break
;
case
ACPI_BUTTON_TYPE_SLEEPF
:
status
=
acpi_remove_fixed_event_handler
(
ACPI_EVENT_SLEEP_BUTTON
,
acpi_button_notify_fixed
);
break
;
default:
status
=
acpi_remove_notify_handler
(
device
->
handle
,
ACPI_DEVICE_NOTIFY
,
acpi_button_notify
);
break
;
}
acpi_button_remove_fs
(
device
);
acpi_button_remove_fs
(
device
);
input_unregister_device
(
button
->
input
);
kfree
(
button
);
kfree
(
button
);
return
0
;
return
0
;
...
@@ -433,8 +490,7 @@ static int acpi_button_remove(struct acpi_device *device, int type)
...
@@ -433,8 +490,7 @@ static int acpi_button_remove(struct acpi_device *device, int type)
static
int
__init
acpi_button_init
(
void
)
static
int
__init
acpi_button_init
(
void
)
{
{
int
result
=
0
;
int
result
;
acpi_button_dir
=
proc_mkdir
(
ACPI_BUTTON_CLASS
,
acpi_root_dir
);
acpi_button_dir
=
proc_mkdir
(
ACPI_BUTTON_CLASS
,
acpi_root_dir
);
if
(
!
acpi_button_dir
)
if
(
!
acpi_button_dir
)
...
@@ -451,7 +507,6 @@ static int __init acpi_button_init(void)
...
@@ -451,7 +507,6 @@ static int __init acpi_button_init(void)
static
void
__exit
acpi_button_exit
(
void
)
static
void
__exit
acpi_button_exit
(
void
)
{
{
acpi_bus_unregister_driver
(
&
acpi_button_driver
);
acpi_bus_unregister_driver
(
&
acpi_button_driver
);
if
(
acpi_power_dir
)
if
(
acpi_power_dir
)
...
@@ -461,8 +516,6 @@ static void __exit acpi_button_exit(void)
...
@@ -461,8 +516,6 @@ static void __exit acpi_button_exit(void)
if
(
acpi_lid_dir
)
if
(
acpi_lid_dir
)
remove_proc_entry
(
ACPI_BUTTON_SUBCLASS_LID
,
acpi_button_dir
);
remove_proc_entry
(
ACPI_BUTTON_SUBCLASS_LID
,
acpi_button_dir
);
remove_proc_entry
(
ACPI_BUTTON_CLASS
,
acpi_root_dir
);
remove_proc_entry
(
ACPI_BUTTON_CLASS
,
acpi_root_dir
);
return
;
}
}
module_init
(
acpi_button_init
);
module_init
(
acpi_button_init
);
...
...
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