From: Stephen Hemminger <stephen@networkplumber.org>
To: "Hans J. Koch" <hjk@hansjkoch.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] uio: add support for ioctl
Date: Mon, 18 May 2015 10:31:36 -0700 [thread overview]
Message-ID: <20150518103136.73e48906@urahara> (raw)
Allow UIO device specific driver to provide ioctl interface.
This mechanism is used in DPDK uio_msi driver to allow creating
VFIO like events.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
--- a/drivers/uio/uio.c 2015-05-18 10:29:00.097129278 -0700
+++ b/drivers/uio/uio.c 2015-05-18 10:29:00.097129278 -0700
@@ -576,6 +576,20 @@ static ssize_t uio_write(struct file *fi
return retval ? retval : sizeof(s32);
}
+static long uio_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
+{
+ struct uio_listener *listener = filep->private_data;
+ struct uio_device *idev = listener->dev;
+
+ if (!idev->info)
+ return -EIO;
+
+ if (!idev->info->ioctl)
+ return -ENOTTY;
+
+ return idev->info->ioctl(idev->info, cmd, arg);
+}
+
static int uio_find_mem_index(struct vm_area_struct *vma)
{
struct uio_device *idev = vma->vm_private_data;
@@ -712,6 +726,7 @@ static const struct file_operations uio_
.write = uio_write,
.mmap = uio_mmap,
.poll = uio_poll,
+ .unlocked_ioctl = uio_ioctl,
.fasync = uio_fasync,
.llseek = noop_llseek,
};
--- a/include/linux/uio_driver.h 2015-05-18 10:29:00.097129278 -0700
+++ b/include/linux/uio_driver.h 2015-05-18 10:29:00.097129278 -0700
@@ -89,6 +89,7 @@ struct uio_device {
* @mmap: mmap operation for this uio device
* @open: open operation for this uio device
* @release: release operation for this uio device
+ * @ioctl: ioctl handler
* @irqcontrol: disable/enable irqs when 0/1 is written to /dev/uioX
*/
struct uio_info {
@@ -105,6 +106,7 @@ struct uio_info {
int (*open)(struct uio_info *info, struct inode *inode);
int (*release)(struct uio_info *info, struct inode *inode);
int (*irqcontrol)(struct uio_info *info, s32 irq_on);
+ int (*ioctl)(struct uio_info *info, unsigned int cmd, unsigned long arg);
};
extern int __must_check
next reply other threads:[~2015-05-18 17:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-18 17:31 Stephen Hemminger [this message]
2015-05-18 17:36 ` [PATCH] uio: add support for ioctl Christoph Hellwig
2015-05-18 17:41 ` Stephen Hemminger
2015-05-19 6:29 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150518103136.73e48906@urahara \
--to=stephen@networkplumber.org \
--cc=gregkh@linuxfoundation.org \
--cc=hjk@hansjkoch.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox