Skip to contentSkip to conversation

virtio_blk: use blk_rq_map_kern

PATCH In review Christoph Hellwig 2 participants 2 messages Sep 15, 2011 – Sep 17, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio_blk: use blk_rq_map_kern

Use blk_rq_map_kern instead of opencoding it for the serial sysfs attribute.

[Rusty, any chance to get this in through the block tree? I have some
other bits in that area pending for it]

drivers/block/virtio_blk.c +7 -11
Index: linux-2.6/drivers/block/virtio_blk.c
===================================================================
@@ -203,24 +203,20 @@ static int virtblk_get_id(struct gendisk
 {
 	struct virtio_blk *vblk = disk->private_data;
 	struct request *req;
-	struct bio *bio;
 	int err;
 
-	bio = bio_map_kern(vblk->disk->queue, id_str, VIRTIO_BLK_ID_BYTES,
-			   GFP_KERNEL);
-	if (IS_ERR(bio))
-		return PTR_ERR(bio);
+	req = blk_get_request(vblk->disk->queue, READ, GFP_KERNEL);
 
-	req = blk_make_request(vblk->disk->queue, bio, GFP_KERNEL);
-	if (IS_ERR(req)) {
-		bio_put(bio);
-		return PTR_ERR(req);
-	}
+	err = blk_rq_map_kern(vblk->disk->queue, req, id_str,
+			      VIRTIO_BLK_ID_BYTES, GFP_KERNEL);
+	if (err)
+		goto put_request;
 
 	req->cmd_type = REQ_TYPE_SPECIAL;
 	err = blk_execute_rq(vblk->disk->queue, vblk->disk, req, false);
-	blk_put_request(req);
 
+put_request:
+	blk_put_request(req);
 	return err;
 }