* [PATCH] clkdev: add devm_of_clk_get()
@ 2016-07-04 1:04 ` Kuninori Morimoto
0 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-07-04 1:04 UTC (permalink / raw)
To: Russell King, Rob Herring, Mark Brown
Cc: Linux-Kernel, Linux-DT, Linux-ARM, Linux-ALSA, linux-clk
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
This is based on devm_clk_get()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
drivers/clk/clkdev.c | 26 ++++++++++++++++++++++++++
include/linux/clk.h | 7 +++++++
2 files changed, 33 insertions(+)
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 89cc700..93a613b 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -55,6 +55,32 @@ struct clk *of_clk_get(struct device_node *np, int index)
}
EXPORT_SYMBOL(of_clk_get);
+static void devm_of_clk_release(struct device *dev, void *res)
+{
+ clk_put(*(struct clk **)res);
+}
+
+struct clk *devm_of_clk_get(struct device *dev,
+ struct device_node *np, int index)
+{
+ struct clk **ptr, *clk;
+
+ ptr = devres_alloc(devm_of_clk_release, sizeof(*ptr), GFP_KERNEL);
+ if (!ptr)
+ return ERR_PTR(-ENOMEM);
+
+ clk = of_clk_get(np, index);
+ if (!IS_ERR(clk)) {
+ *ptr = clk;
+ devres_add(dev, ptr);
+ } else {
+ devres_free(ptr);
+ }
+
+ return clk;
+}
+EXPORT_SYMBOL(devm_of_clk_get);
+
static struct clk *__of_clk_get_by_name(struct device_node *np,
const char *dev_id,
const char *name)
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 834179f..01005e78 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -494,6 +494,8 @@ struct of_phandle_args;
#if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK)
struct clk *of_clk_get(struct device_node *np, int index);
+struct clk *devm_of_clk_get(struct device *dev,
+ struct device_node *np, int index);
struct clk *of_clk_get_by_name(struct device_node *np, const char *name);
struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec);
#else
@@ -501,6 +503,11 @@ static inline struct clk *of_clk_get(struct device_node *np, int index)
{
return ERR_PTR(-ENOENT);
}
+struct clk *devm_of_clk_get(struct device *dev,
+ struct device_node *np, int index)
+{
+ return ERR_PTR(-ENOENT);
+}
static inline struct clk *of_clk_get_by_name(struct device_node *np,
const char *name)
{
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH] clkdev: add devm_of_clk_get()
@ 2016-07-04 1:04 ` Kuninori Morimoto
0 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-07-04 1:04 UTC (permalink / raw)
To: Russell King, Rob Herring, Mark Brown
Cc: Linux-Kernel, Linux-DT, Linux-ARM, Linux-ALSA, linux-clk
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
This is based on devm_clk_get()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
drivers/clk/clkdev.c | 26 ++++++++++++++++++++++++++
include/linux/clk.h | 7 +++++++
2 files changed, 33 insertions(+)
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 89cc700..93a613b 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -55,6 +55,32 @@ struct clk *of_clk_get(struct device_node *np, int index)
}
EXPORT_SYMBOL(of_clk_get);
+static void devm_of_clk_release(struct device *dev, void *res)
+{
+ clk_put(*(struct clk **)res);
+}
+
+struct clk *devm_of_clk_get(struct device *dev,
+ struct device_node *np, int index)
+{
+ struct clk **ptr, *clk;
+
+ ptr = devres_alloc(devm_of_clk_release, sizeof(*ptr), GFP_KERNEL);
+ if (!ptr)
+ return ERR_PTR(-ENOMEM);
+
+ clk = of_clk_get(np, index);
+ if (!IS_ERR(clk)) {
+ *ptr = clk;
+ devres_add(dev, ptr);
+ } else {
+ devres_free(ptr);
+ }
+
+ return clk;
+}
+EXPORT_SYMBOL(devm_of_clk_get);
+
static struct clk *__of_clk_get_by_name(struct device_node *np,
const char *dev_id,
const char *name)
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 834179f..01005e78 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -494,6 +494,8 @@ struct of_phandle_args;
#if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK)
struct clk *of_clk_get(struct device_node *np, int index);
+struct clk *devm_of_clk_get(struct device *dev,
+ struct device_node *np, int index);
struct clk *of_clk_get_by_name(struct device_node *np, const char *name);
struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec);
#else
@@ -501,6 +503,11 @@ static inline struct clk *of_clk_get(struct device_node *np, int index)
{
return ERR_PTR(-ENOENT);
}
+struct clk *devm_of_clk_get(struct device *dev,
+ struct device_node *np, int index)
+{
+ return ERR_PTR(-ENOENT);
+}
static inline struct clk *of_clk_get_by_name(struct device_node *np,
const char *name)
{
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH] clkdev: add devm_of_clk_get()
@ 2016-07-04 1:04 ` Kuninori Morimoto
0 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-07-04 1:04 UTC (permalink / raw)
To: linux-arm-kernel
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
This is based on devm_clk_get()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
drivers/clk/clkdev.c | 26 ++++++++++++++++++++++++++
include/linux/clk.h | 7 +++++++
2 files changed, 33 insertions(+)
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 89cc700..93a613b 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -55,6 +55,32 @@ struct clk *of_clk_get(struct device_node *np, int index)
}
EXPORT_SYMBOL(of_clk_get);
+static void devm_of_clk_release(struct device *dev, void *res)
+{
+ clk_put(*(struct clk **)res);
+}
+
+struct clk *devm_of_clk_get(struct device *dev,
+ struct device_node *np, int index)
+{
+ struct clk **ptr, *clk;
+
+ ptr = devres_alloc(devm_of_clk_release, sizeof(*ptr), GFP_KERNEL);
+ if (!ptr)
+ return ERR_PTR(-ENOMEM);
+
+ clk = of_clk_get(np, index);
+ if (!IS_ERR(clk)) {
+ *ptr = clk;
+ devres_add(dev, ptr);
+ } else {
+ devres_free(ptr);
+ }
+
+ return clk;
+}
+EXPORT_SYMBOL(devm_of_clk_get);
+
static struct clk *__of_clk_get_by_name(struct device_node *np,
const char *dev_id,
const char *name)
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 834179f..01005e78 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -494,6 +494,8 @@ struct of_phandle_args;
#if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK)
struct clk *of_clk_get(struct device_node *np, int index);
+struct clk *devm_of_clk_get(struct device *dev,
+ struct device_node *np, int index);
struct clk *of_clk_get_by_name(struct device_node *np, const char *name);
struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec);
#else
@@ -501,6 +503,11 @@ static inline struct clk *of_clk_get(struct device_node *np, int index)
{
return ERR_PTR(-ENOENT);
}
+struct clk *devm_of_clk_get(struct device *dev,
+ struct device_node *np, int index)
+{
+ return ERR_PTR(-ENOENT);
+}
static inline struct clk *of_clk_get_by_name(struct device_node *np,
const char *name)
{
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] clkdev: add devm_of_clk_get()
2016-07-04 1:04 ` Kuninori Morimoto
@ 2016-07-04 1:15 ` kbuild test robot
-1 siblings, 0 replies; 11+ messages in thread
From: kbuild test robot @ 2016-07-04 1:15 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: kbuild-all, Russell King, Rob Herring, Mark Brown, Linux-Kernel,
Linux-DT, Linux-ARM, Linux-ALSA, linux-clk
[-- Attachment #1: Type: text/plain, Size: 959 bytes --]
Hi,
[auto build test ERROR on clk/clk-next]
[also build test ERROR on v4.7-rc5 next-20160701]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Kuninori-Morimoto/clkdev-add-devm_of_clk_get/20160704-090653
base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: i386-tinyconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
arch/x86/kernel/tsc.o: In function `devm_of_clk_get':
>> tsc.c:(.text+0x3e0): multiple definition of `devm_of_clk_get'
arch/x86/kernel/setup.o:setup.c:(.text+0x3): first defined here
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 6328 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] clkdev: add devm_of_clk_get()
@ 2016-07-04 1:15 ` kbuild test robot
0 siblings, 0 replies; 11+ messages in thread
From: kbuild test robot @ 2016-07-04 1:15 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
[auto build test ERROR on clk/clk-next]
[also build test ERROR on v4.7-rc5 next-20160701]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Kuninori-Morimoto/clkdev-add-devm_of_clk_get/20160704-090653
base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: i386-tinyconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
arch/x86/kernel/tsc.o: In function `devm_of_clk_get':
>> tsc.c:(.text+0x3e0): multiple definition of `devm_of_clk_get'
arch/x86/kernel/setup.o:setup.c:(.text+0x3): first defined here
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 6328 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160704/ebb87313/attachment.obj>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] clkdev: add devm_of_clk_get()
2016-07-04 1:04 ` Kuninori Morimoto
(?)
@ 2016-07-04 7:54 ` Arnd Bergmann
-1 siblings, 0 replies; 11+ messages in thread
From: Arnd Bergmann @ 2016-07-04 7:54 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Kuninori Morimoto, Russell King, Rob Herring, Mark Brown,
Linux-DT, Linux-ALSA, Linux-Kernel, linux-clk
On Monday, July 4, 2016 1:04:30 AM CEST Kuninori Morimoto wrote:
> @@ -501,6 +503,11 @@ static inline struct clk *of_clk_get(struct device_node *np, int index)
> {
> return ERR_PTR(-ENOENT);
> }
> +struct clk *devm_of_clk_get(struct device *dev,
> + struct device_node *np, int index)
> +{
> + return ERR_PTR(-ENOENT);
> +}
> static inline struct clk *of_clk_get_by_name(struct device_node *np,
> const char *name)
> {
> --
>
This is missing "static inline" as found by the bot.
Arnd
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] clkdev: add devm_of_clk_get()
@ 2016-07-04 7:54 ` Arnd Bergmann
0 siblings, 0 replies; 11+ messages in thread
From: Arnd Bergmann @ 2016-07-04 7:54 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Rob Herring, Linux-ALSA, Kuninori Morimoto, Linux-DT,
Russell King, Linux-Kernel, Mark Brown, linux-clk
On Monday, July 4, 2016 1:04:30 AM CEST Kuninori Morimoto wrote:
> @@ -501,6 +503,11 @@ static inline struct clk *of_clk_get(struct device_node *np, int index)
> {
> return ERR_PTR(-ENOENT);
> }
> +struct clk *devm_of_clk_get(struct device *dev,
> + struct device_node *np, int index)
> +{
> + return ERR_PTR(-ENOENT);
> +}
> static inline struct clk *of_clk_get_by_name(struct device_node *np,
> const char *name)
> {
> --
>
This is missing "static inline" as found by the bot.
Arnd
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] clkdev: add devm_of_clk_get()
@ 2016-07-04 7:54 ` Arnd Bergmann
0 siblings, 0 replies; 11+ messages in thread
From: Arnd Bergmann @ 2016-07-04 7:54 UTC (permalink / raw)
To: linux-arm-kernel
On Monday, July 4, 2016 1:04:30 AM CEST Kuninori Morimoto wrote:
> @@ -501,6 +503,11 @@ static inline struct clk *of_clk_get(struct device_node *np, int index)
> {
> return ERR_PTR(-ENOENT);
> }
> +struct clk *devm_of_clk_get(struct device *dev,
> + struct device_node *np, int index)
> +{
> + return ERR_PTR(-ENOENT);
> +}
> static inline struct clk *of_clk_get_by_name(struct device_node *np,
> const char *name)
> {
> --
>
This is missing "static inline" as found by the bot.
Arnd
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] clkdev: add devm_of_clk_get()
2016-07-04 7:54 ` Arnd Bergmann
(?)
@ 2016-07-04 8:04 ` Kuninori Morimoto
-1 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-07-04 8:04 UTC (permalink / raw)
To: Arnd Bergmann
Cc: linux-arm-kernel, Russell King, Rob Herring, Mark Brown,
Linux-DT, Linux-ALSA, Linux-Kernel, linux-clk
Hi Arnd
> > @@ -501,6 +503,11 @@ static inline struct clk *of_clk_get(struct device_node *np, int index)
> > {
> > return ERR_PTR(-ENOENT);
> > }
> > +struct clk *devm_of_clk_get(struct device *dev,
> > + struct device_node *np, int index)
> > +{
> > + return ERR_PTR(-ENOENT);
> > +}
> > static inline struct clk *of_clk_get_by_name(struct device_node *np,
> > const char *name)
> > {
> > --
> >
>
> This is missing "static inline" as found by the bot.
Thanks.
I have already posted v2 patch.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] clkdev: add devm_of_clk_get()
@ 2016-07-04 8:04 ` Kuninori Morimoto
0 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-07-04 8:04 UTC (permalink / raw)
To: Arnd Bergmann
Cc: linux-arm-kernel, Russell King, Rob Herring, Mark Brown,
Linux-DT, Linux-ALSA, Linux-Kernel, linux-clk
Hi Arnd
> > @@ -501,6 +503,11 @@ static inline struct clk *of_clk_get(struct device_node *np, int index)
> > {
> > return ERR_PTR(-ENOENT);
> > }
> > +struct clk *devm_of_clk_get(struct device *dev,
> > + struct device_node *np, int index)
> > +{
> > + return ERR_PTR(-ENOENT);
> > +}
> > static inline struct clk *of_clk_get_by_name(struct device_node *np,
> > const char *name)
> > {
> > --
> >
>
> This is missing "static inline" as found by the bot.
Thanks.
I have already posted v2 patch.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] clkdev: add devm_of_clk_get()
@ 2016-07-04 8:04 ` Kuninori Morimoto
0 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2016-07-04 8:04 UTC (permalink / raw)
To: linux-arm-kernel
Hi Arnd
> > @@ -501,6 +503,11 @@ static inline struct clk *of_clk_get(struct device_node *np, int index)
> > {
> > return ERR_PTR(-ENOENT);
> > }
> > +struct clk *devm_of_clk_get(struct device *dev,
> > + struct device_node *np, int index)
> > +{
> > + return ERR_PTR(-ENOENT);
> > +}
> > static inline struct clk *of_clk_get_by_name(struct device_node *np,
> > const char *name)
> > {
> > --
> >
>
> This is missing "static inline" as found by the bot.
Thanks.
I have already posted v2 patch.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2016-07-04 8:04 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-04 1:04 [PATCH] clkdev: add devm_of_clk_get() Kuninori Morimoto
2016-07-04 1:04 ` Kuninori Morimoto
2016-07-04 1:04 ` Kuninori Morimoto
2016-07-04 1:15 ` kbuild test robot
2016-07-04 1:15 ` kbuild test robot
2016-07-04 7:54 ` Arnd Bergmann
2016-07-04 7:54 ` Arnd Bergmann
2016-07-04 7:54 ` Arnd Bergmann
2016-07-04 8:04 ` Kuninori Morimoto
2016-07-04 8:04 ` Kuninori Morimoto
2016-07-04 8:04 ` Kuninori Morimoto
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.