Skip to content

Commit 59a4f6f

Browse files
htejunJens Axboe
authored andcommitted
ide-cd: clear sense buffer before issuing request sense
Impact: code simplification ide_cd_request_sense_fixup() clears the tail of the sense buffer if the device didn't completely fill it. This patch makes cdrom_queue_request_sense() clear the sense buffer before issuing the command instead of clearing it afterwards. This simplifies code and eases future changes. Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 214ae19 commit 59a4f6f

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

‎drivers/ide/ide-cd.c‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
217217
if (sense == NULL)
218218
sense = &info->sense_data;
219219

220+
memset(sense, 0, 18);
221+
220222
/* stuff the sense request in front of our current request */
221223
blk_rq_init(NULL, rq);
222224
rq->cmd_type = REQ_TYPE_ATA_PC;
@@ -504,14 +506,8 @@ static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct ide_cmd *cmd)
504506
* and some drives don't send them. Sigh.
505507
*/
506508
if (rq->cmd[0] == GPCMD_REQUEST_SENSE &&
507-
cmd->nleft > 0 && cmd->nleft <= 5) {
508-
unsigned int ofs = cmd->nbytes - cmd->nleft;
509-
510-
while (cmd->nleft > 0) {
511-
*((u8 *)rq->data + ofs++) = 0;
512-
cmd->nleft--;
513-
}
514-
}
509+
cmd->nleft > 0 && cmd->nleft <= 5)
510+
cmd->nleft = 0;
515511
}
516512

517513
int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,

0 commit comments

Comments
 (0)