From: "Davide Rizzo" <elpa.rizzo@gmail.com>
To: linux-kernel@vger.kernel.org, hjk@linutronix.de, gregkh@suse.de,
ben-linux@fluff.org
Subject: [PATCH 2/3] Driver for user access to internal clocks
Date: Thu, 8 Jan 2009 10:50:03 +0100 [thread overview]
Message-ID: <8447d6730901080150p217f5d71kd2512b124ed0ed4c@mail.gmail.com> (raw)
Specific for Samsung S3C24xx platforms
Allows any driver to get a device specific clock.
It recognizes also the form clkname.X
Signed-off-by: Davide Rizzo <elpa-rizzo@gmail.com>
---
diff -urNp linux-2.6.28/arch/arm/plat-s3c24xx/clock.c
linux-2.6.28.elpa/arch/arm/plat-s3c24xx/clock.c
--- linux-2.6.28/arch/arm/plat-s3c24xx/clock.c 2008-12-25
00:26:37.000000000 +0100
+++ linux-2.6.28.elpa/arch/arm/plat-s3c24xx/clock.c 2009-01-07
19:25:07.000000000 +0100
@@ -67,11 +67,19 @@ static int clk_null_enable(struct clk *c
struct clk *clk_get(struct device *dev, const char *id)
{
+ long idno;
+ char *name = (char *)id;
+ char *dotpos = strrchr(id, '.');
struct clk *p;
struct clk *clk = ERR_PTR(-ENOENT);
- int idno;
- if (dev == NULL || dev->bus != &platform_bus_type)
+ if (dotpos) {
+ int err = strict_strtol(dotpos + 1, 10, &idno);
+ if (err)
+ return ERR_PTR(err);
+ name = kstrdup(id, GFP_KERNEL);
+ name[dotpos - id] = '\0';
+ } else if (dev == NULL || dev->bus != &platform_bus_type)
idno = -1;
else
idno = to_platform_device(dev)->id;
@@ -80,7 +88,7 @@ struct clk *clk_get(struct device *dev,
list_for_each_entry(p, &clocks, list) {
if (p->id == idno &&
- strcmp(id, p->name) == 0 &&
+ strcmp(name, p->name) == 0 &&
try_module_get(p->owner)) {
clk = p;
break;
@@ -92,7 +100,7 @@ struct clk *clk_get(struct device *dev,
if (IS_ERR(clk)) {
list_for_each_entry(p, &clocks, list) {
- if (p->id == -1 && strcmp(id, p->name) == 0 &&
+ if (p->id == -1 && strcmp(name, p->name) == 0 &&
try_module_get(p->owner)) {
clk = p;
break;
@@ -101,6 +109,9 @@ struct clk *clk_get(struct device *dev,
}
mutex_unlock(&clocks_mutex);
+
+ if (dotpos)
+ kfree(name);
return clk;
}
next reply other threads:[~2009-01-08 9:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-08 9:50 Davide Rizzo [this message]
2009-01-08 12:19 ` Ben Dooks
2009-01-08 14:12 ` Davide Rizzo
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=8447d6730901080150p217f5d71kd2512b124ed0ed4c@mail.gmail.com \
--to=elpa.rizzo@gmail.com \
--cc=ben-linux@fluff.org \
--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
all inboxes | Powered by JetHome®