Re: [PATCH 01/10] comedi: move compat ioctl handling to native fops

2020-05-29 Thread Ian Abbott

On 29/05/2020 01:35, Al Viro wrote:

From: Al Viro 

mechanical move

Signed-off-by: Al Viro 
---
  drivers/staging/comedi/Makefile  |   1 -
  drivers/staging/comedi/comedi_compat32.c | 455 ---
  drivers/staging/comedi/comedi_compat32.h |  28 --
  drivers/staging/comedi/comedi_fops.c | 451 +-
  4 files changed, 448 insertions(+), 487 deletions(-)
  delete mode 100644 drivers/staging/comedi/comedi_compat32.c
  delete mode 100644 drivers/staging/comedi/comedi_compat32.h



Signed-off-by: Ian Abbott 

--
-=( Ian Abbott  || Web: www.mev.co.uk )=-
-=( MEV Ltd. is a company registered in England & Wales. )=-
-=( Registered number: 02862268.  Registered address:)=-
-=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-


[PATCH 01/10] comedi: move compat ioctl handling to native fops

2020-05-28 Thread Al Viro
From: Al Viro 

mechanical move

Signed-off-by: Al Viro 
---
 drivers/staging/comedi/Makefile  |   1 -
 drivers/staging/comedi/comedi_compat32.c | 455 ---
 drivers/staging/comedi/comedi_compat32.h |  28 --
 drivers/staging/comedi/comedi_fops.c | 451 +-
 4 files changed, 448 insertions(+), 487 deletions(-)
 delete mode 100644 drivers/staging/comedi/comedi_compat32.c
 delete mode 100644 drivers/staging/comedi/comedi_compat32.h

diff --git a/drivers/staging/comedi/Makefile b/drivers/staging/comedi/Makefile
index 6af5da3b4315..072ed83a5a6a 100644
--- a/drivers/staging/comedi/Makefile
+++ b/drivers/staging/comedi/Makefile
@@ -4,7 +4,6 @@ ccflags-$(CONFIG_COMEDI_DEBUG)  := -DDEBUG
 comedi-y   := comedi_fops.o range.o drivers.o \
   comedi_buf.o
 comedi-$(CONFIG_PROC_FS)   += proc.o
-comedi-$(CONFIG_COMPAT)+= comedi_compat32.o
 
 obj-$(CONFIG_COMEDI_PCI_DRIVERS)   += comedi_pci.o
 obj-$(CONFIG_COMEDI_PCMCIA_DRIVERS)+= comedi_pcmcia.o
diff --git a/drivers/staging/comedi/comedi_compat32.c 
b/drivers/staging/comedi/comedi_compat32.c
deleted file mode 100644
index 36a3564ba1fb..
--- a/drivers/staging/comedi/comedi_compat32.c
+++ /dev/null
@@ -1,455 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * comedi/comedi_compat32.c
- * 32-bit ioctl compatibility for 64-bit comedi kernel module.
- *
- * Author: Ian Abbott, MEV Ltd. 
- * Copyright (C) 2007 MEV Ltd. 
- *
- * COMEDI - Linux Control and Measurement Device Interface
- * Copyright (C) 1997-2007 David A. Schleef 
- */
-
-#include 
-#include 
-#include 
-#include "comedi.h"
-#include "comedi_compat32.h"
-
-#define COMEDI32_CHANINFO _IOR(CIO, 3, struct comedi32_chaninfo_struct)
-#define COMEDI32_RANGEINFO _IOR(CIO, 8, struct comedi32_rangeinfo_struct)
-/*
- * N.B. COMEDI32_CMD and COMEDI_CMD ought to use _IOWR, not _IOR.
- * It's too late to change it now, but it only affects the command number.
- */
-#define COMEDI32_CMD _IOR(CIO, 9, struct comedi32_cmd_struct)
-/*
- * N.B. COMEDI32_CMDTEST and COMEDI_CMDTEST ought to use _IOWR, not _IOR.
- * It's too late to change it now, but it only affects the command number.
- */
-#define COMEDI32_CMDTEST _IOR(CIO, 10, struct comedi32_cmd_struct)
-#define COMEDI32_INSNLIST _IOR(CIO, 11, struct comedi32_insnlist_struct)
-#define COMEDI32_INSN _IOR(CIO, 12, struct comedi32_insn_struct)
-
-struct comedi32_chaninfo_struct {
-   unsigned int subdev;
-   compat_uptr_t maxdata_list; /* 32-bit 'unsigned int *' */
-   compat_uptr_t flaglist; /* 32-bit 'unsigned int *' */
-   compat_uptr_t rangelist;/* 32-bit 'unsigned int *' */
-   unsigned int unused[4];
-};
-
-struct comedi32_rangeinfo_struct {
-   unsigned int range_type;
-   compat_uptr_t range_ptr;/* 32-bit 'void *' */
-};
-
-struct comedi32_cmd_struct {
-   unsigned int subdev;
-   unsigned int flags;
-   unsigned int start_src;
-   unsigned int start_arg;
-   unsigned int scan_begin_src;
-   unsigned int scan_begin_arg;
-   unsigned int convert_src;
-   unsigned int convert_arg;
-   unsigned int scan_end_src;
-   unsigned int scan_end_arg;
-   unsigned int stop_src;
-   unsigned int stop_arg;
-   compat_uptr_t chanlist; /* 32-bit 'unsigned int *' */
-   unsigned int chanlist_len;
-   compat_uptr_t data; /* 32-bit 'short *' */
-   unsigned int data_len;
-};
-
-struct comedi32_insn_struct {
-   unsigned int insn;
-   unsigned int n;
-   compat_uptr_t data; /* 32-bit 'unsigned int *' */
-   unsigned int subdev;
-   unsigned int chanspec;
-   unsigned int unused[3];
-};
-
-struct comedi32_insnlist_struct {
-   unsigned int n_insns;
-   compat_uptr_t insns;/* 32-bit 'struct comedi_insn *' */
-};
-
-/* Handle translated ioctl. */
-static int translated_ioctl(struct file *file, unsigned int cmd,
-   unsigned long arg)
-{
-   if (file->f_op->unlocked_ioctl)
-   return file->f_op->unlocked_ioctl(file, cmd, arg);
-
-   return -ENOTTY;
-}
-
-/* Handle 32-bit COMEDI_CHANINFO ioctl. */
-static int compat_chaninfo(struct file *file, unsigned long arg)
-{
-   struct comedi_chaninfo __user *chaninfo;
-   struct comedi32_chaninfo_struct __user *chaninfo32;
-   int err;
-   union {
-   unsigned int uint;
-   compat_uptr_t uptr;
-   } temp;
-
-   chaninfo32 = compat_ptr(arg);
-   chaninfo = compat_alloc_user_space(sizeof(*chaninfo));
-
-   /* Copy chaninfo structure.  Ignore unused members. */
-   if (!access_ok(chaninfo32, sizeof(*chaninfo32)) ||
-   !access_ok(chaninfo, sizeof(*chaninfo)))
-   return -EFAULT;
-
-   err = 0;
-   err |= __get_user(temp.uint, >subdev);
-   err |=