diff options
author | Ben Collins <bcollins@ubuntu.com> | 2005-12-19 14:49:24 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-12-19 19:47:50 -0500 |
commit | f98d2dfd02183e016a6295f72140c60d691c9188 (patch) | |
tree | d92ac89a1e5096f979bb93029b3f06e46973e7ca /block | |
parent | 931b11be325e0e866b64bac7cab64d51c7759371 (diff) |
[PATCH] block: Cleanup CDROMEJECT ioctl
This is just a basic cleanup. No change in functionality.
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'block')
-rw-r--r-- | block/scsi_ioctl.c | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index 382dea7b224c..6e7db2e79f42 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 */ | ||
447 | static 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 | |||
467 | static 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 | |||
445 | int scsi_cmd_ioctl(struct file *file, struct gendisk *bd_disk, unsigned int cmd, void __user *arg) | 472 | int 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; |