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

compat_ioctl: move cdrom commands into cdrom.c

There is no need for the special cases for the cdrom ioctls any more now,
so make sure that each cdrom driver has a .compat_ioctl() callback and
calls cdrom_compat_ioctl() directly there.

Reviewed-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+45 -51
-45
block/compat_ioctl.c
··· 160 160 case HDIO_DRIVE_CMD: 161 161 /* 0x330 is reserved -- it used to be HDIO_GETGEO_BIG */ 162 162 case 0x330: 163 - /* CDROM stuff */ 164 - case CDROMPAUSE: 165 - case CDROMRESUME: 166 - case CDROMPLAYMSF: 167 - case CDROMPLAYTRKIND: 168 - case CDROMREADTOCHDR: 169 - case CDROMREADTOCENTRY: 170 - case CDROMSTOP: 171 - case CDROMSTART: 172 - case CDROMEJECT: 173 - case CDROMVOLCTRL: 174 - case CDROMSUBCHNL: 175 - case CDROMMULTISESSION: 176 - case CDROM_GET_MCN: 177 - case CDROMRESET: 178 - case CDROMVOLREAD: 179 - case CDROMSEEK: 180 - case CDROMPLAYBLK: 181 - case CDROMCLOSETRAY: 182 - case CDROM_DISC_STATUS: 183 - case CDROM_CHANGER_NSLOTS: 184 - case CDROM_GET_CAPABILITY: 185 - case CDROM_SEND_PACKET: 186 - /* Ignore cdrom.h about these next 5 ioctls, they absolutely do 187 - * not take a struct cdrom_read, instead they take a struct cdrom_msf 188 - * which is compatible. 189 - */ 190 - case CDROMREADMODE2: 191 - case CDROMREADMODE1: 192 - case CDROMREADRAW: 193 - case CDROMREADCOOKED: 194 - case CDROMREADALL: 195 - /* DVD ioctls */ 196 - case DVD_READ_STRUCT: 197 - case DVD_WRITE_STRUCT: 198 - case DVD_AUTH: 199 163 arg = (unsigned long)compat_ptr(arg); 200 164 /* These intepret arg as an unsigned long, not as a pointer, 201 165 * so we must not do compat_ptr() conversion. */ ··· 175 211 case HDIO_SET_ACOUSTIC: 176 212 case HDIO_SET_BUSSTATE: 177 213 case HDIO_SET_ADDRESS: 178 - case CDROMEJECT_SW: 179 - case CDROM_SET_OPTIONS: 180 - case CDROM_CLEAR_OPTIONS: 181 - case CDROM_SELECT_SPEED: 182 - case CDROM_SELECT_DISC: 183 - case CDROM_MEDIA_CHANGED: 184 - case CDROM_DRIVE_STATUS: 185 - case CDROM_LOCKDOOR: 186 - case CDROM_DEBUG: 187 214 break; 188 215 default: 189 216 /* unknown ioctl number */
+3
drivers/block/paride/pcd.c
··· 275 275 .open = pcd_block_open, 276 276 .release = pcd_block_release, 277 277 .ioctl = pcd_block_ioctl, 278 + #ifdef CONFIG_COMPAT 279 + .ioctl = blkdev_compat_ptr_ioctl, 280 + #endif 278 281 .check_events = pcd_block_check_events, 279 282 }; 280 283
+3
drivers/cdrom/gdrom.c
··· 518 518 .release = gdrom_bdops_release, 519 519 .check_events = gdrom_bdops_check_events, 520 520 .ioctl = gdrom_bdops_ioctl, 521 + #ifdef CONFIG_COMPAT 522 + .ioctl = blkdev_compat_ptr_ioctl, 523 + #endif 521 524 }; 522 525 523 526 static irqreturn_t gdrom_command_interrupt(int irq, void *dev_id)
+37
drivers/ide/ide-cd.c
··· 25 25 26 26 #define IDECD_VERSION "5.00" 27 27 28 + #include <linux/compat.h> 28 29 #include <linux/module.h> 29 30 #include <linux/types.h> 30 31 #include <linux/kernel.h> ··· 1711 1710 return ret; 1712 1711 } 1713 1712 1713 + #ifdef CONFIG_COMPAT 1714 + static int idecd_locked_compat_ioctl(struct block_device *bdev, fmode_t mode, 1715 + unsigned int cmd, unsigned long arg) 1716 + { 1717 + struct cdrom_info *info = ide_drv_g(bdev->bd_disk, cdrom_info); 1718 + void __user *argp = compat_ptr(arg); 1719 + int err; 1720 + 1721 + switch (cmd) { 1722 + case CDROMSETSPINDOWN: 1723 + return idecd_set_spindown(&info->devinfo, (unsigned long)argp); 1724 + case CDROMGETSPINDOWN: 1725 + return idecd_get_spindown(&info->devinfo, (unsigned long)argp); 1726 + default: 1727 + break; 1728 + } 1729 + 1730 + return cdrom_ioctl(&info->devinfo, bdev, mode, cmd, 1731 + (unsigned long)argp); 1732 + } 1733 + 1734 + static int idecd_compat_ioctl(struct block_device *bdev, fmode_t mode, 1735 + unsigned int cmd, unsigned long arg) 1736 + { 1737 + int ret; 1738 + 1739 + mutex_lock(&ide_cd_mutex); 1740 + ret = idecd_locked_compat_ioctl(bdev, mode, cmd, arg); 1741 + mutex_unlock(&ide_cd_mutex); 1742 + 1743 + return ret; 1744 + } 1745 + #endif 1714 1746 1715 1747 static unsigned int idecd_check_events(struct gendisk *disk, 1716 1748 unsigned int clearing) ··· 1766 1732 .open = idecd_open, 1767 1733 .release = idecd_release, 1768 1734 .ioctl = idecd_ioctl, 1735 + #ifdef CONFIG_COMPAT 1736 + .compat_ioctl = idecd_compat_ioctl, 1737 + #endif 1769 1738 .check_events = idecd_check_events, 1770 1739 .revalidate_disk = idecd_revalidate_disk 1771 1740 };
+2 -6
drivers/scsi/sr.c
··· 628 628 goto put; 629 629 } 630 630 631 - /* 632 - * CDROM ioctls are handled in the block layer, but 633 - * do the scsi blk ioctls here. 634 - */ 635 - ret = scsi_cmd_blk_ioctl(bdev, mode, cmd, argp); 636 - if (ret != -ENOTTY) 631 + ret = cdrom_ioctl(&cd->cdi, bdev, mode, cmd, (unsigned long)argp); 632 + if (ret != -ENOSYS) 637 633 goto put; 638 634 639 635 ret = scsi_compat_ioctl(sdev, cmd, argp);