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
def3074d
Commit
def3074d
authored
Mar 22, 2004
by
Len Brown
Committed by
Len Brown
Mar 22, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ACPI] toshiba_acpi 0.18 from John Belmonte
add missing copyin
parent
6f50ab9a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
28 deletions
+27
-28
drivers/acpi/toshiba_acpi.c
drivers/acpi/toshiba_acpi.c
+27
-28
No files found.
drivers/acpi/toshiba_acpi.c
View file @
def3074d
...
...
@@ -33,7 +33,7 @@
*
*/
#define TOSHIBA_ACPI_VERSION "0.1
7
"
#define TOSHIBA_ACPI_VERSION "0.1
8
"
#define PROC_INTERFACE_VERSION 1
#include <linux/kernel.h>
...
...
@@ -41,6 +41,7 @@
#include <linux/init.h>
#include <linux/types.h>
#include <linux/proc_fs.h>
#include <asm/uaccess.h>
#include <acpi/acpi_drivers.h>
...
...
@@ -105,24 +106,6 @@ _set_bit(u32* word, u32 mask, int value)
*
word
=
(
*
word
&
~
mask
)
|
(
mask
*
value
);
}
/* an sscanf that takes explicit string length */
static
int
snscanf
(
const
char
*
str
,
int
n
,
const
char
*
format
,
...)
{
va_list
args
;
int
result
;
char
*
str2
=
kmalloc
(
n
+
1
,
GFP_KERNEL
);
if
(
str2
==
0
)
return
0
;
/* NOTE: don't even _think_ about replacing this with strlcpy */
strncpy
(
str2
,
str
,
n
);
str2
[
n
]
=
0
;
va_start
(
args
,
format
);
result
=
vsscanf
(
str2
,
format
,
args
);
va_end
(
args
);
kfree
(
str2
);
return
result
;
}
/* acpi interface wrappers
*/
...
...
@@ -269,10 +252,26 @@ dispatch_read(char* page, char** start, off_t off, int count, int* eof,
}
static
int
dispatch_write
(
struct
file
*
file
,
const
char
*
buffer
,
unsigned
long
count
,
ProcItem
*
item
)
dispatch_write
(
struct
file
*
file
,
__user
const
char
*
buffer
,
unsigned
long
count
,
ProcItem
*
item
)
{
return
item
->
write_func
(
buffer
,
count
);
int
result
;
char
*
tmp_buffer
;
/* Arg buffer points to userspace memory, which can't be accessed
* directly. Since we're making a copy, zero-terminate the
* destination so that sscanf can be used on it safely.
*/
tmp_buffer
=
kmalloc
(
count
+
1
,
GFP_KERNEL
);
if
(
copy_from_user
(
tmp_buffer
,
buffer
,
count
))
{
result
=
-
EFAULT
;
}
else
{
tmp_buffer
[
count
]
=
0
;
result
=
item
->
write_func
(
tmp_buffer
,
count
);
}
kfree
(
tmp_buffer
);
return
result
;
}
static
char
*
...
...
@@ -300,7 +299,7 @@ write_lcd(const char* buffer, unsigned long count)
int
value
;
u32
hci_result
;
if
(
s
nscanf
(
buffer
,
count
,
" brightness : %i"
,
&
value
)
==
1
&&
if
(
s
scanf
(
buffer
,
" brightness : %i"
,
&
value
)
==
1
&&
value
>=
0
&&
value
<
HCI_LCD_BRIGHTNESS_LEVELS
)
{
value
=
value
<<
HCI_LCD_BRIGHTNESS_SHIFT
;
hci_write1
(
HCI_LCD_BRIGHTNESS
,
value
,
&
hci_result
);
...
...
@@ -350,11 +349,11 @@ write_video(const char* buffer, unsigned long count)
* NOTE: to keep scanning simple, invalid fields are ignored
*/
while
(
remain
)
{
if
(
s
nscanf
(
buffer
,
remain
,
" lcd_out : %i"
,
&
value
)
==
1
)
if
(
s
scanf
(
buffer
,
" lcd_out : %i"
,
&
value
)
==
1
)
lcd_out
=
value
&
1
;
else
if
(
s
nscanf
(
buffer
,
remain
,
" crt_out : %i"
,
&
value
)
==
1
)
else
if
(
s
scanf
(
buffer
,
" crt_out : %i"
,
&
value
)
==
1
)
crt_out
=
value
&
1
;
else
if
(
s
nscanf
(
buffer
,
remain
,
" tv_out : %i"
,
&
value
)
==
1
)
else
if
(
s
scanf
(
buffer
,
" tv_out : %i"
,
&
value
)
==
1
)
tv_out
=
value
&
1
;
/* advance to one character past the next ; */
do
{
...
...
@@ -407,7 +406,7 @@ write_fan(const char* buffer, unsigned long count)
int
value
;
u32
hci_result
;
if
(
s
nscanf
(
buffer
,
count
,
" force_on : %i"
,
&
value
)
==
1
&&
if
(
s
scanf
(
buffer
,
" force_on : %i"
,
&
value
)
==
1
&&
value
>=
0
&&
value
<=
1
)
{
hci_write1
(
HCI_FAN
,
value
,
&
hci_result
);
if
(
hci_result
!=
HCI_SUCCESS
)
...
...
@@ -458,7 +457,7 @@ write_keys(const char* buffer, unsigned long count)
{
int
value
;
if
(
s
nscanf
(
buffer
,
count
,
" hotkey_ready : %i"
,
&
value
)
==
1
&&
if
(
s
scanf
(
buffer
,
" hotkey_ready : %i"
,
&
value
)
==
1
&&
value
==
0
)
{
key_event_valid
=
0
;
}
else
{
...
...
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