mtd: compat_ioctl cleanup

1) Move the MEMREADOOB/MEMWRITEOOB compat_ioctl wrappers from
fs/compat_ioctl.c into mtdchar.c .  Original request was here:

http://lkml.org/lkml/2009/4/1/295

2) Add missing COMPATIBLE_IOCTL lines, so that mtd-utils does not error
out when running in 64/32 compatibility mode.

LKML-Reference: <200904011650.22928.arnd@arndb.de>
Signed-off-by: Kevin Cernekee <kpc.mtd@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
Kevin Cernekee
2009-04-08 22:53:13 -07:00
committed by David Woodhouse
parent 0dc54e9f33
commit 9771854040
2 changed files with 180 additions and 126 deletions

View File

@@ -1411,46 +1411,6 @@ static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
#define HIDPGETCONNLIST _IOR('H', 210, int)
#define HIDPGETCONNINFO _IOR('H', 211, int)
struct mtd_oob_buf32 {
u_int32_t start;
u_int32_t length;
compat_caddr_t ptr; /* unsigned char* */
};
#define MEMWRITEOOB32 _IOWR('M',3,struct mtd_oob_buf32)
#define MEMREADOOB32 _IOWR('M',4,struct mtd_oob_buf32)
static int mtd_rw_oob(unsigned int fd, unsigned int cmd, unsigned long arg)
{
struct mtd_oob_buf __user *buf = compat_alloc_user_space(sizeof(*buf));
struct mtd_oob_buf32 __user *buf32 = compat_ptr(arg);
u32 data;
char __user *datap;
unsigned int real_cmd;
int err;
real_cmd = (cmd == MEMREADOOB32) ?
MEMREADOOB : MEMWRITEOOB;
if (copy_in_user(&buf->start, &buf32->start,
2 * sizeof(u32)) ||
get_user(data, &buf32->ptr))
return -EFAULT;
datap = compat_ptr(data);
if (put_user(datap, &buf->ptr))
return -EFAULT;
err = sys_ioctl(fd, real_cmd, (unsigned long) buf);
if (!err) {
if (copy_in_user(&buf32->start, &buf->start,
2 * sizeof(u32)))
err = -EFAULT;
}
return err;
}
#ifdef CONFIG_BLOCK
struct raw32_config_request
{
@@ -2439,8 +2399,17 @@ COMPATIBLE_IOCTL(MEMLOCK)
COMPATIBLE_IOCTL(MEMUNLOCK)
COMPATIBLE_IOCTL(MEMGETREGIONCOUNT)
COMPATIBLE_IOCTL(MEMGETREGIONINFO)
COMPATIBLE_IOCTL(MEMSETOOBSEL)
COMPATIBLE_IOCTL(MEMGETOOBSEL)
COMPATIBLE_IOCTL(MEMGETBADBLOCK)
COMPATIBLE_IOCTL(MEMSETBADBLOCK)
COMPATIBLE_IOCTL(OTPSELECT)
COMPATIBLE_IOCTL(OTPGETREGIONCOUNT)
COMPATIBLE_IOCTL(OTPGETREGIONINFO)
COMPATIBLE_IOCTL(OTPLOCK)
COMPATIBLE_IOCTL(ECCGETLAYOUT)
COMPATIBLE_IOCTL(ECCGETSTATS)
COMPATIBLE_IOCTL(MTDFILEMODE)
COMPATIBLE_IOCTL(MEMERASE64)
/* NBD */
ULONG_IOCTL(NBD_SET_SOCK)
@@ -2551,8 +2520,6 @@ COMPATIBLE_IOCTL(JSIOCGBUTTONS)
COMPATIBLE_IOCTL(JSIOCGNAME(0))
/* now things that need handlers */
HANDLE_IOCTL(MEMREADOOB32, mtd_rw_oob)
HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob)
#ifdef CONFIG_NET
HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf)