summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-04-04 00:11:32 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-04-11 22:29:42 -0400
commit4961772560d2f19695c73ece943716033ad62ac2 (patch)
treeadab72c5c2e3fd9a374d9650f53cd6813570c313
parent9a219bc70b54523c8f14a3c957179854785ee97c (diff)
infinibad: weird APIs switched to ->write_iter()
Things Not To Do When Writing A Driver, part 1001st: have writev() and write() on the same file doing completely different things. As in, "interpret very different sets of commands". We _can_ handle that, but it's a bloody bad idea. Don't do that in new drivers. Ever. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c18
-rw-r--r--drivers/infiniband/hw/qib/qib_file_ops.c20
2 files changed, 23 insertions, 15 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index aed8afee56da..450d15965005 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -42,6 +42,7 @@
#include <linux/io.h>
#include <linux/jiffies.h>
#include <linux/cpu.h>
+#include <linux/uio.h>
#include <asm/pgtable.h>
#include "ipath_kernel.h"
@@ -52,15 +53,19 @@ static int ipath_open(struct inode *, struct file *);
static int ipath_close(struct inode *, struct file *);
static ssize_t ipath_write(struct file *, const char __user *, size_t,
loff_t *);
-static ssize_t ipath_writev(struct kiocb *, const struct iovec *,
- unsigned long , loff_t);
+static ssize_t ipath_write_iter(struct kiocb *, struct iov_iter *from);
static unsigned int ipath_poll(struct file *, struct poll_table_struct *);
static int ipath_mmap(struct file *, struct vm_area_struct *);
+/*
+ * This is really, really weird shit - write() and writev() here
+ * have completely unrelated semantics. Sucky userland ABI,
+ * film at 11.
+ */
static const struct file_operations ipath_file_ops = {
.owner = THIS_MODULE,
.write = ipath_write,
- .aio_write = ipath_writev,
+ .write_iter = ipath_write_iter,
.open = ipath_open,
.release = ipath_close,
.poll = ipath_poll,
@@ -2413,18 +2418,17 @@ bail:
return ret;
}
-static ssize_t ipath_writev(struct kiocb *iocb, const struct iovec *iov,
- unsigned long dim, loff_t off)
+static ssize_t ipath_write_iter(struct kiocb *iocb, struct iov_iter *from)
{
struct file *filp = iocb->ki_filp;
struct ipath_filedata *fp = filp->private_data;
struct ipath_portdata *pd = port_fp(filp);
struct ipath_user_sdma_queue *pq = fp->pq;
- if (!dim)
+ if (!iter_is_iovec(from) || !from->nr_segs)
return -EINVAL;
- return ipath_user_sdma_writev(pd->port_dd, pq, iov, dim);
+ return ipath_user_sdma_writev(pd->port_dd, pq, from->iov, from->nr_segs);
}
static struct class *ipath_class;
diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c
index 14046f5a37fa..9ea6c440a00c 100644
--- a/drivers/infiniband/hw/qib/qib_file_ops.c
+++ b/drivers/infiniband/hw/qib/qib_file_ops.c
@@ -43,6 +43,7 @@
#include <asm/pgtable.h>
#include <linux/delay.h>
#include <linux/export.h>
+#include <linux/uio.h>
#include "qib.h"
#include "qib_common.h"
@@ -54,15 +55,19 @@
static int qib_open(struct inode *, struct file *);
static int qib_close(struct inode *, struct file *);
static ssize_t qib_write(struct file *, const char __user *, size_t, loff_t *);
-static ssize_t qib_aio_write(struct kiocb *, const struct iovec *,
- unsigned long, loff_t);
+static ssize_t qib_write_iter(struct kiocb *, struct iov_iter *);
static unsigned int qib_poll(struct file *, struct poll_table_struct *);
static int qib_mmapf(struct file *, struct vm_area_struct *);
+/*
+ * This is really, really weird shit - write() and writev() here
+ * have completely unrelated semantics. Sucky userland ABI,
+ * film at 11.
+ */
static const struct file_operations qib_file_ops = {
.owner = THIS_MODULE,
.write = qib_write,
- .aio_write = qib_aio_write,
+ .write_iter = qib_write_iter,
.open = qib_open,
.release = qib_close,
.poll = qib_poll,
@@ -2248,17 +2253,16 @@ bail:
return ret;
}
-static ssize_t qib_aio_write(struct kiocb *iocb, const struct iovec *iov,
- unsigned long dim, loff_t off)
+static ssize_t qib_write_iter(struct kiocb *iocb, struct iov_iter *from)
{
struct qib_filedata *fp = iocb->ki_filp->private_data;
struct qib_ctxtdata *rcd = ctxt_fp(iocb->ki_filp);
struct qib_user_sdma_queue *pq = fp->pq;
- if (!dim || !pq)
+ if (!iter_is_iovec(from) || !from->nr_segs || !pq)
return -EINVAL;
-
- return qib_user_sdma_writev(rcd, pq, iov, dim);
+
+ return qib_user_sdma_writev(rcd, pq, from->iov, from->nr_segs);
}
static struct class *qib_class;