Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1240765
| From | Vlad Zolotarov <vladz@cloudius-systems.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v5 1/4] uio: add ioctl support |
| Date | 2015-10-06 19:20 +0200 |
| Message-ID | <qgE4a-49R-27@gated-at.bofh.it> (permalink) |
| References | <qgE49-49R-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Add the ability for underlying device drivers to register the ioctl
commands. This is useful when some interaction with the user space
beyond sysfs capabilities is required, e.g. query the interrupt mode
or bind eventfd to interrupt notifications (similarly to vfio ioctl
VFIO_DEVICE_SET_IRQS).
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
---
drivers/uio/uio.c | 15 +++++++++++++++
include/linux/uio_driver.h | 3 +++
2 files changed, 18 insertions(+)
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 8196581..714b0e5 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -704,6 +704,20 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma)
}
}
+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 const struct file_operations uio_fops = {
.owner = THIS_MODULE,
.open = uio_open,
@@ -712,6 +726,7 @@ static const struct file_operations uio_fops = {
.write = uio_write,
.mmap = uio_mmap,
.poll = uio_poll,
+ .unlocked_ioctl = uio_ioctl,
.fasync = uio_fasync,
.llseek = noop_llseek,
};
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 32c0e83..10d7833 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -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,8 @@ 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
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH v5 1/4] uio: add ioctl support Vlad Zolotarov <vladz@cloudius-systems.com> - 2015-10-06 19:20 +0200
Re: [PATCH v5 1/4] uio: add ioctl support Stephen Hemminger <stephen@networkplumber.org> - 2015-10-06 23:40 +0200
Re: [PATCH v5 1/4] uio: add ioctl support Vlad Zolotarov <vladz@cloudius-systems.com> - 2015-10-07 10:20 +0200
Re: [PATCH v5 1/4] uio: add ioctl support Vlad Zolotarov <vladz@cloudius-systems.com> - 2015-10-07 10:20 +0200
Re: [PATCH v5 1/4] uio: add ioctl support Greg KH <gregkh@linuxfoundation.org> - 2015-10-07 10:50 +0200
Re: [PATCH v5 1/4] uio: add ioctl support Vlad Zolotarov <vladz@cloudius-systems.com> - 2015-10-07 11:00 +0200
Re: [PATCH v5 1/4] uio: add ioctl support Greg KH <gregkh@linuxfoundation.org> - 2015-10-07 19:30 +0200
Re: [PATCH v5 1/4] uio: add ioctl support Vlad Zolotarov <vladz@cloudius-systems.com> - 2015-10-07 19:30 +0200
Re: [PATCH v5 1/4] uio: add ioctl support Vlad Zolotarov <vladz@cloudius-systems.com> - 2015-10-07 21:10 +0200
Re: [PATCH v5 1/4] uio: add ioctl support Vlad Zolotarov <vladz@cloudius-systems.com> - 2015-10-08 14:50 +0200
Re: [PATCH v5 1/4] uio: add ioctl support Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-10-08 17:40 +0200
csiph-web