aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/include/asm/clkdev.h2
-rw-r--r--arch/blackfin/include/asm/clkdev.h2
-rw-r--r--arch/mips/include/asm/clkdev.h2
-rw-r--r--arch/sh/include/asm/clkdev.h2
-rw-r--r--drivers/clk/clk.c26
-rw-r--r--include/linux/clk-private.h3
-rw-r--r--include/linux/clkdev.h5
7 files changed, 42 insertions, 0 deletions
diff --git a/arch/arm/include/asm/clkdev.h b/arch/arm/include/asm/clkdev.h
index 80751c15c300..4e8a4b27d7c7 100644
--- a/arch/arm/include/asm/clkdev.h
+++ b/arch/arm/include/asm/clkdev.h
@@ -14,12 +14,14 @@
14 14
15#include <linux/slab.h> 15#include <linux/slab.h>
16 16
17#ifndef CONFIG_COMMON_CLK
17#ifdef CONFIG_HAVE_MACH_CLKDEV 18#ifdef CONFIG_HAVE_MACH_CLKDEV
18#include <mach/clkdev.h> 19#include <mach/clkdev.h>
19#else 20#else
20#define __clk_get(clk) ({ 1; }) 21#define __clk_get(clk) ({ 1; })
21#define __clk_put(clk) do { } while (0) 22#define __clk_put(clk) do { } while (0)
22#endif 23#endif
24#endif
23 25
24static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size) 26static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
25{ 27{
diff --git a/arch/blackfin/include/asm/clkdev.h b/arch/blackfin/include/asm/clkdev.h
index 9053beda8c50..7ac2436856a5 100644
--- a/arch/blackfin/include/asm/clkdev.h
+++ b/arch/blackfin/include/asm/clkdev.h
@@ -8,7 +8,9 @@ static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
8 return kzalloc(size, GFP_KERNEL); 8 return kzalloc(size, GFP_KERNEL);
9} 9}
10 10
11#ifndef CONFIG_COMMON_CLK
11#define __clk_put(clk) 12#define __clk_put(clk)
12#define __clk_get(clk) ({ 1; }) 13#define __clk_get(clk) ({ 1; })
14#endif
13 15
14#endif 16#endif
diff --git a/arch/mips/include/asm/clkdev.h b/arch/mips/include/asm/clkdev.h
index 262475414e5f..1b3ad7b09dc1 100644
--- a/arch/mips/include/asm/clkdev.h
+++ b/arch/mips/include/asm/clkdev.h
@@ -14,8 +14,10 @@
14 14
15#include <linux/slab.h> 15#include <linux/slab.h>
16 16
17#ifndef CONFIG_COMMON_CLK
17#define __clk_get(clk) ({ 1; }) 18#define __clk_get(clk) ({ 1; })
18#define __clk_put(clk) do { } while (0) 19#define __clk_put(clk) do { } while (0)
20#endif
19 21
20static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size) 22static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
21{ 23{
diff --git a/arch/sh/include/asm/clkdev.h b/arch/sh/include/asm/clkdev.h
index 6ba91868201c..c41901465fb0 100644
--- a/arch/sh/include/asm/clkdev.h
+++ b/arch/sh/include/asm/clkdev.h
@@ -25,7 +25,9 @@ static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
25 return kzalloc(size, GFP_KERNEL); 25 return kzalloc(size, GFP_KERNEL);
26} 26}
27 27
28#ifndef CONFIG_COMMON_CLK
28#define __clk_put(clk) 29#define __clk_put(clk)
29#define __clk_get(clk) ({ 1; }) 30#define __clk_get(clk) ({ 1; })
31#endif
30 32
31#endif /* __CLKDEV_H__ */ 33#endif /* __CLKDEV_H__ */
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index c687dc8d0b64..baa2f66a7d19 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -1813,6 +1813,10 @@ struct clk *__clk_register(struct device *dev, struct clk_hw *hw)
1813 clk->flags = hw->init->flags; 1813 clk->flags = hw->init->flags;
1814 clk->parent_names = hw->init->parent_names; 1814 clk->parent_names = hw->init->parent_names;
1815 clk->num_parents = hw->init->num_parents; 1815 clk->num_parents = hw->init->num_parents;
1816 if (dev && dev->driver)
1817 clk->owner = dev->driver->owner;
1818 else
1819 clk->owner = NULL;
1816 1820
1817 ret = __clk_init(dev, clk); 1821 ret = __clk_init(dev, clk);
1818 if (ret) 1822 if (ret)
@@ -1833,6 +1837,8 @@ static int _clk_register(struct device *dev, struct clk_hw *hw, struct clk *clk)
1833 goto fail_name; 1837 goto fail_name;
1834 } 1838 }
1835 clk->ops = hw->init->ops; 1839 clk->ops = hw->init->ops;
1840 if (dev && dev->driver)
1841 clk->owner = dev->driver->owner;
1836 clk->hw = hw; 1842 clk->hw = hw;
1837 clk->flags = hw->init->flags; 1843 clk->flags = hw->init->flags;
1838 clk->num_parents = hw->init->num_parents; 1844 clk->num_parents = hw->init->num_parents;
@@ -1973,6 +1979,26 @@ void devm_clk_unregister(struct device *dev, struct clk *clk)
1973} 1979}
1974EXPORT_SYMBOL_GPL(devm_clk_unregister); 1980EXPORT_SYMBOL_GPL(devm_clk_unregister);
1975 1981
1982/*
1983 * clkdev helpers
1984 */
1985int __clk_get(struct clk *clk)
1986{
1987 if (clk && !try_module_get(clk->owner))
1988 return 0;
1989
1990 return 1;
1991}
1992
1993void __clk_put(struct clk *clk)
1994{
1995 if (WARN_ON_ONCE(IS_ERR(clk)))
1996 return;
1997
1998 if (clk)
1999 module_put(clk->owner);
2000}
2001
1976/*** clk rate change notifiers ***/ 2002/*** clk rate change notifiers ***/
1977 2003
1978/** 2004/**
diff --git a/include/linux/clk-private.h b/include/linux/clk-private.h
index 8138c94409f3..8cb1865e7d9d 100644
--- a/include/linux/clk-private.h
+++ b/include/linux/clk-private.h
@@ -25,10 +25,13 @@
25 25
26#ifdef CONFIG_COMMON_CLK 26#ifdef CONFIG_COMMON_CLK
27 27
28struct module;
29
28struct clk { 30struct clk {
29 const char *name; 31 const char *name;
30 const struct clk_ops *ops; 32 const struct clk_ops *ops;
31 struct clk_hw *hw; 33 struct clk_hw *hw;
34 struct module *owner;
32 struct clk *parent; 35 struct clk *parent;
33 const char **parent_names; 36 const char **parent_names;
34 struct clk **parents; 37 struct clk **parents;
diff --git a/include/linux/clkdev.h b/include/linux/clkdev.h
index a6a6f603103b..94bad77eeb4a 100644
--- a/include/linux/clkdev.h
+++ b/include/linux/clkdev.h
@@ -43,4 +43,9 @@ int clk_add_alias(const char *, const char *, char *, struct device *);
43int clk_register_clkdev(struct clk *, const char *, const char *, ...); 43int clk_register_clkdev(struct clk *, const char *, const char *, ...);
44int clk_register_clkdevs(struct clk *, struct clk_lookup *, size_t); 44int clk_register_clkdevs(struct clk *, struct clk_lookup *, size_t);
45 45
46#ifdef CONFIG_COMMON_CLK
47int __clk_get(struct clk *clk);
48void __clk_put(struct clk *clk);
49#endif
50
46#endif 51#endif