Commit 42c4d9c7 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ATAPI MO support update

From: Jens Axboe <axboe@suse.de>

Update the ATAPI MO support code to reflect the reorganisations and cleanups
which the Mt Ranier support patch added.

DESC
cdrom_open fix
EDESC
From: Jens Axboe <axboe@suse.de>
parent 62950936
...@@ -707,6 +707,11 @@ static int cdrom_open_write(struct cdrom_device_info *cdi) ...@@ -707,6 +707,11 @@ static int cdrom_open_write(struct cdrom_device_info *cdi)
ret = cdrom_mrw_open_write(cdi); ret = cdrom_mrw_open_write(cdi);
else if (CDROM_CAN(CDC_DVD_RAM)) else if (CDROM_CAN(CDC_DVD_RAM))
ret = cdrom_dvdram_open_write(cdi); ret = cdrom_dvdram_open_write(cdi);
/*
* needs to really check whether media is writeable
*/
else if (CDROM_CAN(CDC_MO_DRIVE))
ret = 0;
return ret; return ret;
} }
...@@ -733,29 +738,34 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp) ...@@ -733,29 +738,34 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp)
int ret; int ret;
cdinfo(CD_OPEN, "entering cdrom_open\n"); cdinfo(CD_OPEN, "entering cdrom_open\n");
ret = -EROFS;
if (fp->f_mode & FMODE_WRITE) {
if (!(CDROM_CAN(CDC_RAM) || CDROM_CAN(CDC_MO_DRIVE)))
goto out;
if (cdrom_open_write(cdi))
goto out;
}
/* if this was a O_NONBLOCK open and we should honor the flags, /* if this was a O_NONBLOCK open and we should honor the flags,
* do a quick open without drive/disc integrity checks. */ * do a quick open without drive/disc integrity checks. */
if ((fp->f_flags & O_NONBLOCK) && (cdi->options & CDO_USE_FFLAGS)) cdi->use_count++;
if ((fp->f_flags & O_NONBLOCK) && (cdi->options & CDO_USE_FFLAGS)) {
ret = cdi->ops->open(cdi, 1); ret = cdi->ops->open(cdi, 1);
else } else {
if (fp->f_mode & FMODE_WRITE) {
ret = -EROFS;
if (!CDROM_CAN(CDC_RAM))
goto err;
if (cdrom_open_write(cdi))
goto err;
}
ret = open_for_data(cdi); ret = open_for_data(cdi);
}
if (!ret) if (ret)
cdi->use_count++; goto err;
cdinfo(CD_OPEN, "Use count for \"/dev/%s\" now %d\n", cdi->name, cdi->use_count); cdinfo(CD_OPEN, "Use count for \"/dev/%s\" now %d\n",
cdi->name, cdi->use_count);
/* Do this on open. Don't wait for mount, because they might /* Do this on open. Don't wait for mount, because they might
not be mounting, but opening with O_NONBLOCK */ not be mounting, but opening with O_NONBLOCK */
check_disk_change(ip->i_bdev); check_disk_change(ip->i_bdev);
out: return 0;
err:
cdi->use_count--;
return ret; return ret;
} }
......
...@@ -790,7 +790,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) ...@@ -790,7 +790,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
* devices will return this error while flushing * devices will return this error while flushing
* data from cache */ * data from cache */
if (!rq->errors) if (!rq->errors)
info->write_timeout = jiffies + ATAPI_WAIT_BUSY; info->write_timeout = jiffies + ATAPI_WAIT_WRITE_BUSY;
rq->errors = 1; rq->errors = 1;
if (time_after(jiffies, info->write_timeout)) if (time_after(jiffies, info->write_timeout))
do_end_request = 1; do_end_request = 1;
...@@ -2950,6 +2950,7 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) ...@@ -2950,6 +2950,7 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive)
if (drive->media == ide_optical) { if (drive->media == ide_optical) {
CDROM_CONFIG_FLAGS(drive)->mo_drive = 1; CDROM_CONFIG_FLAGS(drive)->mo_drive = 1;
CDROM_CONFIG_FLAGS(drive)->ram = 1;
printk("%s: ATAPI magneto-optical drive\n", drive->name); printk("%s: ATAPI magneto-optical drive\n", drive->name);
return nslots; return nslots;
} }
...@@ -3281,9 +3282,7 @@ int ide_cdrom_setup (ide_drive_t *drive) ...@@ -3281,9 +3282,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
/* /*
* set correct block size and read-only for non-ram media * set correct block size and read-only for non-ram media
*/ */
set_disk_ro(drive->disk, set_disk_ro(drive->disk, !CDROM_CONFIG_FLAGS(drive)->ram);
!(CDROM_CONFIG_FLAGS(drive)->ram ||
CDROM_CONFIG_FLAGS(drive)->mo_drive));
blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE); blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE);
#if 0 #if 0
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
* typical timeout for packet command * typical timeout for packet command
*/ */
#define ATAPI_WAIT_PC (60 * HZ) #define ATAPI_WAIT_PC (60 * HZ)
#define ATAPI_WAIT_BUSY (5 * HZ) #define ATAPI_WAIT_WRITE_BUSY (10 * HZ)
/************************************************************************/ /************************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment