aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
Diffstat (limited to 'block')
-rw-r--r--block/blk-map.c19
-rw-r--r--block/bsg.c6
-rw-r--r--block/genhd.c2
3 files changed, 14 insertions, 13 deletions
diff --git a/block/blk-map.c b/block/blk-map.c
index 2990447f45e9..f103729b462f 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -42,7 +42,7 @@ static int __blk_rq_unmap_user(struct bio *bio)
42 42
43static int __blk_rq_map_user(struct request_queue *q, struct request *rq, 43static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
44 struct rq_map_data *map_data, void __user *ubuf, 44 struct rq_map_data *map_data, void __user *ubuf,
45 unsigned int len, int null_mapped, gfp_t gfp_mask) 45 unsigned int len, gfp_t gfp_mask)
46{ 46{
47 unsigned long uaddr; 47 unsigned long uaddr;
48 struct bio *bio, *orig_bio; 48 struct bio *bio, *orig_bio;
@@ -63,7 +63,7 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
63 if (IS_ERR(bio)) 63 if (IS_ERR(bio))
64 return PTR_ERR(bio); 64 return PTR_ERR(bio);
65 65
66 if (null_mapped) 66 if (map_data && map_data->null_mapped)
67 bio->bi_flags |= (1 << BIO_NULL_MAPPED); 67 bio->bi_flags |= (1 << BIO_NULL_MAPPED);
68 68
69 orig_bio = bio; 69 orig_bio = bio;
@@ -114,17 +114,15 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq,
114{ 114{
115 unsigned long bytes_read = 0; 115 unsigned long bytes_read = 0;
116 struct bio *bio = NULL; 116 struct bio *bio = NULL;
117 int ret, null_mapped = 0; 117 int ret;
118 118
119 if (len > (q->max_hw_sectors << 9)) 119 if (len > (q->max_hw_sectors << 9))
120 return -EINVAL; 120 return -EINVAL;
121 if (!len) 121 if (!len)
122 return -EINVAL; 122 return -EINVAL;
123 if (!ubuf) { 123
124 if (!map_data || rq_data_dir(rq) != READ) 124 if (!ubuf && (!map_data || !map_data->null_mapped))
125 return -EINVAL; 125 return -EINVAL;
126 null_mapped = 1;
127 }
128 126
129 while (bytes_read != len) { 127 while (bytes_read != len) {
130 unsigned long map_len, end, start; 128 unsigned long map_len, end, start;
@@ -143,13 +141,16 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq,
143 map_len -= PAGE_SIZE; 141 map_len -= PAGE_SIZE;
144 142
145 ret = __blk_rq_map_user(q, rq, map_data, ubuf, map_len, 143 ret = __blk_rq_map_user(q, rq, map_data, ubuf, map_len,
146 null_mapped, gfp_mask); 144 gfp_mask);
147 if (ret < 0) 145 if (ret < 0)
148 goto unmap_rq; 146 goto unmap_rq;
149 if (!bio) 147 if (!bio)
150 bio = rq->bio; 148 bio = rq->bio;
151 bytes_read += ret; 149 bytes_read += ret;
152 ubuf += ret; 150 ubuf += ret;
151
152 if (map_data)
153 map_data->offset += ret;
153 } 154 }
154 155
155 if (!bio_flagged(bio, BIO_USER_MAPPED)) 156 if (!bio_flagged(bio, BIO_USER_MAPPED))
diff --git a/block/bsg.c b/block/bsg.c
index e73e50daf3d0..d414bb5607e8 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -42,7 +42,7 @@ struct bsg_device {
42 int done_cmds; 42 int done_cmds;
43 wait_queue_head_t wq_done; 43 wait_queue_head_t wq_done;
44 wait_queue_head_t wq_free; 44 wait_queue_head_t wq_free;
45 char name[BUS_ID_SIZE]; 45 char name[20];
46 int max_queue; 46 int max_queue;
47 unsigned long flags; 47 unsigned long flags;
48}; 48};
@@ -781,7 +781,7 @@ static struct bsg_device *bsg_add_device(struct inode *inode,
781 mutex_lock(&bsg_mutex); 781 mutex_lock(&bsg_mutex);
782 hlist_add_head(&bd->dev_list, bsg_dev_idx_hash(iminor(inode))); 782 hlist_add_head(&bd->dev_list, bsg_dev_idx_hash(iminor(inode)));
783 783
784 strncpy(bd->name, rq->bsg_dev.class_dev->bus_id, sizeof(bd->name) - 1); 784 strncpy(bd->name, dev_name(rq->bsg_dev.class_dev), sizeof(bd->name) - 1);
785 dprintk("bound to <%s>, max queue %d\n", 785 dprintk("bound to <%s>, max queue %d\n",
786 format_dev_t(buf, inode->i_rdev), bd->max_queue); 786 format_dev_t(buf, inode->i_rdev), bd->max_queue);
787 787
@@ -992,7 +992,7 @@ int bsg_register_queue(struct request_queue *q, struct device *parent,
992 if (name) 992 if (name)
993 devname = name; 993 devname = name;
994 else 994 else
995 devname = parent->bus_id; 995 devname = dev_name(parent);
996 996
997 /* 997 /*
998 * we need a proper transport to send commands, not a stacked device 998 * we need a proper transport to send commands, not a stacked device
diff --git a/block/genhd.c b/block/genhd.c
index d84a7df1e2a0..397960cf26af 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1084,7 +1084,7 @@ dev_t blk_lookup_devt(const char *name, int partno)
1084 struct gendisk *disk = dev_to_disk(dev); 1084 struct gendisk *disk = dev_to_disk(dev);
1085 struct hd_struct *part; 1085 struct hd_struct *part;
1086 1086
1087 if (strcmp(dev->bus_id, name)) 1087 if (strcmp(dev_name(dev), name))
1088 continue; 1088 continue;
1089 1089
1090 part = disk_get_part(disk, partno); 1090 part = disk_get_part(disk, partno);