Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 642f1490 authored by Jens Axboe's avatar Jens Axboe
Browse files

SG: Change sg_set_page() to take length and offset argument



Most drivers need to set length and offset as well, so may as well fold
those three lines into one.

Add sg_assign_page() for those two locations that only needed to set
the page, where the offset/length is set outside of the function context.

Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent bd6dee6f
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -1366,9 +1366,7 @@ new_segment:
				sg = sg_next(sg);
			}

			sg_set_page(sg, bvec->bv_page);
			sg->length = nbytes;
			sg->offset = bvec->bv_offset;
			sg_set_page(sg, bvec->bv_page, nbytes, bvec->bv_offset);
			nsegs++;
		}
		bvprv = bvec;
+1 −2
Original line number Diff line number Diff line
@@ -160,8 +160,7 @@ static int hmac_digest(struct hash_desc *pdesc, struct scatterlist *sg,

	sg_set_buf(sg1, ipad, bs);

	sg_set_page(&sg[1], (void *) sg);
	sg1[1].length = 0;
	sg_set_page(&sg[1], (void *) sg, 0, 0);
	sg_set_buf(sg2, opad, bs + ds);

	err = crypto_hash_digest(&desc, sg1, nbytes + bs, digest);
+2 −2
Original line number Diff line number Diff line
@@ -4689,8 +4689,8 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
		 * data in this function or read data in ata_sg_clean.
		 */
		offset = lsg->offset + lsg->length - qc->pad_len;
		sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT));
		psg->offset = offset_in_page(offset);
		sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT),
				qc->pad_len, offset_in_page(offset));

		if (qc->tf.flags & ATA_TFLAG_WRITE) {
			void *addr = kmap_atomic(sg_page(psg), KM_IRQ0);
+2 −7
Original line number Diff line number Diff line
@@ -150,13 +150,8 @@ cryptoloop_transfer(struct loop_device *lo, int cmd,
		u32 iv[4] = { 0, };
		iv[0] = cpu_to_le32(IV & 0xffffffff);

		sg_set_page(&sg_in, in_page);
		sg_in.offset = in_offs;
		sg_in.length = sz;

		sg_set_page(&sg_out, out_page);
		sg_out.offset = out_offs;
		sg_out.length = sz;
		sg_set_page(&sg_in, in_page, sz, in_offs);
		sg_set_page(&sg_out, out_page, sz, out_offs);

		desc.info = iv;
		err = encdecfunc(&desc, &sg_out, &sg_in, sz);
+3 −6
Original line number Diff line number Diff line
@@ -1428,9 +1428,8 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
	scmd->state = UB_CMDST_INIT;
	scmd->nsg = 1;
	sg = &scmd->sgv[0];
	sg_set_page(sg, virt_to_page(sc->top_sense));
	sg->offset = (unsigned long)sc->top_sense & (PAGE_SIZE-1);
	sg->length = UB_SENSE_SIZE;
	sg_set_page(sg, virt_to_page(sc->top_sense), UB_SENSE_SIZE,
			(unsigned long)sc->top_sense & (PAGE_SIZE-1));
	scmd->len = UB_SENSE_SIZE;
	scmd->lun = cmd->lun;
	scmd->done = ub_top_sense_done;
@@ -1864,9 +1863,7 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun,
	cmd->state = UB_CMDST_INIT;
	cmd->nsg = 1;
	sg = &cmd->sgv[0];
	sg_set_page(sg, virt_to_page(p));
	sg->offset = (unsigned long)p & (PAGE_SIZE-1);
	sg->length = 8;
	sg_set_page(sg, virt_to_page(p), 8, (unsigned long)p & (PAGE_SIZE-1));
	cmd->len = 8;
	cmd->lun = lun;
	cmd->done = ub_probe_done;
Loading