aboutsummaryrefslogtreecommitdiffstats
path: root/block/scsi_ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/scsi_ioctl.c')
-rw-r--r--block/scsi_ioctl.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 4e390dfd3157..1d8852f7bbff 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -442,11 +442,37 @@ error:
442 return err; 442 return err;
443} 443}
444 444
445
446/* Send basic block requests */
447static int __blk_send_generic(request_queue_t *q, struct gendisk *bd_disk, int cmd, int data)
448{
449 struct request *rq;
450 int err;
451
452 rq = blk_get_request(q, WRITE, __GFP_WAIT);
453 rq->flags |= REQ_BLOCK_PC;
454 rq->data = NULL;
455 rq->data_len = 0;
456 rq->timeout = BLK_DEFAULT_TIMEOUT;
457 memset(rq->cmd, 0, sizeof(rq->cmd));
458 rq->cmd[0] = cmd;
459 rq->cmd[4] = data;
460 rq->cmd_len = 6;
461 err = blk_execute_rq(q, bd_disk, rq, 0);
462 blk_put_request(rq);
463
464 return err;
465}
466
467static inline int blk_send_start_stop(request_queue_t *q, struct gendisk *bd_disk, int data)
468{
469 return __blk_send_generic(q, bd_disk, GPCMD_START_STOP_UNIT, data);
470}
471
445int scsi_cmd_ioctl(struct file *file, struct gendisk *bd_disk, unsigned int cmd, void __user *arg) 472int scsi_cmd_ioctl(struct file *file, struct gendisk *bd_disk, unsigned int cmd, void __user *arg)
446{ 473{
447 request_queue_t *q; 474 request_queue_t *q;
448 struct request *rq; 475 int err;
449 int close = 0, err;
450 476
451 q = bd_disk->queue; 477 q = bd_disk->queue;
452 if (!q) 478 if (!q)
@@ -564,19 +590,10 @@ int scsi_cmd_ioctl(struct file *file, struct gendisk *bd_disk, unsigned int cmd,
564 err = sg_scsi_ioctl(file, q, bd_disk, arg); 590 err = sg_scsi_ioctl(file, q, bd_disk, arg);
565 break; 591 break;
566 case CDROMCLOSETRAY: 592 case CDROMCLOSETRAY:
567 close = 1; 593 err = blk_send_start_stop(q, bd_disk, 0x03);
594 break;
568 case CDROMEJECT: 595 case CDROMEJECT:
569 rq = blk_get_request(q, WRITE, __GFP_WAIT); 596 err = blk_send_start_stop(q, bd_disk, 0x02);
570 rq->flags |= REQ_BLOCK_PC;
571 rq->data = NULL;
572 rq->data_len = 0;
573 rq->timeout = BLK_DEFAULT_TIMEOUT;
574 memset(rq->cmd, 0, sizeof(rq->cmd));
575 rq->cmd[0] = GPCMD_START_STOP_UNIT;
576 rq->cmd[4] = 0x02 + (close != 0);
577 rq->cmd_len = 6;
578 err = blk_execute_rq(q, bd_disk, rq, 0);
579 blk_put_request(rq);
580 break; 597 break;
581 default: 598 default:
582 err = -ENOTTY; 599 err = -ENOTTY;