From: Arnd Bergmann <arnd@arndb.de>
To: "James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Jens Axboe <axboe@kernel.dk>,
Tim Waugh <tim@cyberelk.net>, Borislav Petkov <bp@alien8.de>,
"David S. Miller" <davem@davemloft.net>,
Damien Le Moal <damien.lemoal@wdc.com>,
zhengbin <zhengbin13@huawei.com>, Hannes Reinecke <hare@suse.com>,
YueHaibing <yuehaibing@huawei.com>,
Martin Wilck <mwilck@suse.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Kefeng Wang <wangkefeng.wang@huawei.com>,
Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: [PATCH v3 16/22] compat_ioctl: move cdrom commands into cdrom.c
Date: Thu, 2 Jan 2020 15:55:34 +0100 [thread overview]
Message-ID: <20200102145552.1853992-17-arnd@arndb.de> (raw)
In-Reply-To: <20200102145552.1853992-1-arnd@arndb.de>
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.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
block/compat_ioctl.c | 45 --------------------------------------
drivers/block/paride/pcd.c | 3 +++
drivers/cdrom/gdrom.c | 3 +++
drivers/ide/ide-cd.c | 37 +++++++++++++++++++++++++++++++
drivers/scsi/sr.c | 8 ++-----
5 files changed, 45 insertions(+), 51 deletions(-)
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
index 91a5dcf6e36c..e1c5d07b09e5 100644
--- a/block/compat_ioctl.c
+++ b/block/compat_ioctl.c
@@ -160,42 +160,6 @@ static int compat_blkdev_driver_ioctl(struct block_device *bdev, fmode_t mode,
case HDIO_DRIVE_CMD:
/* 0x330 is reserved -- it used to be HDIO_GETGEO_BIG */
case 0x330:
- /* CDROM stuff */
- case CDROMPAUSE:
- case CDROMRESUME:
- case CDROMPLAYMSF:
- case CDROMPLAYTRKIND:
- case CDROMREADTOCHDR:
- case CDROMREADTOCENTRY:
- case CDROMSTOP:
- case CDROMSTART:
- case CDROMEJECT:
- case CDROMVOLCTRL:
- case CDROMSUBCHNL:
- case CDROMMULTISESSION:
- case CDROM_GET_MCN:
- case CDROMRESET:
- case CDROMVOLREAD:
- case CDROMSEEK:
- case CDROMPLAYBLK:
- case CDROMCLOSETRAY:
- case CDROM_DISC_STATUS:
- case CDROM_CHANGER_NSLOTS:
- case CDROM_GET_CAPABILITY:
- case CDROM_SEND_PACKET:
- /* Ignore cdrom.h about these next 5 ioctls, they absolutely do
- * not take a struct cdrom_read, instead they take a struct cdrom_msf
- * which is compatible.
- */
- case CDROMREADMODE2:
- case CDROMREADMODE1:
- case CDROMREADRAW:
- case CDROMREADCOOKED:
- case CDROMREADALL:
- /* DVD ioctls */
- case DVD_READ_STRUCT:
- case DVD_WRITE_STRUCT:
- case DVD_AUTH:
arg = (unsigned long)compat_ptr(arg);
/* These intepret arg as an unsigned long, not as a pointer,
* so we must not do compat_ptr() conversion. */
@@ -211,15 +175,6 @@ static int compat_blkdev_driver_ioctl(struct block_device *bdev, fmode_t mode,
case HDIO_SET_ACOUSTIC:
case HDIO_SET_BUSSTATE:
case HDIO_SET_ADDRESS:
- case CDROMEJECT_SW:
- case CDROM_SET_OPTIONS:
- case CDROM_CLEAR_OPTIONS:
- case CDROM_SELECT_SPEED:
- case CDROM_SELECT_DISC:
- case CDROM_MEDIA_CHANGED:
- case CDROM_DRIVE_STATUS:
- case CDROM_LOCKDOOR:
- case CDROM_DEBUG:
break;
default:
/* unknown ioctl number */
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index 636bfea2de6f..117cfc8cd05a 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -275,6 +275,9 @@ static const struct block_device_operations pcd_bdops = {
.open = pcd_block_open,
.release = pcd_block_release,
.ioctl = pcd_block_ioctl,
+#ifdef CONFIG_COMPAT
+ .ioctl = blkdev_compat_ptr_ioctl,
+#endif
.check_events = pcd_block_check_events,
};
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index 5b21dc421c94..886b2638c730 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -518,6 +518,9 @@ static const struct block_device_operations gdrom_bdops = {
.release = gdrom_bdops_release,
.check_events = gdrom_bdops_check_events,
.ioctl = gdrom_bdops_ioctl,
+#ifdef CONFIG_COMPAT
+ .ioctl = blkdev_compat_ptr_ioctl,
+#endif
};
static irqreturn_t gdrom_command_interrupt(int irq, void *dev_id)
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 9d117936bee1..e09b949a7c46 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -25,6 +25,7 @@
#define IDECD_VERSION "5.00"
+#include <linux/compat.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
@@ -1710,6 +1711,39 @@ static int idecd_ioctl(struct block_device *bdev, fmode_t mode,
return ret;
}
+#ifdef CONFIG_COMPAT
+static int idecd_locked_compat_ioctl(struct block_device *bdev, fmode_t mode,
+ unsigned int cmd, unsigned long arg)
+{
+ struct cdrom_info *info = ide_drv_g(bdev->bd_disk, cdrom_info);
+ void __user *argp = compat_ptr(arg);
+ int err;
+
+ switch (cmd) {
+ case CDROMSETSPINDOWN:
+ return idecd_set_spindown(&info->devinfo, (unsigned long)argp);
+ case CDROMGETSPINDOWN:
+ return idecd_get_spindown(&info->devinfo, (unsigned long)argp);
+ default:
+ break;
+ }
+
+ return cdrom_ioctl(&info->devinfo, bdev, mode, cmd,
+ (unsigned long)argp);
+}
+
+static int idecd_compat_ioctl(struct block_device *bdev, fmode_t mode,
+ unsigned int cmd, unsigned long arg)
+{
+ int ret;
+
+ mutex_lock(&ide_cd_mutex);
+ ret = idecd_locked_compat_ioctl(bdev, mode, cmd, arg);
+ mutex_unlock(&ide_cd_mutex);
+
+ return ret;
+}
+#endif
static unsigned int idecd_check_events(struct gendisk *disk,
unsigned int clearing)
@@ -1732,6 +1766,9 @@ static const struct block_device_operations idecd_ops = {
.open = idecd_open,
.release = idecd_release,
.ioctl = idecd_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = idecd_compat_ioctl,
+#endif
.check_events = idecd_check_events,
.revalidate_disk = idecd_revalidate_disk
};
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index f1e7aab00ce3..0fbb8fe6e521 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -628,12 +628,8 @@ static int sr_block_compat_ioctl(struct block_device *bdev, fmode_t mode, unsign
goto put;
}
- /*
- * CDROM ioctls are handled in the block layer, but
- * do the scsi blk ioctls here.
- */
- ret = scsi_cmd_blk_ioctl(bdev, mode, cmd, argp);
- if (ret != -ENOTTY)
+ ret = cdrom_ioctl(&cd->cdi, bdev, mode, cmd, (unsigned long)argp);
+ if (ret != -ENOSYS)
goto put;
ret = scsi_compat_ioctl(sdev, cmd, argp);
--
2.20.0
next prev parent reply other threads:[~2020-01-02 15:03 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-02 14:55 [GIT PULL v3 00/27] block, scsi: final compat_ioctl cleanup Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 03/22] compat: scsi: sg: fix v3 compat read/write interface Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 04/22] compat_ioctl: block: add blkdev_compat_ptr_ioctl Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 05/22] compat_ioctl: ubd, aoe: use blkdev_compat_ptr_ioctl Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 06/22] compat_ioctl: move CDROM_SEND_PACKET handling into scsi Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 07/22] compat_ioctl: move CDROMREADADIO to cdrom.c Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 08/22] compat_ioctl: cdrom: handle CDROM_LAST_WRITTEN Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 09/22] compat_ioctl: block: handle cdrom compat ioctl in non-cdrom drivers Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 11/22] compat_ioctl: bsg: add handler Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 13/22] compat_ioctl: scsi: move ioctl handling into drivers Arnd Bergmann
2020-01-02 16:33 ` Stefan Hajnoczi
2020-02-12 21:14 ` Johannes Hirte
2020-02-12 21:49 ` Arnd Bergmann
2020-02-13 6:53 ` Johannes Hirte
2020-01-02 14:55 ` Arnd Bergmann [this message]
2020-01-02 14:55 ` [PATCH v3 18/22] compat_ioctl: move HDIO ioctl handling into drivers/ide Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 19/22] compat_ioctl: block: move blkdev_compat_ioctl() into ioctl.c Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 20/22] compat_ioctl: block: simplify compat_blkpg_ioctl() Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 21/22] compat_ioctl: simplify up block/ioctl.c Arnd Bergmann
2020-01-02 20:22 ` [GIT PULL v3 00/27] block, scsi: final compat_ioctl cleanup Arnd Bergmann
2020-01-03 0:22 ` Ben Hutchings
2020-01-03 8:56 ` Arnd Bergmann
2020-01-03 3:02 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200102145552.1853992-17-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=axboe@kernel.dk \
--cc=bp@alien8.de \
--cc=damien.lemoal@wdc.com \
--cc=davem@davemloft.net \
--cc=hare@suse.com \
--cc=jejb@linux.ibm.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mchehab+samsung@kernel.org \
--cc=mwilck@suse.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=tim@cyberelk.net \
--cc=wangkefeng.wang@huawei.com \
--cc=yuehaibing@huawei.com \
--cc=zhengbin13@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).