Commit 2c257a5a authored by Jens Axboe's avatar Jens Axboe Committed by Linus Torvalds

[PATCH] fix cdrom mt rainier probe

Mt rainier probe must be deferred to media load time, since it requires a
valid media (the drive may present a different capability based on what
media is loaded).  This fixes that for ide-cd and sr.
Signed-Off-By: default avatarJens Axboe <axboe@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 17ced6b4
...@@ -508,6 +508,8 @@ int cdrom_is_mrw(struct cdrom_device_info *cdi, int *write) ...@@ -508,6 +508,8 @@ int cdrom_is_mrw(struct cdrom_device_info *cdi, int *write)
unsigned char buffer[16]; unsigned char buffer[16];
int ret; int ret;
*write = 0;
init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_READ); init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_READ);
cgc.cmd[0] = GPCMD_GET_CONFIGURATION; cgc.cmd[0] = GPCMD_GET_CONFIGURATION;
...@@ -521,8 +523,10 @@ int cdrom_is_mrw(struct cdrom_device_info *cdi, int *write) ...@@ -521,8 +523,10 @@ int cdrom_is_mrw(struct cdrom_device_info *cdi, int *write)
mfd = (struct mrw_feature_desc *)&buffer[sizeof(struct feature_header)]; mfd = (struct mrw_feature_desc *)&buffer[sizeof(struct feature_header)];
*write = mfd->write; *write = mfd->write;
if ((ret = cdrom_mrw_probe_pc(cdi))) if ((ret = cdrom_mrw_probe_pc(cdi))) {
*write = 0;
return ret; return ret;
}
return 0; return 0;
} }
...@@ -822,8 +826,30 @@ static int cdrom_ram_open_write(struct cdrom_device_info *cdi) ...@@ -822,8 +826,30 @@ static int cdrom_ram_open_write(struct cdrom_device_info *cdi)
*/ */
static int cdrom_open_write(struct cdrom_device_info *cdi) static int cdrom_open_write(struct cdrom_device_info *cdi)
{ {
int mrw, mrw_write, ram_write;
int ret = 1; int ret = 1;
mrw = 0;
if (!cdrom_is_mrw(cdi, &mrw_write))
mrw = 1;
(void) cdrom_is_random_writable(cdi, &ram_write);
if (mrw)
cdi->mask &= ~CDC_MRW;
else
cdi->mask |= CDC_MRW;
if (mrw_write)
cdi->mask &= ~CDC_MRW_W;
else
cdi->mask |= CDC_MRW_W;
if (ram_write)
cdi->mask &= ~CDC_RAM;
else
cdi->mask |= CDC_RAM;
if (CDROM_CAN(CDC_MRW_W)) if (CDROM_CAN(CDC_MRW_W))
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))
...@@ -866,6 +892,9 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp) ...@@ -866,6 +892,9 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp)
if ((fp->f_flags & O_NONBLOCK) && (cdi->options & CDO_USE_FFLAGS)) { 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 {
ret = open_for_data(cdi);
if (ret)
goto err;
if (fp->f_mode & FMODE_WRITE) { if (fp->f_mode & FMODE_WRITE) {
ret = -EROFS; ret = -EROFS;
if (!CDROM_CAN(CDC_RAM)) if (!CDROM_CAN(CDC_RAM))
...@@ -873,7 +902,6 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp) ...@@ -873,7 +902,6 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp)
if (cdrom_open_write(cdi)) if (cdrom_open_write(cdi))
goto err; goto err;
} }
ret = open_for_data(cdi);
} }
if (ret) if (ret)
......
...@@ -2816,7 +2816,6 @@ int ide_cdrom_open_real (struct cdrom_device_info *cdi, int purpose) ...@@ -2816,7 +2816,6 @@ int ide_cdrom_open_real (struct cdrom_device_info *cdi, int purpose)
return 0; return 0;
} }
/* /*
* Close down the device. Invalidate all cached blocks. * Close down the device. Invalidate all cached blocks.
*/ */
...@@ -2890,12 +2889,6 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots) ...@@ -2890,12 +2889,6 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots)
devinfo->mask |= CDC_CLOSE_TRAY; devinfo->mask |= CDC_CLOSE_TRAY;
if (!CDROM_CONFIG_FLAGS(drive)->mo_drive) if (!CDROM_CONFIG_FLAGS(drive)->mo_drive)
devinfo->mask |= CDC_MO_DRIVE; devinfo->mask |= CDC_MO_DRIVE;
if (!CDROM_CONFIG_FLAGS(drive)->mrw)
devinfo->mask |= CDC_MRW;
if (!CDROM_CONFIG_FLAGS(drive)->mrw_w)
devinfo->mask |= CDC_MRW_W;
if (!CDROM_CONFIG_FLAGS(drive)->ram)
devinfo->mask |= CDC_RAM;
devinfo->disk = drive->disk; devinfo->disk = drive->disk;
return register_cdrom(devinfo); return register_cdrom(devinfo);
...@@ -2932,7 +2925,7 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) ...@@ -2932,7 +2925,7 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive)
struct cdrom_info *info = drive->driver_data; struct cdrom_info *info = drive->driver_data;
struct cdrom_device_info *cdi = &info->devinfo; struct cdrom_device_info *cdi = &info->devinfo;
struct atapi_capabilities_page cap; struct atapi_capabilities_page cap;
int nslots = 1, mrw_write = 0, ram_write = 0; int nslots = 1;
if (drive->media == ide_optical) { if (drive->media == ide_optical) {
CDROM_CONFIG_FLAGS(drive)->mo_drive = 1; CDROM_CONFIG_FLAGS(drive)->mo_drive = 1;
...@@ -2961,17 +2954,6 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) ...@@ -2961,17 +2954,6 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive)
if (ide_cdrom_get_capabilities(drive, &cap)) if (ide_cdrom_get_capabilities(drive, &cap))
return 0; return 0;
if (!cdrom_is_mrw(cdi, &mrw_write)) {
CDROM_CONFIG_FLAGS(drive)->mrw = 1;
if (mrw_write) {
CDROM_CONFIG_FLAGS(drive)->mrw_w = 1;
CDROM_CONFIG_FLAGS(drive)->ram = 1;
}
}
if (!cdrom_is_random_writable(cdi, &ram_write))
if (ram_write)
CDROM_CONFIG_FLAGS(drive)->ram = 1;
if (cap.lock == 0) if (cap.lock == 0)
CDROM_CONFIG_FLAGS(drive)->no_doorlock = 1; CDROM_CONFIG_FLAGS(drive)->no_doorlock = 1;
if (cap.eject) if (cap.eject)
...@@ -3051,9 +3033,6 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) ...@@ -3051,9 +3033,6 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive)
(CDROM_CONFIG_FLAGS(drive)->cd_r)? "-R" : "", (CDROM_CONFIG_FLAGS(drive)->cd_r)? "-R" : "",
(CDROM_CONFIG_FLAGS(drive)->cd_rw)? "/RW" : ""); (CDROM_CONFIG_FLAGS(drive)->cd_rw)? "/RW" : "");
if (CDROM_CONFIG_FLAGS(drive)->mrw || CDROM_CONFIG_FLAGS(drive)->mrw_w)
printk(" CD-MR%s", CDROM_CONFIG_FLAGS(drive)->mrw_w ? "W" : "");
if (CDROM_CONFIG_FLAGS(drive)->is_changer) if (CDROM_CONFIG_FLAGS(drive)->is_changer)
printk(" changer w/%d slots", nslots); printk(" changer w/%d slots", nslots);
else else
......
...@@ -79,8 +79,6 @@ struct ide_cd_config_flags { ...@@ -79,8 +79,6 @@ struct ide_cd_config_flags {
__u8 dvd : 1; /* Drive is a DVD-ROM */ __u8 dvd : 1; /* Drive is a DVD-ROM */
__u8 dvd_r : 1; /* Drive can write DVD-R */ __u8 dvd_r : 1; /* Drive can write DVD-R */
__u8 dvd_ram : 1; /* Drive can write DVD-RAM */ __u8 dvd_ram : 1; /* Drive can write DVD-RAM */
__u8 mrw : 1; /* drive can read mrw */
__u8 mrw_w : 1; /* drive can write mrw */
__u8 ram : 1; /* generic WRITE (dvd-ram/mrw) */ __u8 ram : 1; /* generic WRITE (dvd-ram/mrw) */
__u8 test_write : 1; /* Drive can fake writes */ __u8 test_write : 1; /* Drive can fake writes */
__u8 supp_disc_present : 1; /* Changer can report exact contents __u8 supp_disc_present : 1; /* Changer can report exact contents
......
...@@ -754,12 +754,11 @@ static void get_sectorsize(struct scsi_cd *cd) ...@@ -754,12 +754,11 @@ static void get_sectorsize(struct scsi_cd *cd)
static void get_capabilities(struct scsi_cd *cd) static void get_capabilities(struct scsi_cd *cd)
{ {
unsigned char *buffer; unsigned char *buffer;
int rc, n, mrw_write = 0, mrw = 1,ram_write=0;
struct scsi_mode_data data; struct scsi_mode_data data;
struct scsi_request *SRpnt; struct scsi_request *SRpnt;
unsigned char cmd[MAX_COMMAND_SIZE]; unsigned char cmd[MAX_COMMAND_SIZE];
unsigned int the_result; unsigned int the_result;
int retries; int retries, rc, n;
static char *loadmech[] = static char *loadmech[] =
{ {
...@@ -831,19 +830,6 @@ static void get_capabilities(struct scsi_cd *cd) ...@@ -831,19 +830,6 @@ static void get_capabilities(struct scsi_cd *cd)
return; return;
} }
if (cdrom_is_mrw(&cd->cdi, &mrw_write)) {
mrw = 0;
cd->cdi.mask |= CDC_MRW;
cd->cdi.mask |= CDC_MRW_W;
}
if (!mrw_write)
cd->cdi.mask |= CDC_MRW_W;
if (cdrom_is_random_writable(&cd->cdi, &ram_write))
cd->cdi.mask |= CDC_RAM;
if (!ram_write)
cd->cdi.mask |= CDC_RAM;
n = data.header_length + data.block_descriptor_length; n = data.header_length + data.block_descriptor_length;
cd->cdi.speed = ((buffer[n + 8] << 8) + buffer[n + 9]) / 176; cd->cdi.speed = ((buffer[n + 8] << 8) + buffer[n + 9]) / 176;
cd->readcd_known = 1; cd->readcd_known = 1;
......
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