diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-01-25 20:19:08 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-01-25 20:19:08 -0500 |
commit | 9b73e76f3cf63379dcf45fcd4f112f5812418d0a (patch) | |
tree | 4e6bef87cd0cd6d848fc39a5ae25b981dbbe035b /drivers/scsi/sr_ioctl.c | |
parent | 50d9a126240f9961cfdd063336bbeb91f77a7dce (diff) | |
parent | 23c3e290fb9ce38cabc2822b47583fc8702411bf (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (200 commits)
[SCSI] usbstorage: use last_sector_bug flag universally
[SCSI] libsas: abstract STP task status into a function
[SCSI] ultrastor: clean up inline asm warnings
[SCSI] aic7xxx: fix firmware build
[SCSI] aacraid: fib context lock for management ioctls
[SCSI] ch: remove forward declarations
[SCSI] ch: fix device minor number management bug
[SCSI] ch: handle class_device_create failure properly
[SCSI] NCR5380: fix section mismatch
[SCSI] sg: fix /proc/scsi/sg/devices when no SCSI devices
[SCSI] IB/iSER: add logical unit reset support
[SCSI] don't use __GFP_DMA for sense buffers if not required
[SCSI] use dynamically allocated sense buffer
[SCSI] scsi.h: add macro for enclosure bit of inquiry data
[SCSI] sd: add fix for devices with last sector access problems
[SCSI] fix pcmcia compile problem
[SCSI] aacraid: add Voodoo Lite class of cards.
[SCSI] aacraid: add new driver features flags
[SCSI] qla2xxx: Update version number to 8.02.00-k7.
[SCSI] qla2xxx: Issue correct MBC_INITIALIZE_FIRMWARE command.
...
Diffstat (limited to 'drivers/scsi/sr_ioctl.c')
-rw-r--r-- | drivers/scsi/sr_ioctl.c | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index e1589f91706a..d5cebff1d646 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c | |||
@@ -275,18 +275,6 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) | |||
275 | /* ---------------------------------------------------------------------- */ | 275 | /* ---------------------------------------------------------------------- */ |
276 | /* interface to cdrom.c */ | 276 | /* interface to cdrom.c */ |
277 | 277 | ||
278 | static int test_unit_ready(Scsi_CD *cd) | ||
279 | { | ||
280 | struct packet_command cgc; | ||
281 | |||
282 | memset(&cgc, 0, sizeof(struct packet_command)); | ||
283 | cgc.cmd[0] = GPCMD_TEST_UNIT_READY; | ||
284 | cgc.quiet = 1; | ||
285 | cgc.data_direction = DMA_NONE; | ||
286 | cgc.timeout = IOCTL_TIMEOUT; | ||
287 | return sr_do_ioctl(cd, &cgc); | ||
288 | } | ||
289 | |||
290 | int sr_tray_move(struct cdrom_device_info *cdi, int pos) | 278 | int sr_tray_move(struct cdrom_device_info *cdi, int pos) |
291 | { | 279 | { |
292 | Scsi_CD *cd = cdi->handle; | 280 | Scsi_CD *cd = cdi->handle; |
@@ -310,14 +298,46 @@ int sr_lock_door(struct cdrom_device_info *cdi, int lock) | |||
310 | 298 | ||
311 | int sr_drive_status(struct cdrom_device_info *cdi, int slot) | 299 | int sr_drive_status(struct cdrom_device_info *cdi, int slot) |
312 | { | 300 | { |
301 | struct scsi_cd *cd = cdi->handle; | ||
302 | struct scsi_sense_hdr sshdr; | ||
303 | struct media_event_desc med; | ||
304 | |||
313 | if (CDSL_CURRENT != slot) { | 305 | if (CDSL_CURRENT != slot) { |
314 | /* we have no changer support */ | 306 | /* we have no changer support */ |
315 | return -EINVAL; | 307 | return -EINVAL; |
316 | } | 308 | } |
317 | if (0 == test_unit_ready(cdi->handle)) | 309 | if (0 == scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, |
310 | &sshdr)) | ||
318 | return CDS_DISC_OK; | 311 | return CDS_DISC_OK; |
319 | 312 | ||
320 | return CDS_TRAY_OPEN; | 313 | if (!cdrom_get_media_event(cdi, &med)) { |
314 | if (med.media_present) | ||
315 | return CDS_DISC_OK; | ||
316 | else if (med.door_open) | ||
317 | return CDS_TRAY_OPEN; | ||
318 | else | ||
319 | return CDS_NO_DISC; | ||
320 | } | ||
321 | |||
322 | /* | ||
323 | * 0x04 is format in progress .. but there must be a disc present! | ||
324 | */ | ||
325 | if (sshdr.sense_key == NOT_READY && sshdr.asc == 0x04) | ||
326 | return CDS_DISC_OK; | ||
327 | |||
328 | /* | ||
329 | * If not using Mt Fuji extended media tray reports, | ||
330 | * just return TRAY_OPEN since ATAPI doesn't provide | ||
331 | * any other way to detect this... | ||
332 | */ | ||
333 | if (scsi_sense_valid(&sshdr) && | ||
334 | /* 0x3a is medium not present */ | ||
335 | sshdr.asc == 0x3a) | ||
336 | return CDS_NO_DISC; | ||
337 | else | ||
338 | return CDS_TRAY_OPEN; | ||
339 | |||
340 | return CDS_DRIVE_NOT_READY; | ||
321 | } | 341 | } |
322 | 342 | ||
323 | int sr_disk_status(struct cdrom_device_info *cdi) | 343 | int sr_disk_status(struct cdrom_device_info *cdi) |