diff options
author | Michael J. Ruhl <michael.j.ruhl@intel.com> | 2017-05-04 05:14:45 -0700 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2017-05-04 19:31:46 -0400 |
commit | 5042cddfd058a2db419ba7aaadc866e8dccca06c (patch) | |
tree | 4318d7df99e87e849fe1b7a85a26c70fea2b11c4 /drivers/infiniband/hw/hfi1/file_ops.c | |
parent | f4cd876529194b2d3f653c645ba203688e9e4ba3 (diff) |
IB/hfi1: Use filedata rather than filepointer
Since almost all functions that use the hfi1_filedata get the pointer
from the file pointer, simplify by only passing the hfi1_filedata pointer.
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/hw/hfi1/file_ops.c')
-rw-r--r-- | drivers/infiniband/hw/hfi1/file_ops.c | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c index 0b77283078e5..ab798a81d6b4 100644 --- a/drivers/infiniband/hw/hfi1/file_ops.c +++ b/drivers/infiniband/hw/hfi1/file_ops.c @@ -80,16 +80,18 @@ static u64 kvirt_to_phys(void *addr); static int assign_ctxt(struct file *fp, struct hfi1_user_info *uinfo); static int init_subctxts(struct hfi1_ctxtdata *uctxt, const struct hfi1_user_info *uinfo); -static int user_init(struct file *fp); -static int get_ctxt_info(struct file *fp, void __user *ubase, __u32 len); -static int get_base_info(struct file *fp, void __user *ubase, __u32 len); -static int setup_ctxt(struct file *fp); +static int user_init(struct hfi1_filedata *fd); +static int get_ctxt_info(struct hfi1_filedata *fd, void __user *ubase, + __u32 len); +static int get_base_info(struct hfi1_filedata *fd, void __user *ubase, + __u32 len); +static int setup_ctxt(struct hfi1_filedata *fd); static int setup_subctxt(struct hfi1_ctxtdata *uctxt); -static int get_user_context(struct file *fp, struct hfi1_user_info *uinfo, - int devno); -static int find_shared_ctxt(struct file *fp, +static int get_user_context(struct hfi1_filedata *fd, + struct hfi1_user_info *uinfo, int devno); +static int find_shared_ctxt(struct hfi1_filedata *fd, const struct hfi1_user_info *uinfo); -static int allocate_ctxt(struct file *fp, struct hfi1_devdata *dd, +static int allocate_ctxt(struct hfi1_filedata *fd, struct hfi1_devdata *dd, struct hfi1_user_info *uinfo); static unsigned int poll_urgent(struct file *fp, struct poll_table_struct *pt); static unsigned int poll_next(struct file *fp, struct poll_table_struct *pt); @@ -238,17 +240,17 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, ret = assign_ctxt(fp, &uinfo); if (ret < 0) return ret; - ret = setup_ctxt(fp); + ret = setup_ctxt(fd); if (ret) return ret; - ret = user_init(fp); + ret = user_init(fd); break; case HFI1_IOCTL_CTXT_INFO: - ret = get_ctxt_info(fp, (void __user *)(unsigned long)arg, + ret = get_ctxt_info(fd, (void __user *)(unsigned long)arg, sizeof(struct hfi1_ctxt_info)); break; case HFI1_IOCTL_USER_INFO: - ret = get_base_info(fp, (void __user *)(unsigned long)arg, + ret = get_base_info(fd, (void __user *)(unsigned long)arg, sizeof(struct hfi1_base_info)); break; case HFI1_IOCTL_CREDIT_UPD: @@ -262,7 +264,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, sizeof(tinfo))) return -EFAULT; - ret = hfi1_user_exp_rcv_setup(fp, &tinfo); + ret = hfi1_user_exp_rcv_setup(fd, &tinfo); if (!ret) { /* * Copy the number of tidlist entries we used @@ -284,7 +286,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, sizeof(tinfo))) return -EFAULT; - ret = hfi1_user_exp_rcv_clear(fp, &tinfo); + ret = hfi1_user_exp_rcv_clear(fd, &tinfo); if (ret) break; addr = arg + offsetof(struct hfi1_tid_info, tidcnt); @@ -299,7 +301,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, sizeof(tinfo))) return -EFAULT; - ret = hfi1_user_exp_rcv_invalid(fp, &tinfo); + ret = hfi1_user_exp_rcv_invalid(fd, &tinfo); if (ret) break; addr = arg + offsetof(struct hfi1_tid_info, tidcnt); @@ -436,7 +438,7 @@ static ssize_t hfi1_write_iter(struct kiocb *kiocb, struct iov_iter *from) unsigned long count = 0; ret = hfi1_user_sdma_process_request( - kiocb->ki_filp, (struct iovec *)(from->iov + done), + fd, (struct iovec *)(from->iov + done), dim, &count); if (ret) { reqs = ret; @@ -863,7 +865,7 @@ static int assign_ctxt(struct file *fp, struct hfi1_user_info *uinfo) if (uinfo->subctxt_cnt) { struct hfi1_filedata *fd = fp->private_data; - ret = find_shared_ctxt(fp, uinfo); + ret = find_shared_ctxt(fd, uinfo); if (ret < 0) goto done_unlock; if (ret) { @@ -878,7 +880,7 @@ static int assign_ctxt(struct file *fp, struct hfi1_user_info *uinfo) */ if (!ret) { i_minor = iminor(file_inode(fp)) - HFI1_USER_MINOR_BASE; - ret = get_user_context(fp, uinfo, i_minor); + ret = get_user_context(fp->private_data, uinfo, i_minor); } done_unlock: mutex_unlock(&hfi1_mutex); @@ -886,8 +888,8 @@ done: return ret; } -static int get_user_context(struct file *fp, struct hfi1_user_info *uinfo, - int devno) +static int get_user_context(struct hfi1_filedata *fd, + struct hfi1_user_info *uinfo, int devno) { struct hfi1_devdata *dd = NULL; int devmax, npresent, nup; @@ -905,15 +907,14 @@ static int get_user_context(struct file *fp, struct hfi1_user_info *uinfo, else if (!dd->freectxts) return -EBUSY; - return allocate_ctxt(fp, dd, uinfo); + return allocate_ctxt(fd, dd, uinfo); } -static int find_shared_ctxt(struct file *fp, +static int find_shared_ctxt(struct hfi1_filedata *fd, const struct hfi1_user_info *uinfo) { int devmax, ndev, i; int ret = 0; - struct hfi1_filedata *fd = fp->private_data; devmax = hfi1_count_units(NULL, NULL); @@ -960,10 +961,9 @@ done: return ret; } -static int allocate_ctxt(struct file *fp, struct hfi1_devdata *dd, +static int allocate_ctxt(struct hfi1_filedata *fd, struct hfi1_devdata *dd, struct hfi1_user_info *uinfo) { - struct hfi1_filedata *fd = fp->private_data; struct hfi1_ctxtdata *uctxt; unsigned ctxt; int ret, numa; @@ -1113,10 +1113,9 @@ bail: return ret; } -static int user_init(struct file *fp) +static int user_init(struct hfi1_filedata *fd) { unsigned int rcvctrl_ops = 0; - struct hfi1_filedata *fd = fp->private_data; struct hfi1_ctxtdata *uctxt = fd->uctxt; /* make sure that the context has already been setup */ @@ -1179,10 +1178,10 @@ static int user_init(struct file *fp) return 0; } -static int get_ctxt_info(struct file *fp, void __user *ubase, __u32 len) +static int get_ctxt_info(struct hfi1_filedata *fd, void __user *ubase, + __u32 len) { struct hfi1_ctxt_info cinfo; - struct hfi1_filedata *fd = fp->private_data; struct hfi1_ctxtdata *uctxt = fd->uctxt; int ret = 0; @@ -1220,9 +1219,8 @@ static int get_ctxt_info(struct file *fp, void __user *ubase, __u32 len) return ret; } -static int setup_ctxt(struct file *fp) +static int setup_ctxt(struct hfi1_filedata *fd) { - struct hfi1_filedata *fd = fp->private_data; struct hfi1_ctxtdata *uctxt = fd->uctxt; struct hfi1_devdata *dd = uctxt->dd; int ret = 0; @@ -1257,7 +1255,7 @@ static int setup_ctxt(struct file *fp) goto done; } - ret = hfi1_user_sdma_alloc_queues(uctxt, fp); + ret = hfi1_user_sdma_alloc_queues(uctxt, fd); if (ret) goto done; /* @@ -1269,7 +1267,7 @@ static int setup_ctxt(struct file *fp) * (due to the above wait_event_interruptible() until the master * is setup. */ - ret = hfi1_user_exp_rcv_init(fp); + ret = hfi1_user_exp_rcv_init(fd); if (ret) goto done; @@ -1278,10 +1276,10 @@ done: return ret; } -static int get_base_info(struct file *fp, void __user *ubase, __u32 len) +static int get_base_info(struct hfi1_filedata *fd, void __user *ubase, + __u32 len) { struct hfi1_base_info binfo; - struct hfi1_filedata *fd = fp->private_data; struct hfi1_ctxtdata *uctxt = fd->uctxt; struct hfi1_devdata *dd = uctxt->dd; ssize_t sz; |