ide-atapi: don't abuse rq->buffer
[GitHub/LineageOS/android_kernel_motorola_exynos9610.git] / drivers / ide / ide-atapi.c
index 3e43b889dd64ab55422e5b1432831586a21b5cca..2894577237ba7cf99991a41c9b2d2c203c46dc95 100644 (file)
@@ -90,7 +90,7 @@ static void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk,
        blk_rq_init(NULL, rq);
        rq->cmd_type = REQ_TYPE_SPECIAL;
        rq->cmd_flags |= REQ_PREEMPT;
-       rq->buffer = (char *)pc;
+       rq->special = (char *)pc;
        rq->rq_disk = disk;
 
        if (pc->req_xfer) {
@@ -119,7 +119,7 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
 
        rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
        rq->cmd_type = REQ_TYPE_SPECIAL;
-       rq->buffer = (char *)pc;
+       rq->special = (char *)pc;
 
        if (pc->req_xfer) {
                rq->data = pc->buf;
@@ -254,16 +254,13 @@ EXPORT_SYMBOL_GPL(ide_cd_get_xferlen);
 
 void ide_read_bcount_and_ireason(ide_drive_t *drive, u16 *bcount, u8 *ireason)
 {
-       struct ide_cmd cmd;
+       struct ide_taskfile tf;
 
-       memset(&cmd, 0, sizeof(cmd));
-       cmd.tf_flags = IDE_TFLAG_IN_LBAH | IDE_TFLAG_IN_LBAM |
-                      IDE_TFLAG_IN_NSECT;
+       drive->hwif->tp_ops->tf_read(drive, &tf, IDE_VALID_NSECT |
+                                    IDE_VALID_LBAM | IDE_VALID_LBAH);
 
-       drive->hwif->tp_ops->tf_read(drive, &cmd);
-
-       *bcount = (cmd.tf.lbah << 8) | cmd.tf.lbam;
-       *ireason = cmd.tf.nsect & 3;
+       *bcount = (tf.lbah << 8) | tf.lbam;
+       *ireason = tf.nsect & 3;
 }
 EXPORT_SYMBOL_GPL(ide_read_bcount_and_ireason);
 
@@ -439,12 +436,12 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
        return ide_started;
 }
 
-static void ide_init_packet_cmd(struct ide_cmd *cmd, u32 tf_flags,
+static void ide_init_packet_cmd(struct ide_cmd *cmd, u8 valid_tf,
                                u16 bcount, u8 dma)
 {
-       cmd->protocol  = dma ? ATAPI_PROT_DMA : ATAPI_PROT_PIO;
-       cmd->tf_flags |= IDE_TFLAG_OUT_LBAH | IDE_TFLAG_OUT_LBAM |
-                        IDE_TFLAG_OUT_FEATURE | tf_flags;
+       cmd->protocol = dma ? ATAPI_PROT_DMA : ATAPI_PROT_PIO;
+       cmd->valid.out.tf = IDE_VALID_LBAH | IDE_VALID_LBAM |
+                           IDE_VALID_FEATURE | valid_tf;
        cmd->tf.command = ATA_CMD_PACKET;
        cmd->tf.feature = dma;          /* Use PIO/DMA */
        cmd->tf.lbam    = bcount & 0xff;
@@ -453,14 +450,11 @@ static void ide_init_packet_cmd(struct ide_cmd *cmd, u32 tf_flags,
 
 static u8 ide_read_ireason(ide_drive_t *drive)
 {
-       struct ide_cmd cmd;
-
-       memset(&cmd, 0, sizeof(cmd));
-       cmd.tf_flags = IDE_TFLAG_IN_NSECT;
+       struct ide_taskfile tf;
 
-       drive->hwif->tp_ops->tf_read(drive, &cmd);
+       drive->hwif->tp_ops->tf_read(drive, &tf, IDE_VALID_NSECT);
 
-       return cmd.tf.nsect & 3;
+       return tf.nsect & 3;
 }
 
 static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason)
@@ -588,12 +582,12 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
        ide_expiry_t *expiry = NULL;
        struct request *rq = hwif->rq;
        unsigned int timeout;
-       u32 tf_flags;
        u16 bcount;
+       u8 valid_tf;
        u8 drq_int = !!(drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT);
 
        if (dev_is_idecd(drive)) {
-               tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL;
+               valid_tf = IDE_VALID_NSECT | IDE_VALID_LBAL;
                bcount = ide_cd_get_xferlen(rq);
                expiry = ide_cd_expiry;
                timeout = ATAPI_WAIT_PC;
@@ -607,7 +601,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
                pc->xferred = 0;
                pc->cur_pos = pc->buf;
 
-               tf_flags = IDE_TFLAG_OUT_DEVICE;
+               valid_tf = IDE_VALID_DEVICE;
                bcount = ((drive->media == ide_tape) ?
                                pc->req_xfer :
                                min(pc->req_xfer, 63 * 1024));
@@ -627,7 +621,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
                                                       : WAIT_TAPE_CMD;
        }
 
-       ide_init_packet_cmd(cmd, tf_flags, bcount, drive->dma);
+       ide_init_packet_cmd(cmd, valid_tf, bcount, drive->dma);
 
        (void)do_rw_taskfile(drive, cmd);