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
152c12f5
Commit
152c12f5
authored
Jun 30, 2005
by
Dmitry Torokhov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Input: clean up uinput driver (formatting, extra braces)
Signed-off-by:
Dmitry Torokhov
<
dtor@mail.ru
>
parent
9b4311ee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
46 deletions
+35
-46
drivers/input/misc/uinput.c
drivers/input/misc/uinput.c
+35
-46
No files found.
drivers/input/misc/uinput.c
View file @
152c12f5
...
@@ -36,16 +36,6 @@
...
@@ -36,16 +36,6 @@
#include <linux/miscdevice.h>
#include <linux/miscdevice.h>
#include <linux/uinput.h>
#include <linux/uinput.h>
static
int
uinput_dev_open
(
struct
input_dev
*
dev
)
{
return
0
;
}
static
void
uinput_dev_close
(
struct
input_dev
*
dev
)
{
}
static
int
uinput_dev_event
(
struct
input_dev
*
dev
,
unsigned
int
type
,
unsigned
int
code
,
int
value
)
static
int
uinput_dev_event
(
struct
input_dev
*
dev
,
unsigned
int
type
,
unsigned
int
code
,
int
value
)
{
{
struct
uinput_device
*
udev
;
struct
uinput_device
*
udev
;
...
@@ -68,17 +58,20 @@ static int uinput_request_alloc_id(struct input_dev *dev, struct uinput_request
...
@@ -68,17 +58,20 @@ static int uinput_request_alloc_id(struct input_dev *dev, struct uinput_request
/* Atomically allocate an ID for the given request. Returns 0 on success. */
/* Atomically allocate an ID for the given request. Returns 0 on success. */
struct
uinput_device
*
udev
=
dev
->
private
;
struct
uinput_device
*
udev
=
dev
->
private
;
int
id
;
int
id
;
int
err
=
-
1
;
down
(
&
udev
->
requests_sem
);
down
(
&
udev
->
requests_sem
);
for
(
id
=
0
;
id
<
UINPUT_NUM_REQUESTS
;
id
++
)
for
(
id
=
0
;
id
<
UINPUT_NUM_REQUESTS
;
id
++
)
if
(
!
udev
->
requests
[
id
])
{
if
(
!
udev
->
requests
[
id
])
{
udev
->
requests
[
id
]
=
request
;
udev
->
requests
[
id
]
=
request
;
request
->
id
=
id
;
request
->
id
=
id
;
up
(
&
udev
->
requests_sem
)
;
err
=
0
;
return
0
;
break
;
}
}
up
(
&
udev
->
requests_sem
);
up
(
&
udev
->
requests_sem
);
return
-
1
;
return
err
;
}
}
static
struct
uinput_request
*
uinput_request_find
(
struct
uinput_device
*
udev
,
int
id
)
static
struct
uinput_request
*
uinput_request_find
(
struct
uinput_device
*
udev
,
int
id
)
...
@@ -101,7 +94,7 @@ static void uinput_request_init(struct input_dev *dev, struct uinput_request *re
...
@@ -101,7 +94,7 @@ static void uinput_request_init(struct input_dev *dev, struct uinput_request *re
/* Allocate an ID. If none are available right away, wait. */
/* Allocate an ID. If none are available right away, wait. */
request
->
retval
=
wait_event_interruptible
(
udev
->
requests_waitq
,
request
->
retval
=
wait_event_interruptible
(
udev
->
requests_waitq
,
!
uinput_request_alloc_id
(
dev
,
request
));
!
uinput_request_alloc_id
(
dev
,
request
));
}
}
static
void
uinput_request_submit
(
struct
input_dev
*
dev
,
struct
uinput_request
*
request
)
static
void
uinput_request_submit
(
struct
input_dev
*
dev
,
struct
uinput_request
*
request
)
...
@@ -159,32 +152,30 @@ static int uinput_create_device(struct uinput_device *udev)
...
@@ -159,32 +152,30 @@ static int uinput_create_device(struct uinput_device *udev)
return
-
EINVAL
;
return
-
EINVAL
;
}
}
udev
->
dev
->
open
=
uinput_dev_open
;
udev
->
dev
->
close
=
uinput_dev_close
;
udev
->
dev
->
event
=
uinput_dev_event
;
udev
->
dev
->
event
=
uinput_dev_event
;
udev
->
dev
->
upload_effect
=
uinput_dev_upload_effect
;
udev
->
dev
->
upload_effect
=
uinput_dev_upload_effect
;
udev
->
dev
->
erase_effect
=
uinput_dev_erase_effect
;
udev
->
dev
->
erase_effect
=
uinput_dev_erase_effect
;
udev
->
dev
->
private
=
udev
;
udev
->
dev
->
private
=
udev
;
init_waitqueue_head
(
&
(
udev
->
waitq
)
);
init_waitqueue_head
(
&
udev
->
waitq
);
input_register_device
(
udev
->
dev
);
input_register_device
(
udev
->
dev
);
set_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
);
set_bit
(
UIST_CREATED
,
&
udev
->
state
);
return
0
;
return
0
;
}
}
static
int
uinput_destroy_device
(
struct
uinput_device
*
udev
)
static
int
uinput_destroy_device
(
struct
uinput_device
*
udev
)
{
{
if
(
!
test_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
))
{
if
(
!
test_bit
(
UIST_CREATED
,
&
udev
->
state
))
{
printk
(
KERN_WARNING
"%s: create the device first
\n
"
,
UINPUT_NAME
);
printk
(
KERN_WARNING
"%s: create the device first
\n
"
,
UINPUT_NAME
);
return
-
EINVAL
;
return
-
EINVAL
;
}
}
input_unregister_device
(
udev
->
dev
);
input_unregister_device
(
udev
->
dev
);
clear_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
);
clear_bit
(
UIST_CREATED
,
&
udev
->
state
);
return
0
;
return
0
;
}
}
...
@@ -253,15 +244,15 @@ static int uinput_alloc_device(struct file *file, const char __user *buffer, siz
...
@@ -253,15 +244,15 @@ static int uinput_alloc_device(struct file *file, const char __user *buffer, siz
struct
uinput_user_dev
*
user_dev
;
struct
uinput_user_dev
*
user_dev
;
struct
input_dev
*
dev
;
struct
input_dev
*
dev
;
struct
uinput_device
*
udev
;
struct
uinput_device
*
udev
;
int
size
,
int
size
;
retval
;
int
retval
;
retval
=
count
;
retval
=
count
;
udev
=
file
->
private_data
;
udev
=
file
->
private_data
;
dev
=
udev
->
dev
;
dev
=
udev
->
dev
;
user_dev
=
kmalloc
(
sizeof
(
*
user_dev
),
GFP_KERNEL
);
user_dev
=
kmalloc
(
sizeof
(
struct
uinput_
user_dev
),
GFP_KERNEL
);
if
(
!
user_dev
)
{
if
(
!
user_dev
)
{
retval
=
-
ENOMEM
;
retval
=
-
ENOMEM
;
goto
exit
;
goto
exit
;
...
@@ -272,7 +263,7 @@ static int uinput_alloc_device(struct file *file, const char __user *buffer, siz
...
@@ -272,7 +263,7 @@ static int uinput_alloc_device(struct file *file, const char __user *buffer, siz
goto
exit
;
goto
exit
;
}
}
if
(
NULL
!=
dev
->
name
)
if
(
dev
->
name
)
kfree
(
dev
->
name
);
kfree
(
dev
->
name
);
size
=
strnlen
(
user_dev
->
name
,
UINPUT_MAX_NAME_SIZE
)
+
1
;
size
=
strnlen
(
user_dev
->
name
,
UINPUT_MAX_NAME_SIZE
)
+
1
;
...
@@ -314,14 +305,13 @@ static ssize_t uinput_write(struct file *file, const char __user *buffer, size_t
...
@@ -314,14 +305,13 @@ static ssize_t uinput_write(struct file *file, const char __user *buffer, size_t
{
{
struct
uinput_device
*
udev
=
file
->
private_data
;
struct
uinput_device
*
udev
=
file
->
private_data
;
if
(
test_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
))
{
if
(
test_bit
(
UIST_CREATED
,
&
udev
->
state
))
{
struct
input_event
ev
;
struct
input_event
ev
;
if
(
copy_from_user
(
&
ev
,
buffer
,
sizeof
(
struct
input_event
)))
if
(
copy_from_user
(
&
ev
,
buffer
,
sizeof
(
struct
input_event
)))
return
-
EFAULT
;
return
-
EFAULT
;
input_event
(
udev
->
dev
,
ev
.
type
,
ev
.
code
,
ev
.
value
);
input_event
(
udev
->
dev
,
ev
.
type
,
ev
.
code
,
ev
.
value
);
}
}
else
else
count
=
uinput_alloc_device
(
file
,
buffer
,
count
);
count
=
uinput_alloc_device
(
file
,
buffer
,
count
);
return
count
;
return
count
;
...
@@ -332,26 +322,24 @@ static ssize_t uinput_read(struct file *file, char __user *buffer, size_t count,
...
@@ -332,26 +322,24 @@ static ssize_t uinput_read(struct file *file, char __user *buffer, size_t count,
struct
uinput_device
*
udev
=
file
->
private_data
;
struct
uinput_device
*
udev
=
file
->
private_data
;
int
retval
=
0
;
int
retval
=
0
;
if
(
!
test_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
))
if
(
!
test_bit
(
UIST_CREATED
,
&
udev
->
state
))
return
-
ENODEV
;
return
-
ENODEV
;
if
(
(
udev
->
head
==
udev
->
tail
)
&&
(
file
->
f_flags
&
O_NONBLOCK
))
if
(
udev
->
head
==
udev
->
tail
&&
(
file
->
f_flags
&
O_NONBLOCK
))
return
-
EAGAIN
;
return
-
EAGAIN
;
retval
=
wait_event_interruptible
(
udev
->
waitq
,
retval
=
wait_event_interruptible
(
udev
->
waitq
,
(
udev
->
head
!=
udev
->
tail
)
||
udev
->
head
!=
udev
->
tail
||
!
test_bit
(
UIST_CREATED
,
&
udev
->
state
));
!
test_bit
(
UIST_CREATED
,
&
(
udev
->
state
)));
if
(
retval
)
if
(
retval
)
return
retval
;
return
retval
;
if
(
!
test_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
))
if
(
!
test_bit
(
UIST_CREATED
,
&
udev
->
state
))
return
-
ENODEV
;
return
-
ENODEV
;
while
((
udev
->
head
!=
udev
->
tail
)
&&
while
((
udev
->
head
!=
udev
->
tail
)
&&
(
retval
+
sizeof
(
struct
input_event
)
<=
count
))
{
(
retval
+
sizeof
(
struct
input_event
)
<=
count
))
{
if
(
copy_to_user
(
buffer
+
retval
,
&
(
udev
->
buff
[
udev
->
tail
]),
if
(
copy_to_user
(
buffer
+
retval
,
&
udev
->
buff
[
udev
->
tail
],
sizeof
(
struct
input_event
)))
sizeof
(
struct
input_event
)))
return
-
EFAULT
;
return
-
EFAULT
;
udev
->
tail
=
(
udev
->
tail
+
1
)
%
UINPUT_BUFFER_SIZE
;
udev
->
tail
=
(
udev
->
tail
+
1
)
%
UINPUT_BUFFER_SIZE
;
retval
+=
sizeof
(
struct
input_event
);
retval
+=
sizeof
(
struct
input_event
);
}
}
...
@@ -373,12 +361,12 @@ static unsigned int uinput_poll(struct file *file, poll_table *wait)
...
@@ -373,12 +361,12 @@ static unsigned int uinput_poll(struct file *file, poll_table *wait)
static
int
uinput_burn_device
(
struct
uinput_device
*
udev
)
static
int
uinput_burn_device
(
struct
uinput_device
*
udev
)
{
{
if
(
test_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
))
if
(
test_bit
(
UIST_CREATED
,
&
udev
->
state
))
uinput_destroy_device
(
udev
);
uinput_destroy_device
(
udev
);
if
(
NULL
!=
udev
->
dev
->
name
)
if
(
udev
->
dev
->
name
)
kfree
(
udev
->
dev
->
name
);
kfree
(
udev
->
dev
->
name
);
if
(
NULL
!=
udev
->
dev
->
phys
)
if
(
udev
->
dev
->
phys
)
kfree
(
udev
->
dev
->
phys
);
kfree
(
udev
->
dev
->
phys
);
kfree
(
udev
->
dev
);
kfree
(
udev
->
dev
);
...
@@ -389,7 +377,8 @@ static int uinput_burn_device(struct uinput_device *udev)
...
@@ -389,7 +377,8 @@ static int uinput_burn_device(struct uinput_device *udev)
static
int
uinput_close
(
struct
inode
*
inode
,
struct
file
*
file
)
static
int
uinput_close
(
struct
inode
*
inode
,
struct
file
*
file
)
{
{
return
uinput_burn_device
(
file
->
private_data
);
uinput_burn_device
(
file
->
private_data
);
return
0
;
}
}
static
int
uinput_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
)
static
int
uinput_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
)
...
@@ -415,7 +404,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
...
@@ -415,7 +404,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
case
UI_SET_SNDBIT
:
case
UI_SET_SNDBIT
:
case
UI_SET_FFBIT
:
case
UI_SET_FFBIT
:
case
UI_SET_PHYS
:
case
UI_SET_PHYS
:
if
(
test_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
))
if
(
test_bit
(
UIST_CREATED
,
&
udev
->
state
))
return
-
EINVAL
;
return
-
EINVAL
;
}
}
...
@@ -511,7 +500,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
...
@@ -511,7 +500,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
udev
->
dev
->
phys
=
NULL
;
udev
->
dev
->
phys
=
NULL
;
break
;
break
;
}
}
udev
->
dev
->
phys
[
length
-
1
]
=
'\0'
;
udev
->
dev
->
phys
[
length
-
1
]
=
'\0'
;
break
;
break
;
case
UI_BEGIN_FF_UPLOAD
:
case
UI_BEGIN_FF_UPLOAD
:
...
@@ -520,7 +509,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
...
@@ -520,7 +509,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
break
;
break
;
}
}
req
=
uinput_request_find
(
udev
,
ff_up
.
request_id
);
req
=
uinput_request_find
(
udev
,
ff_up
.
request_id
);
if
(
!
(
req
&&
req
->
code
==
UI_FF_UPLOAD
&&
req
->
u
.
effect
))
{
if
(
!
(
req
&&
req
->
code
==
UI_FF_UPLOAD
&&
req
->
u
.
effect
))
{
retval
=
-
EINVAL
;
retval
=
-
EINVAL
;
break
;
break
;
}
}
...
@@ -538,7 +527,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
...
@@ -538,7 +527,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
break
;
break
;
}
}
req
=
uinput_request_find
(
udev
,
ff_erase
.
request_id
);
req
=
uinput_request_find
(
udev
,
ff_erase
.
request_id
);
if
(
!
(
req
&&
req
->
code
==
UI_FF_ERASE
))
{
if
(
!
(
req
&&
req
->
code
==
UI_FF_ERASE
))
{
retval
=
-
EINVAL
;
retval
=
-
EINVAL
;
break
;
break
;
}
}
...
@@ -556,7 +545,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
...
@@ -556,7 +545,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
break
;
break
;
}
}
req
=
uinput_request_find
(
udev
,
ff_up
.
request_id
);
req
=
uinput_request_find
(
udev
,
ff_up
.
request_id
);
if
(
!
(
req
&&
req
->
code
==
UI_FF_UPLOAD
&&
req
->
u
.
effect
))
{
if
(
!
(
req
&&
req
->
code
==
UI_FF_UPLOAD
&&
req
->
u
.
effect
))
{
retval
=
-
EINVAL
;
retval
=
-
EINVAL
;
break
;
break
;
}
}
...
@@ -572,7 +561,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
...
@@ -572,7 +561,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
break
;
break
;
}
}
req
=
uinput_request_find
(
udev
,
ff_erase
.
request_id
);
req
=
uinput_request_find
(
udev
,
ff_erase
.
request_id
);
if
(
!
(
req
&&
req
->
code
==
UI_FF_ERASE
))
{
if
(
!
(
req
&&
req
->
code
==
UI_FF_ERASE
))
{
retval
=
-
EINVAL
;
retval
=
-
EINVAL
;
break
;
break
;
}
}
...
...
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