LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Maarten Bressers <mbres@gentoo.org>
To: linux-kernel@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
Cc: axboe@kernel.dk
Cc: James.Bottomley@SteelEye.com
Cc: tasio@hierro.tasio.net
Cc: dsd@gentoo.org
Subject: [PATCH RESEND] SCSI not showing tray status correctly
Date: Thu, 25 Oct 2007 22:30:37 +0000 (UTC)	[thread overview]
Message-ID: <20071025223037.C077D65309@smtp.gentoo.org> (raw)

From: David Martin <tasio@tasio.net>

Greetings,

The following patch was submitted to the lkml in 2004 by David Martin
(http://lkml.org/lkml/2004/12/27/1). It wasn't accepted, but I was
unable to find a reason why, so I'm resending it now.

Without this patch the SCSI ioctl CDROM_DRIVE_STATUS always returns
CDS_TRAY_OPEN even if the tray is closed. This patch fixes that.
Gentoo bug report: http://bugs.gentoo.org/show_bug.cgi?id=196879

Signed-off by: Maarten Bressers <mbres@gentoo.org>

---

--- a/drivers/scsi/sr_ioctl.c	2007-10-09 22:31:38.000000000 +0200
+++ b/drivers/scsi/sr_ioctl.c	2007-10-25 22:57:21.000000000 +0200
@@ -310,6 +310,8 @@ int sr_lock_door(struct cdrom_device_inf
 
 int sr_drive_status(struct cdrom_device_info *cdi, int slot)
 {
+	struct media_event_desc med;
+
 	if (CDSL_CURRENT != slot) {
 		/* we have no changer support */
 		return -EINVAL;
@@ -317,7 +319,10 @@ int sr_drive_status(struct cdrom_device_
 	if (0 == test_unit_ready(cdi->handle))
 		return CDS_DISC_OK;
 
-	return CDS_TRAY_OPEN;
+	if (!cdrom_get_media_event(cdi, &med) && med.door_open)
+		return CDS_TRAY_OPEN;
+
+	return CDS_NO_DISC;
 }
 
 int sr_disk_status(struct cdrom_device_info *cdi)

             reply	other threads:[~2007-10-25 22:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-25 22:30 Maarten Bressers [this message]
2007-10-25 23:24 ` James Bottomley
2007-10-27 22:58 Maarten Bressers
2007-10-31  3:32 ` James Bottomley

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=20071025223037.C077D65309@smtp.gentoo.org \
    --to=mbres@gentoo.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --subject='Re: [PATCH RESEND] SCSI not showing tray status correctly' \
    /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

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).