Skip to contentSkip to conversation

uio: add ioctl callback

PATCH In review Neil Armstrong 2 participants 2 messages Nov 12, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 uio: add ioctl callback

Add an ioctl callback to the UIO device class.
This can be useful when status and data are needed after an interrupt occurs.

Changes :
- Add an uio_ioctl method
- Add en ioctl entry in uio_info

Neil Armstrong <[email protected]>

uio/uio.c (working copy) renamed from uio/uio.c (revision 80) +1 -0
Index: drivers/uio/uio.c
===================================================================
@@ -378,6 +378,17 @@
     return 0;
 }
 
+static int uio_ioctl(struct inode *inode, 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->ioctl)
+ return idev->info->ioctl(idev->info, cmd, arg);
+
+ return -ENOSYS;
+}
+
static ssize_t uio_read(struct file *filep, char __user *buf,
size_t count, loff_t *ppos)
{
@@ -575,6 +586,7 @@
.mmap = uio_mmap,
.poll = uio_poll,
.fasync = uio_fasync,
+ .ioctl = uio_ioctl,
};

static int uio_major_init(void)

linux/uio_driver.h (working copy) renamed from linux/uio_driver.h (revision 80) +1 -0
Index: include/linux/uio_driver.h
===================================================================
@@ -68,6 +68,7 @@
     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

begin:vcard
fn:Neil Armstrong
n:Armstrong;Neil
org:Neotion;Neotion Sophia Antipolis
adr:;;;Sophia Antipolis;;;France
email;internet:[email protected]
title:Embedded Linux Software Engineer
tel;cell:0667474169
note:PGP 0x1166F485
x-mozilla-html:FALSE
url:http://www.neotion.com
version:2.1
end:vcard

#1 lore raw

Read the file SubmittingPatches in your kernel documentation folder before sending a patch. In addition, check the patch with checkpatch script. You can find the script in the script kernel folder. Send the patch with the right destination. You can know the names (and emails) of the maintainers in the MAINTAINER file in the kernel source.

Regards,

Marco

Quoted 55 lines · Neil Armstrong

Add an ioctl callback to the UIO device class.
This can be useful when status and data are needed after an interrupt occurs.

Changes :
- Add an uio_ioctl method
- Add en ioctl entry in uio_info

Neil Armstrong <[email protected]>

Index: drivers/uio/uio.c
===================================================================

uio/uio.c (working copy) renamed from uio/uio.c (revision 80) +11 -0
@@ -378,6 +378,17 @@
     return 0;
 }
 
+static int uio_ioctl(struct inode *inode, 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->ioctl)
+        return idev->info->ioctl(idev->info, cmd, arg);
+   
+    return -ENOSYS;
+}
+
 static ssize_t uio_read(struct file *filep, char __user *buf,
             size_t count, loff_t *ppos)

{

uio/uio.c (working copy) renamed from uio/uio.c (revision 80) +1 -0
@@ -575,6 +586,7 @@
     .mmap        = uio_mmap,
     .poll        = uio_poll,
     .fasync        = uio_fasync,
+   .ioctl      = uio_ioctl,
 };
 
 static int uio_major_init(void)

Index: include/linux/uio_driver.h
===================================================================

linux/uio_driver.h (working copy) renamed from linux/uio_driver.h (revision 80) +1 -0
@@ -68,6 +68,7 @@
     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