linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 2.6: ATAPI MO drive support
@ 2003-12-18 23:30 Pascal Schmidt
  2003-12-19  6:58 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pascal Schmidt @ 2003-12-18 23:30 UTC (permalink / raw)
  To: Linus Torvalds, Andrew Morton, Jens Axboe, linux-kernel


Hi!

The below patch is needed to support ATAPI MO drives in 2.6. ide-scsi
doesn't work any more for this, so ide-cd has to take over the job of
running the MO drive. Without this, there is no way to write to an
ATAPI MO drive.

This patch has been discussed with Linus and Jens already around test9
time and it was agreed this is the right way to go about it. I have
rediffed it against 2.6.0. Compiles, runs, works just fine for me.

Somebody please apply.


--- linux-2.6.0/drivers/ide/ide-cd.c	Thu Dec 18 23:36:59 2003
+++ linux-2.6.0-mo/drivers/ide/ide-cd.c	Thu Dec 18 23:46:47 2003
@@ -2242,6 +2242,7 @@ static int cdrom_read_toc(ide_drive_t *d
 		struct atapi_toc_header hdr;
 		struct atapi_toc_entry  ent;
 	} ms_tmp;
+	long last_written;
 
 	if (toc == NULL) {
 		/* Try to allocate space. */
@@ -2261,6 +2262,13 @@ static int cdrom_read_toc(ide_drive_t *d
 	if (CDROM_STATE_FLAGS(drive)->toc_valid)
 		return 0;
 
+	/* Try to get the total cdrom capacity. */
+	stat = cdrom_read_capacity(drive, &toc->capacity, sense);
+	if (stat)
+		toc->capacity = 0x1fffff;
+
+	set_capacity(drive->disk, toc->capacity * SECTORS_PER_FRAME);
+
 	/* First read just the header, so we know how long the TOC is. */
 	stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr,
 				    sizeof(struct atapi_toc_header), sense);
@@ -2368,13 +2376,11 @@ static int cdrom_read_toc(ide_drive_t *d
 	toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track);
 
 	/* Now try to get the total cdrom capacity. */
-	stat = cdrom_get_last_written(cdi, (long *) &toc->capacity);
-	if (stat || !toc->capacity)
-		stat = cdrom_read_capacity(drive, &toc->capacity, sense);
-	if (stat)
-		toc->capacity = 0x1fffff;
-
-	set_capacity(drive->disk, toc->capacity * SECTORS_PER_FRAME);
+	stat = cdrom_get_last_written(cdi, &last_written);
+	if (!stat && last_written) {
+		toc->capacity = last_written;
+		set_capacity(drive->disk, toc->capacity * SECTORS_PER_FRAME);
+	}
 
 	/* Remember that we've read this stuff. */
 	CDROM_STATE_FLAGS(drive)->toc_valid = 1;
@@ -3215,7 +3221,8 @@ int ide_cdrom_setup (ide_drive_t *drive)
 
 	nslots = ide_cdrom_probe_capabilities (drive);
 
-	if (CDROM_CONFIG_FLAGS(drive)->dvd_ram)
+	if (CDROM_CONFIG_FLAGS(drive)->dvd_ram ||
+	    CDROM_CONFIG_FLAGS(drive)->mo_drive)
 		set_disk_ro(drive->disk, 0);
 
 #if 0
--- linux-2.6.0/drivers/cdrom/cdrom.c	Thu Dec 18 23:36:59 2003
+++ linux-2.6.0-mo/drivers/cdrom/cdrom.c	Thu Dec 18 23:40:51 2003
@@ -426,7 +426,8 @@ int cdrom_open(struct cdrom_device_info 
 	if ((fp->f_flags & O_NONBLOCK) && (cdi->options & CDO_USE_FFLAGS))
 		ret = cdi->ops->open(cdi, 1);
 	else {
-		if ((fp->f_mode & FMODE_WRITE) && !CDROM_CAN(CDC_DVD_RAM))
+		if ((fp->f_mode & FMODE_WRITE) &&
+		    !(CDROM_CAN(CDC_DVD_RAM) || CDROM_CAN(CDC_MO_DRIVE)))
 			return -EROFS;
 
 		ret = open_for_data(cdi);


-- 
Ciao,
Pascal


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] 2.6: ATAPI MO drive support
  2003-12-18 23:30 [PATCH] 2.6: ATAPI MO drive support Pascal Schmidt
@ 2003-12-19  6:58 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2003-12-19  6:58 UTC (permalink / raw)
  To: Pascal Schmidt; +Cc: Linus Torvalds, Andrew Morton, linux-kernel

On Fri, Dec 19 2003, Pascal Schmidt wrote:
> 
> Hi!
> 
> The below patch is needed to support ATAPI MO drives in 2.6. ide-scsi
> doesn't work any more for this, so ide-cd has to take over the job of
> running the MO drive. Without this, there is no way to write to an
> ATAPI MO drive.
> 
> This patch has been discussed with Linus and Jens already around test9
> time and it was agreed this is the right way to go about it. I have
> rediffed it against 2.6.0. Compiles, runs, works just fine for me.

Thanks for reminding us, I'm fine with the patch and it should be
applied.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-12-19  6:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-18 23:30 [PATCH] 2.6: ATAPI MO drive support Pascal Schmidt
2003-12-19  6:58 ` Jens Axboe

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