Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1239155

[PATCH v1 1/3] uio: add ioctl support

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Vlad Zolotarov <vladz@cloudius-systems.com>
Newsgroups linux.kernel
Subject [PATCH v1 1/3] uio: add ioctl support
Date Sun, 04 Oct 2015 18:50:01 +0200
Message-ID <qfUE1-5Xx-7@gated-at.bofh.it> (permalink)
References <qfUE1-5Xx-3@gated-at.bofh.it>
X-Original-To linux-kernel@vger.kernel.org, mst@redhat.com, hjk@hansjkoch.de, regkh@linuxfoundation.org, corbet@lwn.net
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iC1J8s1faPKij5pmMz/1pGbn6mCLyabSYIumICLRLFk=; b=l1OkKVtLED9AgZD/LbMlItJUnEA+muUbwlLRp11uqGfSW2wcmFHPPnOlcwq96+6j6E RQuzHbTIMJoF08FUhGHBjUJLnUvRgH2dzj5NB6XBdURu14Nh6zvGjBST6hQzrzCyOVsy sIZ75+UoEntMFBaaftuaJmQ0/sFMgOqcZRRmBgD9d7fxEVIOAPRRA38mPia3sdPmkPU6 2yMY2a6iShlXQ2YhV34ptbaft3cJm7X2P0IyIClqqXc9aRrDV+SfnGQolX4Asp4aOVZm 3HD2B+Nv3CRV/KWGb6r2Doegj6Vk1WEWo5r6tcqNAWA1UT641h9uIE6oGFJeCI/E4aFv sttw==
X-Gm-Message-State ALoCoQkrzkcsI047WrMA6o2p3iBWK53VPsEmJ8wCBPMPVjzJJpJ2FrMmOSFyOvkE9WTqzuJ74Nem
X-Received by 10.194.6.161 with SMTP id c1mr20606186wja.152.1443977037060; Sun, 04 Oct 2015 09:43:57 -0700 (PDT)
X-Mailer git-send-email 2.1.0
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 68
Organization linux.* mail to news gateway
X-Original-Cc bruce.richardson@intel.com, avi@cloudius-systems.com, gleb@cloudius-systems.com, stephen@networkplumber.org, alexander.duyck@gmail.com, Vlad Zolotarov <vladz@cloudius-systems.com>
X-Original-Date Sun, 4 Oct 2015 19:43:37 +0300
X-Original-Message-ID <1443977019-1513-2-git-send-email-vladz@cloudius-systems.com>
X-Original-References <1443977019-1513-1-git-send-email-vladz@cloudius-systems.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1239155

Show key headers only | View raw


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 | Find similar | Unroll thread


Thread

[PATCH v1 1/3] uio: add ioctl support Vlad Zolotarov <vladz@cloudius-systems.com> - 2015-10-04 18:50 +0200

csiph-web