Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Staging: comedi: remove check for HAVE_COMPAT_IOCTL

All new kernels have support for compat_ioctl so remove the check and support
for older kernels.

Signed-off-by: Shawn Bohrer <shawn.bohrer@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Shawn Bohrer and committed by
Greg Kroah-Hartman
5d7ae225 00a1855c

-130
-108
drivers/staging/comedi/comedi_compat32.c
··· 33 33 34 34 #ifdef CONFIG_COMPAT 35 35 36 - #ifndef HAVE_COMPAT_IOCTL 37 - #include <linux/ioctl32.h> /* for (un)register_ioctl32_conversion */ 38 - #endif 39 - 40 36 #define COMEDI32_CHANINFO _IOR(CIO, 3, struct comedi32_chaninfo_struct) 41 37 #define COMEDI32_RANGEINFO _IOR(CIO, 8, struct comedi32_rangeinfo_struct) 42 38 /* N.B. COMEDI32_CMD and COMEDI_CMD ought to use _IOWR, not _IOR. ··· 458 462 return rc; 459 463 } 460 464 461 - #ifdef HAVE_COMPAT_IOCTL /* defined in <linux/fs.h> 2.6.11 onwards */ 462 - 463 465 /* compat_ioctl file operation. */ 464 466 /* Returns -ENOIOCTLCMD for unrecognised ioctl codes. */ 465 467 long comedi_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 466 468 { 467 469 return raw_ioctl(file, cmd, arg); 468 470 } 469 - 470 - #else /* HAVE_COMPAT_IOCTL */ 471 - 472 - /* 473 - * Brain-dead ioctl compatibility for 2.6.10 and earlier. 474 - * 475 - * It's brain-dead because cmd numbers need to be unique system-wide! 476 - * The comedi driver could end up attempting to execute ioctls for non-Comedi 477 - * devices because it registered the system-wide cmd code first. Similarly, 478 - * another driver could end up attempting to execute ioctls for a Comedi 479 - * device because it registered the cmd code first. Chaos ensues. 480 - */ 481 - 482 - /* Handler for all 32-bit ioctl codes registered by this driver. */ 483 - static int mapped_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, 484 - struct file *file) 485 - { 486 - int rc; 487 - 488 - /* Make sure we are dealing with a Comedi device. */ 489 - if (imajor(file->f_dentry->d_inode) != COMEDI_MAJOR) 490 - return -ENOTTY; 491 - 492 - rc = raw_ioctl(file, cmd, arg); 493 - /* Do not return -ENOIOCTLCMD. */ 494 - if (rc == -ENOIOCTLCMD) 495 - rc = -ENOTTY; 496 - 497 - return rc; 498 - } 499 - 500 - struct ioctl32_map { 501 - unsigned int cmd; 502 - int (*handler) (unsigned int, unsigned int, unsigned long, 503 - struct file *); 504 - int registered; 505 - }; 506 - 507 - static struct ioctl32_map comedi_ioctl32_map[] = { 508 - {COMEDI_DEVCONFIG, mapped_ioctl, 0}, 509 - {COMEDI_DEVINFO, mapped_ioctl, 0}, 510 - {COMEDI_SUBDINFO, mapped_ioctl, 0}, 511 - {COMEDI_BUFCONFIG, mapped_ioctl, 0}, 512 - {COMEDI_BUFINFO, mapped_ioctl, 0}, 513 - {COMEDI_LOCK, mapped_ioctl, 0}, 514 - {COMEDI_UNLOCK, mapped_ioctl, 0}, 515 - {COMEDI_CANCEL, mapped_ioctl, 0}, 516 - {COMEDI_POLL, mapped_ioctl, 0}, 517 - {COMEDI32_CHANINFO, mapped_ioctl, 0}, 518 - {COMEDI32_RANGEINFO, mapped_ioctl, 0}, 519 - {COMEDI32_CMD, mapped_ioctl, 0}, 520 - {COMEDI32_CMDTEST, mapped_ioctl, 0}, 521 - {COMEDI32_INSNLIST, mapped_ioctl, 0}, 522 - {COMEDI32_INSN, mapped_ioctl, 0}, 523 - }; 524 - 525 - #define NUM_IOCTL32_MAPS ARRAY_SIZE(comedi_ioctl32_map) 526 - 527 - /* Register system-wide 32-bit ioctl handlers. */ 528 - void comedi_register_ioctl32(void) 529 - { 530 - int n, rc; 531 - 532 - for (n = 0; n < NUM_IOCTL32_MAPS; n++) { 533 - rc = register_ioctl32_conversion(comedi_ioctl32_map[n].cmd, 534 - comedi_ioctl32_map[n].handler); 535 - if (rc) { 536 - printk(KERN_WARNING 537 - "comedi: failed to register 32-bit " 538 - "compatible ioctl handler for 0x%X - " 539 - "expect bad things to happen!\n", 540 - comedi_ioctl32_map[n].cmd); 541 - } 542 - comedi_ioctl32_map[n].registered = !rc; 543 - } 544 - } 545 - 546 - /* Unregister system-wide 32-bit ioctl translations. */ 547 - void comedi_unregister_ioctl32(void) 548 - { 549 - int n, rc; 550 - 551 - for (n = 0; n < NUM_IOCTL32_MAPS; n++) { 552 - if (comedi_ioctl32_map[n].registered) { 553 - rc = unregister_ioctl32_conversion(comedi_ioctl32_map 554 - [n].cmd, 555 - comedi_ioctl32_map 556 - [n].handler); 557 - if (rc) { 558 - printk(KERN_ERR 559 - "comedi: failed to unregister 32-bit " 560 - "compatible ioctl handler for 0x%X - " 561 - "expect kernel Oops!\n", 562 - comedi_ioctl32_map[n].cmd); 563 - } else { 564 - comedi_ioctl32_map[n].registered = 0; 565 - } 566 - } 567 - } 568 - } 569 - 570 - #endif /* HAVE_COMPAT_IOCTL */ 571 471 572 472 #endif /* CONFIG_COMPAT */
-16
drivers/staging/comedi/comedi_compat32.h
··· 28 28 #define _COMEDI_COMPAT32_H 29 29 30 30 #include <linux/compat.h> 31 - 32 - /* For HAVE_COMPAT_IOCTL and HAVE_UNLOCKED_IOCTL */ 33 31 #include <linux/fs.h> 34 32 35 33 #ifdef CONFIG_COMPAT 36 34 37 - #ifdef HAVE_COMPAT_IOCTL 38 - 39 35 extern long comedi_compat_ioctl(struct file *file, unsigned int cmd, 40 36 unsigned long arg); 41 - #define comedi_register_ioctl32() do {} while (0) 42 - #define comedi_unregister_ioctl32() do {} while (0) 43 - 44 - #else /* HAVE_COMPAT_IOCTL */ 45 - 46 - #define comedi_compat_ioctl 0 /* NULL */ 47 - extern void comedi_register_ioctl32(void); 48 - extern void comedi_unregister_ioctl32(void); 49 - 50 - #endif /* HAVE_COMPAT_IOCTL */ 51 37 52 38 #else /* CONFIG_COMPAT */ 53 39 54 40 #define comedi_compat_ioctl 0 /* NULL */ 55 - #define comedi_register_ioctl32() do {} while (0) 56 - #define comedi_unregister_ioctl32() do {} while (0) 57 41 58 42 #endif /* CONFIG_COMPAT */ 59 43
-6
drivers/staging/comedi/comedi_fops.c
··· 1863 1863 const struct file_operations comedi_fops = { 1864 1864 .owner = THIS_MODULE, 1865 1865 .unlocked_ioctl = comedi_unlocked_ioctl, 1866 - #ifdef HAVE_COMPAT_IOCTL 1867 1866 .compat_ioctl = comedi_compat_ioctl, 1868 - #endif 1869 1867 .open = comedi_open, 1870 1868 .release = comedi_close, 1871 1869 .read = comedi_read, ··· 1948 1950 } 1949 1951 } 1950 1952 1951 - comedi_register_ioctl32(); 1952 - 1953 1953 return 0; 1954 1954 } 1955 1955 ··· 1964 1968 unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS); 1965 1969 1966 1970 comedi_proc_cleanup(); 1967 - 1968 - comedi_unregister_ioctl32(); 1969 1971 } 1970 1972 1971 1973 module_init(comedi_init);