|
Michal Suchanek |
1ae1ec |
From 366ba7c71ef77c08d06b18ad61b26e2df7352338 Mon Sep 17 00:00:00 2001
|
|
Michal Suchanek |
1ae1ec |
From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= <flameeyes@flameeyes.com>
|
|
Michal Suchanek |
1ae1ec |
Date: Tue, 19 Nov 2019 21:37:08 +0000
|
|
Michal Suchanek |
1ae1ec |
Subject: [PATCH] cdrom: respect device capabilities during opening action
|
|
Michal Suchanek |
1ae1ec |
MIME-Version: 1.0
|
|
Michal Suchanek |
1ae1ec |
Content-Type: text/plain; charset=UTF-8
|
|
Michal Suchanek |
1ae1ec |
Content-Transfer-Encoding: 8bit
|
|
Michal Suchanek |
1ae1ec |
|
|
Michal Suchanek |
1ae1ec |
References: boo#1164632
|
|
Michal Suchanek |
1ae1ec |
Patch-mainline: v5.5-rc1
|
|
Michal Suchanek |
1ae1ec |
Git-commit: 366ba7c71ef77c08d06b18ad61b26e2df7352338
|
|
Michal Suchanek |
1ae1ec |
|
|
Michal Suchanek |
1ae1ec |
Reading the TOC only works if the device can play audio, otherwise
|
|
Michal Suchanek |
1ae1ec |
these commands fail (and possibly bring the device to an unhealthy
|
|
Michal Suchanek |
1ae1ec |
state.)
|
|
Michal Suchanek |
1ae1ec |
|
|
Michal Suchanek |
1ae1ec |
Similarly, cdrom_mmc3_profile() should only be called if the device
|
|
Michal Suchanek |
1ae1ec |
supports generic packet commands.
|
|
Michal Suchanek |
1ae1ec |
|
|
Michal Suchanek |
1ae1ec |
To: Jens Axboe <axboe@kernel.dk>
|
|
Michal Suchanek |
1ae1ec |
Cc: linux-kernel@vger.kernel.org
|
|
Michal Suchanek |
1ae1ec |
Cc: linux-scsi@vger.kernel.org
|
|
Michal Suchanek |
1ae1ec |
Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.com>
|
|
Michal Suchanek |
1ae1ec |
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
|
Michal Suchanek |
1ae1ec |
Acked-by: Michal Suchanek <msuchanek@suse.de>
|
|
Michal Suchanek |
1ae1ec |
---
|
|
Michal Suchanek |
1ae1ec |
drivers/cdrom/cdrom.c | 12 +++++++++++-
|
|
Michal Suchanek |
1ae1ec |
1 file changed, 11 insertions(+), 1 deletion(-)
|
|
Michal Suchanek |
1ae1ec |
|
|
Michal Suchanek |
1ae1ec |
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
|
|
Michal Suchanek |
1ae1ec |
index ac42ae4651ce..eebdcbef0578 100644
|
|
Michal Suchanek |
1ae1ec |
--- a/drivers/cdrom/cdrom.c
|
|
Michal Suchanek |
1ae1ec |
+++ b/drivers/cdrom/cdrom.c
|
|
Michal Suchanek |
1ae1ec |
@@ -996,6 +996,12 @@ static void cdrom_count_tracks(struct cdrom_device_info *cdi, tracktype *tracks)
|
|
Michal Suchanek |
1ae1ec |
tracks->xa = 0;
|
|
Michal Suchanek |
1ae1ec |
tracks->error = 0;
|
|
Michal Suchanek |
1ae1ec |
cd_dbg(CD_COUNT_TRACKS, "entering cdrom_count_tracks\n");
|
|
Michal Suchanek |
1ae1ec |
+
|
|
Michal Suchanek |
1ae1ec |
+ if (!CDROM_CAN(CDC_PLAY_AUDIO)) {
|
|
Michal Suchanek |
1ae1ec |
+ tracks->error = CDS_NO_INFO;
|
|
Michal Suchanek |
1ae1ec |
+ return;
|
|
Michal Suchanek |
1ae1ec |
+ }
|
|
Michal Suchanek |
1ae1ec |
+
|
|
Michal Suchanek |
1ae1ec |
/* Grab the TOC header so we can see how many tracks there are */
|
|
Michal Suchanek |
1ae1ec |
ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCHDR, &header);
|
|
Michal Suchanek |
1ae1ec |
if (ret) {
|
|
Michal Suchanek |
1ae1ec |
@@ -1162,7 +1168,8 @@ int cdrom_open(struct cdrom_device_info *cdi, struct block_device *bdev,
|
|
Michal Suchanek |
1ae1ec |
ret = open_for_data(cdi);
|
|
Michal Suchanek |
1ae1ec |
if (ret)
|
|
Michal Suchanek |
1ae1ec |
goto err;
|
|
Michal Suchanek |
1ae1ec |
- cdrom_mmc3_profile(cdi);
|
|
Michal Suchanek |
1ae1ec |
+ if (CDROM_CAN(CDC_GENERIC_PACKET))
|
|
Michal Suchanek |
1ae1ec |
+ cdrom_mmc3_profile(cdi);
|
|
Michal Suchanek |
1ae1ec |
if (mode & FMODE_WRITE) {
|
|
Michal Suchanek |
1ae1ec |
ret = -EROFS;
|
|
Michal Suchanek |
1ae1ec |
if (cdrom_open_write(cdi))
|
|
Michal Suchanek |
1ae1ec |
@@ -2882,6 +2889,9 @@ int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written)
|
|
Michal Suchanek |
1ae1ec |
it doesn't give enough information or fails. then we return
|
|
Michal Suchanek |
1ae1ec |
the toc contents. */
|
|
Michal Suchanek |
1ae1ec |
use_toc:
|
|
Michal Suchanek |
1ae1ec |
+ if (!CDROM_CAN(CDC_PLAY_AUDIO))
|
|
Michal Suchanek |
1ae1ec |
+ return -ENOSYS;
|
|
Michal Suchanek |
1ae1ec |
+
|
|
Michal Suchanek |
1ae1ec |
toc.cdte_format = CDROM_MSF;
|
|
Michal Suchanek |
1ae1ec |
toc.cdte_track = CDROM_LEADOUT;
|
|
Michal Suchanek |
1ae1ec |
if ((ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCENTRY, &toc)))
|
|
Michal Suchanek |
1ae1ec |
--
|
|
Michal Suchanek |
1ae1ec |
2.23.0
|
|
Michal Suchanek |
1ae1ec |
|