mmap locking API: use coccinelle to convert mmap_sem rwsem call sites
[linux-2.6-microblaze.git] / drivers / infiniband / sw / siw / siw_mem.c
index e2061dc..34a910c 100644 (file)
@@ -349,14 +349,11 @@ dma_addr_t siw_pbl_get_buffer(struct siw_pbl *pbl, u64 off, int *len, int *idx)
 struct siw_pbl *siw_pbl_alloc(u32 num_buf)
 {
        struct siw_pbl *pbl;
-       int buf_size = sizeof(*pbl);
 
        if (num_buf == 0)
                return ERR_PTR(-EINVAL);
 
-       buf_size += ((num_buf - 1) * sizeof(struct siw_pble));
-
-       pbl = kzalloc(buf_size, GFP_KERNEL);
+       pbl = kzalloc(struct_size(pbl, pbe, num_buf), GFP_KERNEL);
        if (!pbl)
                return ERR_PTR(-ENOMEM);
 
@@ -397,7 +394,7 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable)
        if (!writable)
                foll_flags |= FOLL_FORCE;
 
-       down_read(&mm_s->mmap_sem);
+       mmap_read_lock(mm_s);
 
        mlock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
 
@@ -441,7 +438,7 @@ struct siw_umem *siw_umem_get(u64 start, u64 len, bool writable)
                num_pages -= got;
        }
 out_sem_up:
-       up_read(&mm_s->mmap_sem);
+       mmap_read_unlock(mm_s);
 
        if (rv > 0)
                return umem;