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
7d5cb456
Commit
7d5cb456
authored
Sep 20, 2017
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
i2c compat ioctls: move to ->compat_ioctl()
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
abca5fc5
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
180 additions
and
210 deletions
+180
-210
drivers/i2c/i2c-dev.c
drivers/i2c/i2c-dev.c
+180
-88
fs/compat_ioctl.c
fs/compat_ioctl.c
+0
-122
No files found.
drivers/i2c/i2c-dev.c
View file @
7d5cb456
This diff is collapsed.
Click to expand it.
fs/compat_ioctl.c
View file @
7d5cb456
...
...
@@ -53,8 +53,6 @@
#include <linux/if_tun.h>
#include <linux/ctype.h>
#include <linux/syscalls.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <linux/atalk.h>
#include <linux/gfp.h>
#include <linux/cec.h>
...
...
@@ -136,22 +134,6 @@ static int do_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return
vfs_ioctl
(
file
,
cmd
,
arg
);
}
static
int
w_long
(
struct
file
*
file
,
unsigned
int
cmd
,
compat_ulong_t
__user
*
argp
)
{
int
err
;
unsigned
long
__user
*
valp
=
compat_alloc_user_space
(
sizeof
(
*
valp
));
if
(
valp
==
NULL
)
return
-
EFAULT
;
err
=
do_ioctl
(
file
,
cmd
,
(
unsigned
long
)
valp
);
if
(
err
)
return
err
;
if
(
convert_in_user
(
valp
,
argp
))
return
-
EFAULT
;
return
0
;
}
struct
compat_video_event
{
int32_t
type
;
compat_time_t
timestamp
;
...
...
@@ -670,96 +652,6 @@ static int serial_struct_ioctl(struct file *file,
return
err
;
}
/*
* I2C layer ioctls
*/
struct
i2c_msg32
{
u16
addr
;
u16
flags
;
u16
len
;
compat_caddr_t
buf
;
};
struct
i2c_rdwr_ioctl_data32
{
compat_caddr_t
msgs
;
/* struct i2c_msg __user *msgs */
u32
nmsgs
;
};
struct
i2c_smbus_ioctl_data32
{
u8
read_write
;
u8
command
;
u32
size
;
compat_caddr_t
data
;
/* union i2c_smbus_data *data */
};
struct
i2c_rdwr_aligned
{
struct
i2c_rdwr_ioctl_data
cmd
;
struct
i2c_msg
msgs
[
0
];
};
static
int
do_i2c_rdwr_ioctl
(
struct
file
*
file
,
unsigned
int
cmd
,
struct
i2c_rdwr_ioctl_data32
__user
*
udata
)
{
struct
i2c_rdwr_aligned
__user
*
tdata
;
struct
i2c_msg
__user
*
tmsgs
;
struct
i2c_msg32
__user
*
umsgs
;
compat_caddr_t
datap
;
u32
nmsgs
;
int
i
;
if
(
get_user
(
nmsgs
,
&
udata
->
nmsgs
))
return
-
EFAULT
;
if
(
nmsgs
>
I2C_RDWR_IOCTL_MAX_MSGS
)
return
-
EINVAL
;
if
(
get_user
(
datap
,
&
udata
->
msgs
))
return
-
EFAULT
;
umsgs
=
compat_ptr
(
datap
);
tdata
=
compat_alloc_user_space
(
sizeof
(
*
tdata
)
+
nmsgs
*
sizeof
(
struct
i2c_msg
));
tmsgs
=
&
tdata
->
msgs
[
0
];
if
(
put_user
(
nmsgs
,
&
tdata
->
cmd
.
nmsgs
)
||
put_user
(
tmsgs
,
&
tdata
->
cmd
.
msgs
))
return
-
EFAULT
;
for
(
i
=
0
;
i
<
nmsgs
;
i
++
)
{
if
(
copy_in_user
(
&
tmsgs
[
i
].
addr
,
&
umsgs
[
i
].
addr
,
3
*
sizeof
(
u16
)))
return
-
EFAULT
;
if
(
get_user
(
datap
,
&
umsgs
[
i
].
buf
)
||
put_user
(
compat_ptr
(
datap
),
&
tmsgs
[
i
].
buf
))
return
-
EFAULT
;
}
return
do_ioctl
(
file
,
cmd
,
(
unsigned
long
)
tdata
);
}
static
int
do_i2c_smbus_ioctl
(
struct
file
*
file
,
unsigned
int
cmd
,
struct
i2c_smbus_ioctl_data32
__user
*
udata
)
{
struct
i2c_smbus_ioctl_data
__user
*
tdata
;
union
{
/* beginnings of those have identical layouts */
struct
i2c_smbus_ioctl_data32
data32
;
struct
i2c_smbus_ioctl_data
data
;
}
v
;
tdata
=
compat_alloc_user_space
(
sizeof
(
*
tdata
));
if
(
tdata
==
NULL
)
return
-
ENOMEM
;
memset
(
&
v
,
0
,
sizeof
(
v
));
if
(
copy_from_user
(
&
v
.
data32
,
udata
,
sizeof
(
v
.
data32
)))
return
-
EFAULT
;
v
.
data
.
data
=
compat_ptr
(
v
.
data32
.
data
);
if
(
copy_to_user
(
tdata
,
&
v
.
data
,
sizeof
(
v
.
data
)))
return
-
EFAULT
;
return
do_ioctl
(
file
,
cmd
,
(
unsigned
long
)
tdata
);
}
#define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t)
#define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t)
#define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t)
...
...
@@ -1282,13 +1174,6 @@ COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
COMPATIBLE_IOCTL
(
PCIIOC_MMAP_IS_IO
)
COMPATIBLE_IOCTL
(
PCIIOC_MMAP_IS_MEM
)
COMPATIBLE_IOCTL
(
PCIIOC_WRITE_COMBINE
)
/* i2c */
COMPATIBLE_IOCTL
(
I2C_SLAVE
)
COMPATIBLE_IOCTL
(
I2C_SLAVE_FORCE
)
COMPATIBLE_IOCTL
(
I2C_TENBIT
)
COMPATIBLE_IOCTL
(
I2C_PEC
)
COMPATIBLE_IOCTL
(
I2C_RETRIES
)
COMPATIBLE_IOCTL
(
I2C_TIMEOUT
)
/* hiddev */
COMPATIBLE_IOCTL
(
HIDIOCGVERSION
)
COMPATIBLE_IOCTL
(
HIDIOCAPPLICATION
)
...
...
@@ -1463,13 +1348,6 @@ static long do_ioctl_trans(unsigned int cmd,
case
TIOCGSERIAL
:
case
TIOCSSERIAL
:
return
serial_struct_ioctl
(
file
,
cmd
,
argp
);
/* i2c */
case
I2C_FUNCS
:
return
w_long
(
file
,
cmd
,
argp
);
case
I2C_RDWR
:
return
do_i2c_rdwr_ioctl
(
file
,
cmd
,
argp
);
case
I2C_SMBUS
:
return
do_i2c_smbus_ioctl
(
file
,
cmd
,
argp
);
/* Not implemented in the native kernel */
case
RTC_IRQP_READ32
:
case
RTC_IRQP_SET32
:
...
...
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