bsg: fix address space warning from sparse
authorNamhyung Kim <namhyung@gmail.com>
Mon, 20 Jun 2011 11:27:45 +0000 (13:27 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Mon, 20 Jun 2011 11:27:45 +0000 (13:27 +0200)
copy_from/to_user() and blk_rq_map_user() want __user pointer.
This patch fixes following warnings from sparse:

   CHECK   block/bsg.c
 block/bsg.c:185:38: warning: incorrect type in argument 2 (different address spaces)
 block/bsg.c:185:38:    expected void const [noderef] <asn:1>*from
 block/bsg.c:185:38:    got void *<noident>
 block/bsg.c:295:58: warning: incorrect type in argument 4 (different address spaces)
 block/bsg.c:295:58:    expected void [noderef] <asn:1>*<noident>
 block/bsg.c:295:58:    got void *[assigned] dxferp
 block/bsg.c:311:52: warning: incorrect type in argument 4 (different address spaces)
 block/bsg.c:311:52:    expected void [noderef] <asn:1>*<noident>
 block/bsg.c:311:52:    got void *[assigned] dxferp
 block/bsg.c:448:37: warning: incorrect type in argument 1 (different address spaces)
 block/bsg.c:448:37:    expected void [noderef] <asn:1>*dst
 block/bsg.c:448:37:    got void *<noident>

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>

block/bsg.c

index b7e42ad..702f131 100644 (file)
@@ -182,7 +182,7 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
                        return -ENOMEM;
        }
 
-       if (copy_from_user(rq->cmd, (void *)(unsigned long)hdr->request,
+       if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
                           hdr->request_len))
                return -EFAULT;
 
@@ -249,7 +249,7 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm,
        struct request *rq, *next_rq = NULL;
        int ret, rw;
        unsigned int dxfer_len;
-       void *dxferp = NULL;
+       void __user *dxferp = NULL;
        struct bsg_class_device *bcd = &q->bsg_dev;
 
        /* if the LLD has been removed then the bsg_unregister_queue will
@@ -291,7 +291,7 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm,
                rq->next_rq = next_rq;
                next_rq->cmd_type = rq->cmd_type;
 
-               dxferp = (void*)(unsigned long)hdr->din_xferp;
+               dxferp = (void __user *)(unsigned long)hdr->din_xferp;
                ret =  blk_rq_map_user(q, next_rq, NULL, dxferp,
                                       hdr->din_xfer_len, GFP_KERNEL);
                if (ret)
@@ -300,10 +300,10 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm,
 
        if (hdr->dout_xfer_len) {
                dxfer_len = hdr->dout_xfer_len;
-               dxferp = (void*)(unsigned long)hdr->dout_xferp;
+               dxferp = (void __user *)(unsigned long)hdr->dout_xferp;
        } else if (hdr->din_xfer_len) {
                dxfer_len = hdr->din_xfer_len;
-               dxferp = (void*)(unsigned long)hdr->din_xferp;
+               dxferp = (void __user *)(unsigned long)hdr->din_xferp;
        } else
                dxfer_len = 0;
 
@@ -445,7 +445,7 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr,
                int len = min_t(unsigned int, hdr->max_response_len,
                                        rq->sense_len);
 
-               ret = copy_to_user((void*)(unsigned long)hdr->response,
+               ret = copy_to_user((void __user *)(unsigned long)hdr->response,
                                   rq->sense, len);
                if (!ret)
                        hdr->response_len = len;