mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-11-18 15:44:02 +08:00
[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>
This commit is contained in:
parent
931b11be32
commit
f98d2dfd02
@ -442,11 +442,37 @@ error:
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/* Send basic block requests */
|
||||
static int __blk_send_generic(request_queue_t *q, struct gendisk *bd_disk, int cmd, int data)
|
||||
{
|
||||
struct request *rq;
|
||||
int err;
|
||||
|
||||
rq = blk_get_request(q, WRITE, __GFP_WAIT);
|
||||
rq->flags |= REQ_BLOCK_PC;
|
||||
rq->data = NULL;
|
||||
rq->data_len = 0;
|
||||
rq->timeout = BLK_DEFAULT_TIMEOUT;
|
||||
memset(rq->cmd, 0, sizeof(rq->cmd));
|
||||
rq->cmd[0] = cmd;
|
||||
rq->cmd[4] = data;
|
||||
rq->cmd_len = 6;
|
||||
err = blk_execute_rq(q, bd_disk, rq, 0);
|
||||
blk_put_request(rq);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static inline int blk_send_start_stop(request_queue_t *q, struct gendisk *bd_disk, int data)
|
||||
{
|
||||
return __blk_send_generic(q, bd_disk, GPCMD_START_STOP_UNIT, data);
|
||||
}
|
||||
|
||||
int scsi_cmd_ioctl(struct file *file, struct gendisk *bd_disk, unsigned int cmd, void __user *arg)
|
||||
{
|
||||
request_queue_t *q;
|
||||
struct request *rq;
|
||||
int close = 0, err;
|
||||
int err;
|
||||
|
||||
q = bd_disk->queue;
|
||||
if (!q)
|
||||
@ -564,19 +590,10 @@ int scsi_cmd_ioctl(struct file *file, struct gendisk *bd_disk, unsigned int cmd,
|
||||
err = sg_scsi_ioctl(file, q, bd_disk, arg);
|
||||
break;
|
||||
case CDROMCLOSETRAY:
|
||||
close = 1;
|
||||
err = blk_send_start_stop(q, bd_disk, 0x03);
|
||||
break;
|
||||
case CDROMEJECT:
|
||||
rq = blk_get_request(q, WRITE, __GFP_WAIT);
|
||||
rq->flags |= REQ_BLOCK_PC;
|
||||
rq->data = NULL;
|
||||
rq->data_len = 0;
|
||||
rq->timeout = BLK_DEFAULT_TIMEOUT;
|
||||
memset(rq->cmd, 0, sizeof(rq->cmd));
|
||||
rq->cmd[0] = GPCMD_START_STOP_UNIT;
|
||||
rq->cmd[4] = 0x02 + (close != 0);
|
||||
rq->cmd_len = 6;
|
||||
err = blk_execute_rq(q, bd_disk, rq, 0);
|
||||
blk_put_request(rq);
|
||||
err = blk_send_start_stop(q, bd_disk, 0x02);
|
||||
break;
|
||||
default:
|
||||
err = -ENOTTY;
|
||||
|
Loading…
Reference in New Issue
Block a user