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
40605d07
Commit
40605d07
authored
Jan 07, 2003
by
Andy Grover
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ACPI: Expose lid state to userspace (Zdenek OGAR Skalak)
parent
e8be7069
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
8 deletions
+57
-8
drivers/acpi/button.c
drivers/acpi/button.c
+57
-8
No files found.
drivers/acpi/button.c
View file @
40605d07
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver"
#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver"
#define ACPI_BUTTON_CLASS "button"
#define ACPI_BUTTON_CLASS "button"
#define ACPI_BUTTON_FILE_INFO "info"
#define ACPI_BUTTON_FILE_INFO "info"
#define ACPI_BUTTON_FILE_STATE "state"
#define ACPI_BUTTON_TYPE_UNKNOWN 0x00
#define ACPI_BUTTON_TYPE_UNKNOWN 0x00
#define ACPI_BUTTON_NOTIFY_STATUS 0x80
#define ACPI_BUTTON_NOTIFY_STATUS 0x80
...
@@ -70,7 +71,8 @@ MODULE_LICENSE("GPL");
...
@@ -70,7 +71,8 @@ MODULE_LICENSE("GPL");
int
acpi_button_add
(
struct
acpi_device
*
device
);
int
acpi_button_add
(
struct
acpi_device
*
device
);
int
acpi_button_remove
(
struct
acpi_device
*
device
,
int
type
);
int
acpi_button_remove
(
struct
acpi_device
*
device
,
int
type
);
static
int
acpi_button_open_fs
(
struct
inode
*
inode
,
struct
file
*
file
);
static
int
acpi_button_info_open_fs
(
struct
inode
*
inode
,
struct
file
*
file
);
static
int
acpi_button_state_open_fs
(
struct
inode
*
inode
,
struct
file
*
file
);
static
struct
acpi_driver
acpi_button_driver
=
{
static
struct
acpi_driver
acpi_button_driver
=
{
.
name
=
ACPI_BUTTON_DRIVER_NAME
,
.
name
=
ACPI_BUTTON_DRIVER_NAME
,
...
@@ -89,24 +91,30 @@ struct acpi_button {
...
@@ -89,24 +91,30 @@ struct acpi_button {
unsigned
long
pushed
;
unsigned
long
pushed
;
};
};
static
struct
file_operations
acpi_button_fops
=
{
static
struct
file_operations
acpi_button_
info_
fops
=
{
.
open
=
acpi_button_open_fs
,
.
open
=
acpi_button_
info_
open_fs
,
.
read
=
seq_read
,
.
read
=
seq_read
,
.
llseek
=
seq_lseek
,
.
llseek
=
seq_lseek
,
.
release
=
single_release
,
.
release
=
single_release
,
};
};
static
struct
file_operations
acpi_button_state_fops
=
{
.
open
=
acpi_button_state_open_fs
,
.
read
=
seq_read
,
.
llseek
=
seq_lseek
,
.
release
=
single_release
,
};
/* --------------------------------------------------------------------------
/* --------------------------------------------------------------------------
FS Interface (/proc)
FS Interface (/proc)
-------------------------------------------------------------------------- */
-------------------------------------------------------------------------- */
static
struct
proc_dir_entry
*
acpi_button_dir
=
NULL
;
static
struct
proc_dir_entry
*
acpi_button_dir
=
NULL
;
static
int
acpi_button_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
=
(
struct
acpi_button
*
)
seq
->
private
;
ACPI_FUNCTION_TRACE
(
"acpi_button_seq_show"
);
ACPI_FUNCTION_TRACE
(
"acpi_button_
info_
seq_show"
);
if
(
!
button
||
!
button
->
device
)
if
(
!
button
||
!
button
->
device
)
return
0
;
return
0
;
...
@@ -117,9 +125,36 @@ static int acpi_button_seq_show(struct seq_file *seq, void *offset)
...
@@ -117,9 +125,36 @@ static int acpi_button_seq_show(struct seq_file *seq, void *offset)
return
0
;
return
0
;
}
}
static
int
acpi_button_open_fs
(
struct
inode
*
inode
,
struct
file
*
file
)
static
int
acpi_button_
info_
open_fs
(
struct
inode
*
inode
,
struct
file
*
file
)
{
{
return
single_open
(
file
,
acpi_button_seq_show
,
PDE
(
inode
)
->
data
);
return
single_open
(
file
,
acpi_button_info_seq_show
,
PDE
(
inode
)
->
data
);
}
static
int
acpi_button_state_seq_show
(
struct
seq_file
*
seq
,
void
*
offset
)
{
struct
acpi_button
*
button
=
(
struct
acpi_button
*
)
seq
->
private
;
acpi_status
status
;
unsigned
long
state
;
ACPI_FUNCTION_TRACE
(
"acpi_button_state_seq_show"
);
if
(
!
button
||
!
button
->
device
)
return
0
;
status
=
acpi_evaluate_integer
(
button
->
handle
,
"_LID"
,
NULL
,
&
state
);
if
(
ACPI_FAILURE
(
status
))
{
seq_printf
(
seq
,
"state: unsupported
\n
"
);
}
else
{
seq_printf
(
seq
,
"state: %lu
\n
"
,
state
);
}
return
0
;
}
static
int
acpi_button_state_open_fs
(
struct
inode
*
inode
,
struct
file
*
file
)
{
return
single_open
(
file
,
acpi_button_state_seq_show
,
PDE
(
inode
)
->
data
);
}
}
static
int
static
int
...
@@ -165,10 +200,24 @@ acpi_button_add_fs (
...
@@ -165,10 +200,24 @@ acpi_button_add_fs (
"Unable to create '%s' fs entry
\n
"
,
"Unable to create '%s' fs entry
\n
"
,
ACPI_BUTTON_FILE_INFO
));
ACPI_BUTTON_FILE_INFO
));
else
{
else
{
entry
->
proc_fops
=
&
acpi_button_fops
;
entry
->
proc_fops
=
&
acpi_button_
info_
fops
;
entry
->
data
=
acpi_driver_data
(
device
);
entry
->
data
=
acpi_driver_data
(
device
);
}
}
/* show lid state [R] */
if
(
button
->
type
==
ACPI_BUTTON_TYPE_LID
)
{
entry
=
create_proc_entry
(
ACPI_BUTTON_FILE_STATE
,
S_IRUGO
,
acpi_device_dir
(
device
));
if
(
!
entry
)
ACPI_DEBUG_PRINT
((
ACPI_DB_ERROR
,
"Unable to create '%s' fs entry
\n
"
,
ACPI_BUTTON_FILE_INFO
));
else
{
entry
->
proc_fops
=
&
acpi_button_state_fops
;
entry
->
data
=
acpi_driver_data
(
device
);
}
}
return_VALUE
(
0
);
return_VALUE
(
0
);
}
}
...
...
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