public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH]: UIO read(2)/write(2) overrides
@ 2014-03-21 14:20 Matt Sickler
  2014-03-21 14:24 ` gregkh
  0 siblings, 1 reply; 4+ messages in thread
From: Matt Sickler @ 2014-03-21 14:20 UTC (permalink / raw)
  To: hjk@hansjkoch.de, gregkh@linuxfoundation.org; +Cc: linux-kernel@vger.kernel.org

Tiny patch to let uio-based drivers override the read(2), write(2), and poll(2) syscalls.
The rationale is that some uio-based drivers might want the mmap(2) functionality
of UIO, but have no need for the IRQ semantics of read(2) and write(2).

Signed-Off-by: Matt Sickler <Matt.Sickler@daktronics.com>
---
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index a673e5b..da1bfc8 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -505,6 +505,9 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
    struct uio_listener *listener = filep->private_data;
    struct uio_device *idev = listener->dev;

+   if (idev->info->poll)
+       return idev->info->poll(filep, wait);
+
    if (!idev->info->irq)
        return -EIO;

@@ -523,6 +526,9 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
    ssize_t retval;
    s32 event_count;

+   if (idev->info->read)
+       return idev->info->read(filep, buf, count, ppos);
+
    if (!idev->info->irq)
        return -EIO;

@@ -571,6 +577,9 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
    ssize_t retval;
    s32 irq_on;

+   if (idev->info->write)
+       return idev->info->write(filep, buf, count, ppos);
+
    if (!idev->info->irq)
        return -EIO;

diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 1ad4724..f15ace1 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -16,6 +16,7 @@

 #include <linux/fs.h>
 #include <linux/interrupt.h>
+#include <linux/poll.h>

 struct module;
 struct uio_map;
@@ -95,6 +96,11 @@ 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);
+   unsigned int (*poll)(struct file *filep, poll_table *wait);
+   ssize_t (*read)(struct file *filep, char __user *buf,
+                   size_t count, loff_t *ppos);
+   ssize_t (*write)(struct file *filep, const char __user *buf,
+                    size_t count, loff_t *ppos);
 };

 extern int __must_check


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-21 14:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-21 14:20 [PATCH]: UIO read(2)/write(2) overrides Matt Sickler
2014-03-21 14:24 ` gregkh
2014-03-21 14:49   ` Matt Sickler
2014-03-21 14:59     ` gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox