aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/virtio_blk.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/virtio_blk.c')
-rw-r--r--drivers/block/virtio_blk.c39
1 files changed, 3 insertions, 36 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 43f19389647a..51042f0ba7e1 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -3,7 +3,6 @@
3#include <linux/blkdev.h> 3#include <linux/blkdev.h>
4#include <linux/hdreg.h> 4#include <linux/hdreg.h>
5#include <linux/virtio.h> 5#include <linux/virtio.h>
6#include <linux/virtio_ids.h>
7#include <linux/virtio_blk.h> 6#include <linux/virtio_blk.h>
8#include <linux/scatterlist.h> 7#include <linux/scatterlist.h>
9 8
@@ -183,34 +182,6 @@ static void do_virtblk_request(struct request_queue *q)
183 vblk->vq->vq_ops->kick(vblk->vq); 182 vblk->vq->vq_ops->kick(vblk->vq);
184} 183}
185 184
186/* return ATA identify data
187 */
188static int virtblk_identify(struct gendisk *disk, void *argp)
189{
190 struct virtio_blk *vblk = disk->private_data;
191 void *opaque;
192 int err = -ENOMEM;
193
194 opaque = kmalloc(VIRTIO_BLK_ID_BYTES, GFP_KERNEL);
195 if (!opaque)
196 goto out;
197
198 err = virtio_config_buf(vblk->vdev, VIRTIO_BLK_F_IDENTIFY,
199 offsetof(struct virtio_blk_config, identify), opaque,
200 VIRTIO_BLK_ID_BYTES);
201
202 if (err)
203 goto out_kfree;
204
205 if (copy_to_user(argp, opaque, VIRTIO_BLK_ID_BYTES))
206 err = -EFAULT;
207
208out_kfree:
209 kfree(opaque);
210out:
211 return err;
212}
213
214static void virtblk_prepare_flush(struct request_queue *q, struct request *req) 185static void virtblk_prepare_flush(struct request_queue *q, struct request *req)
215{ 186{
216 req->cmd_type = REQ_TYPE_LINUX_BLOCK; 187 req->cmd_type = REQ_TYPE_LINUX_BLOCK;
@@ -222,10 +193,6 @@ static int virtblk_ioctl(struct block_device *bdev, fmode_t mode,
222{ 193{
223 struct gendisk *disk = bdev->bd_disk; 194 struct gendisk *disk = bdev->bd_disk;
224 struct virtio_blk *vblk = disk->private_data; 195 struct virtio_blk *vblk = disk->private_data;
225 void __user *argp = (void __user *)data;
226
227 if (cmd == HDIO_GET_IDENTITY)
228 return virtblk_identify(disk, argp);
229 196
230 /* 197 /*
231 * Only allow the generic SCSI ioctls if the host can support it. 198 * Only allow the generic SCSI ioctls if the host can support it.
@@ -233,7 +200,8 @@ static int virtblk_ioctl(struct block_device *bdev, fmode_t mode,
233 if (!virtio_has_feature(vblk->vdev, VIRTIO_BLK_F_SCSI)) 200 if (!virtio_has_feature(vblk->vdev, VIRTIO_BLK_F_SCSI))
234 return -ENOTTY; 201 return -ENOTTY;
235 202
236 return scsi_cmd_ioctl(disk->queue, disk, mode, cmd, argp); 203 return scsi_cmd_ioctl(disk->queue, disk, mode, cmd,
204 (void __user *)data);
237} 205}
238 206
239/* We provide getgeo only to please some old bootloader/partitioning tools */ 207/* We provide getgeo only to please some old bootloader/partitioning tools */
@@ -332,7 +300,6 @@ static int __devinit virtblk_probe(struct virtio_device *vdev)
332 } 300 }
333 301
334 vblk->disk->queue->queuedata = vblk; 302 vblk->disk->queue->queuedata = vblk;
335 queue_flag_set_unlocked(QUEUE_FLAG_VIRT, vblk->disk->queue);
336 303
337 if (index < 26) { 304 if (index < 26) {
338 sprintf(vblk->disk->disk_name, "vd%c", 'a' + index % 26); 305 sprintf(vblk->disk->disk_name, "vd%c", 'a' + index % 26);
@@ -445,7 +412,7 @@ static struct virtio_device_id id_table[] = {
445static unsigned int features[] = { 412static unsigned int features[] = {
446 VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX, 413 VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX,
447 VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE, 414 VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE,
448 VIRTIO_BLK_F_SCSI, VIRTIO_BLK_F_IDENTIFY, VIRTIO_BLK_F_FLUSH 415 VIRTIO_BLK_F_SCSI, VIRTIO_BLK_F_FLUSH
449}; 416};
450 417
451/* 418/*