lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1245857425-25389-2-git-send-email-daniel@caiaq.de>
Date:	Wed, 24 Jun 2009 17:30:24 +0200
From:	Daniel Mack <daniel@...aq.de>
To:	linux-kernel@...r.kernel.org
Cc:	gregkh@...e.de, hjk@...utronix.de, Daniel Mack <daniel@...aq.de>
Subject: [PATCH 1/2] UIO: add device clock support

Add a pointer to a 'struct clk' to uio_info. Drivers can set
this pointer if a clock is needed, and the UIO core will care
to enable and disable it upon device open and release.

Signed-off-by: Daniel Mack <daniel@...aq.de>
Cc: Hans J. Koch <hjk@...utronix.de>
Cc: Greg Kroah-Hartman <gregkh@...e.de>
---
 drivers/uio/uio.c          |   15 ++++++++++++++-
 include/linux/uio_driver.h |    2 ++
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 03efb06..6ba95cf 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -479,6 +479,12 @@ static int uio_open(struct inode *inode, struct file *filep)
 	listener->event_count = atomic_read(&idev->event);
 	filep->private_data = listener;
 
+	if (idev->info->clk) {
+		ret = clk_enable(idev->info->clk);
+		if (ret)
+			goto err_clkenable;
+	}
+
 	if (idev->info->open) {
 		ret = idev->info->open(idev->info, inode);
 		if (ret)
@@ -486,6 +492,7 @@ static int uio_open(struct inode *inode, struct file *filep)
 	}
 	return 0;
 
+err_clkenable:
 err_infoopen:
 	kfree(listener);
 
@@ -510,8 +517,14 @@ static int uio_release(struct inode *inode, struct file *filep)
 	struct uio_listener *listener = filep->private_data;
 	struct uio_device *idev = listener->dev;
 
-	if (idev->info->release)
+	if (idev->info->release) {
 		ret = idev->info->release(idev->info, inode);
+		if (ret)
+			dev_err(idev->dev, "release() failed (%d)\n", ret);
+	}
+
+	if (idev->info->clk)
+		clk_disable(idev->info->clk);
 
 	module_put(idev->owner);
 	kfree(listener);
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 5dcc9ff..6bc0e7e 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/interrupt.h>
+#include <linux/clk.h>
 
 struct uio_map;
 
@@ -87,6 +88,7 @@ struct uio_info {
 	long			irq;
 	unsigned long		irq_flags;
 	void			*priv;
+	struct clk		*clk;
 	irqreturn_t (*handler)(int irq, struct uio_info *dev_info);
 	int (*mmap)(struct uio_info *info, struct vm_area_struct *vma);
 	int (*open)(struct uio_info *info, struct inode *inode);
-- 
1.6.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ