27 #define __NO_VERSION__
36 #define COMEDI32_CHANINFO _IOR(CIO, 3, struct comedi32_chaninfo_struct)
37 #define COMEDI32_RANGEINFO _IOR(CIO, 8, struct comedi32_rangeinfo_struct)
40 #define COMEDI32_CMD _IOR(CIO, 9, struct comedi32_cmd_struct)
43 #define COMEDI32_CMDTEST _IOR(CIO, 10, struct comedi32_cmd_struct)
44 #define COMEDI32_INSNLIST _IOR(CIO, 11, struct comedi32_insnlist_struct)
45 #define COMEDI32_INSN _IOR(CIO, 12, struct comedi32_insn_struct)
47 struct comedi32_chaninfo_struct {
55 struct comedi32_rangeinfo_struct {
56 unsigned int range_type;
60 struct comedi32_cmd_struct {
63 unsigned int start_src;
64 unsigned int start_arg;
65 unsigned int scan_begin_src;
66 unsigned int scan_begin_arg;
67 unsigned int convert_src;
68 unsigned int convert_arg;
69 unsigned int scan_end_src;
70 unsigned int scan_end_arg;
71 unsigned int stop_src;
72 unsigned int stop_arg;
74 unsigned int chanlist_len;
79 struct comedi32_insn_struct {
84 unsigned int chanspec;
88 struct comedi32_insnlist_struct {
94 static int translated_ioctl(
struct file *
file,
unsigned int cmd,
100 if (file->
f_op->unlocked_ioctl)
101 return file->
f_op->unlocked_ioctl(file, cmd, arg);
107 static int compat_chaninfo(
struct file *file,
unsigned long arg)
110 struct comedi32_chaninfo_struct
__user *chaninfo32;
117 chaninfo32 = compat_ptr(arg);
137 return translated_ioctl(file,
COMEDI_CHANINFO, (
unsigned long)chaninfo);
141 static int compat_rangeinfo(
struct file *file,
unsigned long arg)
144 struct comedi32_rangeinfo_struct
__user *rangeinfo32;
151 rangeinfo32 = compat_ptr(arg);
168 (
unsigned long)rangeinfo);
172 static int get_compat_cmd(
struct comedi_cmd __user *cmd,
173 struct comedi32_cmd_struct __user *
cmd32)
223 static int put_compat_cmd(
struct comedi32_cmd_struct __user *cmd32,
246 err |=
__get_user(temp, &cmd->scan_begin_src);
247 err |=
__put_user(temp, &cmd32->scan_begin_src);
248 err |=
__get_user(temp, &cmd->scan_begin_arg);
249 err |=
__put_user(temp, &cmd32->scan_begin_arg);
255 err |=
__put_user(temp, &cmd32->scan_end_src);
257 err |=
__put_user(temp, &cmd32->scan_end_arg);
264 err |=
__put_user(temp, &cmd32->chanlist_len);
272 static int compat_cmd(
struct file *file,
unsigned long arg)
278 cmd32 = compat_ptr(arg);
281 rc = get_compat_cmd(cmd, cmd32);
285 return translated_ioctl(file,
COMEDI_CMD, (
unsigned long)cmd);
289 static int compat_cmdtest(
struct file *file,
unsigned long arg)
295 cmd32 = compat_ptr(arg);
298 rc = get_compat_cmd(cmd, cmd32);
306 err = put_compat_cmd(cmd32, cmd);
315 struct comedi32_insn_struct __user *insn32)
334 err |=
__put_user(compat_ptr(temp.uptr), &insn->data);
335 err |=
__get_user(temp.uint, &insn32->subdev);
337 err |=
__get_user(temp.uint, &insn32->chanspec);
338 err |=
__put_user(temp.uint, &insn->chanspec);
343 static int compat_insnlist(
struct file *file,
unsigned long arg)
345 struct combined_insnlist {
349 struct comedi32_insnlist_struct
__user *insnlist32;
350 struct comedi32_insn_struct
__user *insn32;
352 unsigned int n_insns,
n;
355 insnlist32 = compat_ptr(arg);
362 err |=
__get_user(n_insns, &insnlist32->n_insns);
364 insn32 = compat_ptr(uptr);
376 err |=
__put_user(n_insns, &s->insnlist.n_insns);
377 err |=
__put_user(&s->insn[0], &s->insnlist.insns);
382 for (n = 0; n < n_insns; n++) {
383 rc = get_compat_insn(&s->insn[n], &insn32[n]);
389 (
unsigned long)&s->insnlist);
393 static int compat_insn(
struct file *file,
unsigned long arg)
396 struct comedi32_insn_struct
__user *insn32;
399 insn32 = compat_ptr(arg);
402 rc = get_compat_insn(insn, insn32);
406 return translated_ioctl(file,
COMEDI_INSN, (
unsigned long)insn);
411 static inline int raw_ioctl(
struct file *file,
unsigned int cmd,
423 arg = (
unsigned long)compat_ptr(arg);
424 rc = translated_ioctl(file, cmd, arg);
431 rc = translated_ioctl(file, cmd, arg);
433 case COMEDI32_CHANINFO:
434 rc = compat_chaninfo(file, arg);
436 case COMEDI32_RANGEINFO:
437 rc = compat_rangeinfo(file, arg);
440 rc = compat_cmd(file, arg);
442 case COMEDI32_CMDTEST:
443 rc = compat_cmdtest(file, arg);
445 case COMEDI32_INSNLIST:
446 rc = compat_insnlist(file, arg);
449 rc = compat_insn(file, arg);
462 return raw_ioctl(file, cmd, arg);