![Tejun Heo](/assets/img/avatar_default.png)
The usage of TUR has been confusing involving several different commits updating different parts over time. Currently, the only differences between scsi_test_unit_ready() and sr_test_unit_ready() are, * scsi_test_unit_ready() also sets sdev->changed on NOT_READY. * scsi_test_unit_ready() returns 0 if TUR ended with UNIT_ATTENTION or NOT_READY. Due to the above two differences, sr is using its own sr_test_unit_ready(), but sd - the sole user of the above extra handling - doesn't even need them. Where scsi_test_unit_ready() is used in sd_media_changed(), the code is looking for device ready w/ media present state which is true iff TUR succeeds w/o sense data or UA, and when the device is not ready for whatever reason sd_media_changed() explicitly marks media as missing so there's no reason to set sdev->changed automatically from scsi_test_unit_ready() on NOT_READY. Drop both special handlings from scsi_test_unit_ready(), which makes it equivalant to sr_test_unit_ready(), and replace sr_test_unit_ready() with scsi_test_unit_ready(). Also, drop the unnecessary explicit NOT_READY check from sd_media_changed(). Checking return value is enough for testing device readiness. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
71 lines
2.2 KiB
C
71 lines
2.2 KiB
C
/*
|
|
* sr.h by David Giller
|
|
* CD-ROM disk driver header file
|
|
*
|
|
* adapted from:
|
|
* sd.h Copyright (C) 1992 Drew Eckhardt
|
|
* SCSI disk driver header file by
|
|
* Drew Eckhardt
|
|
*
|
|
* <drew@colorado.edu>
|
|
*
|
|
* Modified by Eric Youngdale eric@andante.org to
|
|
* add scatter-gather, multiple outstanding request, and other
|
|
* enhancements.
|
|
*/
|
|
|
|
#ifndef _SR_H
|
|
#define _SR_H
|
|
|
|
#include <linux/genhd.h>
|
|
#include <linux/kref.h>
|
|
|
|
#define MAX_RETRIES 3
|
|
#define SR_TIMEOUT (30 * HZ)
|
|
|
|
struct scsi_device;
|
|
|
|
/* The CDROM is fairly slow, so we need a little extra time */
|
|
/* In fact, it is very slow if it has to spin up first */
|
|
#define IOCTL_TIMEOUT 30*HZ
|
|
|
|
|
|
typedef struct scsi_cd {
|
|
struct scsi_driver *driver;
|
|
unsigned capacity; /* size in blocks */
|
|
struct scsi_device *device;
|
|
unsigned int vendor; /* vendor code, see sr_vendor.c */
|
|
unsigned long ms_offset; /* for reading multisession-CD's */
|
|
unsigned use:1; /* is this device still supportable */
|
|
unsigned xa_flag:1; /* CD has XA sectors ? */
|
|
unsigned readcd_known:1; /* drive supports READ_CD (0xbe) */
|
|
unsigned readcd_cdda:1; /* reading audio data using READ_CD */
|
|
unsigned previous_state:1; /* media has changed */
|
|
struct cdrom_device_info cdi;
|
|
/* We hold gendisk and scsi_device references on probe and use
|
|
* the refs on this kref to decide when to release them */
|
|
struct kref kref;
|
|
struct gendisk *disk;
|
|
} Scsi_CD;
|
|
|
|
int sr_do_ioctl(Scsi_CD *, struct packet_command *);
|
|
|
|
int sr_lock_door(struct cdrom_device_info *, int);
|
|
int sr_tray_move(struct cdrom_device_info *, int);
|
|
int sr_drive_status(struct cdrom_device_info *, int);
|
|
int sr_disk_status(struct cdrom_device_info *);
|
|
int sr_get_last_session(struct cdrom_device_info *, struct cdrom_multisession *);
|
|
int sr_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *);
|
|
int sr_reset(struct cdrom_device_info *);
|
|
int sr_select_speed(struct cdrom_device_info *cdi, int speed);
|
|
int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);
|
|
|
|
int sr_is_xa(Scsi_CD *);
|
|
|
|
/* sr_vendor.c */
|
|
void sr_vendor_init(Scsi_CD *);
|
|
int sr_cd_check(struct cdrom_device_info *);
|
|
int sr_set_blocklength(Scsi_CD *, int blocklength);
|
|
|
|
#endif
|