From: Daniel Mack <daniel@caiaq.de>
To: linux-kernel@vger.kernel.org
Cc: gregkh@suse.de, hjk@linutronix.de, Daniel Mack <daniel@caiaq.de>
Subject: [PATCH 1/2] UIO: add device clock support
Date: Wed, 24 Jun 2009 17:30:24 +0200 [thread overview]
Message-ID: <1245857425-25389-2-git-send-email-daniel@caiaq.de> (raw)
In-Reply-To: <1245857425-25389-1-git-send-email-daniel@caiaq.de>
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@caiaq.de>
Cc: Hans J. Koch <hjk@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@suse.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
next prev parent reply other threads:[~2009-06-24 15:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-24 15:30 Two small UIO patches Daniel Mack
2009-06-24 15:30 ` Daniel Mack [this message]
2009-06-24 15:30 ` [PATCH 2/2] UIO: remove 'default n' from Kconfig Daniel Mack
2009-06-24 16:34 ` Greg KH
2009-06-24 18:32 ` Daniel Mack
2009-06-24 18:32 ` Greg KH
2009-06-24 16:34 ` [PATCH 1/2] UIO: add device clock support Greg KH
2009-06-24 18:29 ` Daniel Mack
2009-06-24 18:32 ` Greg KH
2009-06-24 18:41 ` Paul Mundt
2009-06-25 15:17 ` Magnus Damm
2009-06-25 17:47 ` Paul Mundt
2009-06-26 8:28 ` Magnus Damm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1245857425-25389-2-git-send-email-daniel@caiaq.de \
--to=daniel@caiaq.de \
--cc=gregkh@suse.de \
--cc=hjk@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome