* [PATCH v2 0/3] clk: provide new devm helpers for prepared and enabled clocks
@ 2021-03-01 11:08 Uwe Kleine-König
2021-03-01 11:08 ` [PATCH v2 1/3] clk: generalize devm_clk_get() a bit Uwe Kleine-König
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2021-03-01 11:08 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd
Cc: linux-pwm, linux-clk, kernel, linux-kernel
Hello,
compared to the (implicit) v1 sent with Message-Id:
20201013082132.661993-1-u.kleine-koenig@pengutronix.de) I rebased
(trivially) to v5.12-rc1, fixed a bug and split the first patch in two
to make the series easier to review.
I also stripped down the demo patch to a single driver.
Thanks for considering
Uwe
Uwe Kleine-König (3):
clk: generalize devm_clk_get() a bit
clk: Provide new devm_clk_helpers for prepared and enabled clocks
pwm: atmel: Simplify using devm_clk_get_prepared()
drivers/clk/clk-devres.c | 106 +++++++++++++++++++++++++++++++--------
drivers/pwm/pwm-atmel.c | 15 +-----
include/linux/clk.h | 87 +++++++++++++++++++++++++++++++-
3 files changed, 173 insertions(+), 35 deletions(-)
base-commit: fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8
--
2.30.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v2 1/3] clk: generalize devm_clk_get() a bit 2021-03-01 11:08 [PATCH v2 0/3] clk: provide new devm helpers for prepared and enabled clocks Uwe Kleine-König @ 2021-03-01 11:08 ` Uwe Kleine-König 2021-03-01 12:41 ` kernel test robot 2021-03-01 12:46 ` kernel test robot 2021-03-01 11:08 ` [PATCH v2 2/3] clk: Provide new devm_clk_helpers for prepared and enabled clocks Uwe Kleine-König 2021-03-01 11:08 ` [PATCH v2 3/3] pwm: atmel: Simplify using devm_clk_get_prepared() Uwe Kleine-König 2 siblings, 2 replies; 8+ messages in thread From: Uwe Kleine-König @ 2021-03-01 11:08 UTC (permalink / raw) To: Michael Turquette, Stephen Boyd Cc: linux-pwm, linux-clk, kernel, linux-kernel, Uwe Kleine-König From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Allow to add an exit hook to devm managed clocks. Also use clk_get_optional() in devm_clk_get_optional instead of open coding it. The generalisation will be used in the next commit to add some more devm_clk helpers. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/clk/clk-devres.c | 75 +++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 21 deletions(-) diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c index be160764911b..7ba8670deeb6 100644 --- a/drivers/clk/clk-devres.c +++ b/drivers/clk/clk-devres.c @@ -4,39 +4,72 @@ #include <linux/export.h> #include <linux/gfp.h> +struct devm_clk_state { + struct clk *clk; + void (*exit)(struct clk *clk); +}; + static void devm_clk_release(struct device *dev, void *res) { - clk_put(*(struct clk **)res); + struct devm_clk_state *state = *(struct devm_clk_state **)res; + + if (state->exit) + state->exit(state->clk); + + clk_put(state->clk); +} + +struct clk *__devm_clk_get(struct device *dev, const char *id, + struct clk *(*get)(struct device *dev, const char *id), + int (*init)(struct clk *clk), + void (*exit)(struct clk *clk)) +{ + struct devm_clk_state *state; + struct clk *clk; + int ret; + + state = devres_alloc(devm_clk_release, sizeof(*state), GFP_KERNEL); + if (!state) + return ERR_PTR(-ENOMEM); + + clk = get(dev, id); + if (IS_ERR(clk)) { + ret = PTR_ERR(clk); + goto err_clk_get; + } + + if (init) { + ret = init(clk); + if (ret) + goto err_clk_init; + } + + state->clk = clk; + state->exit = exit; + + devres_add(dev, state); + + return clk; + +err_clk_init: + + clk_put(clk); +err_clk_get: + + devres_free(state); + return ERR_PTR(ret); } struct clk *devm_clk_get(struct device *dev, const char *id) { - struct clk **ptr, *clk; + return __devm_clk_get(dev, id, clk_get, NULL, NULL); - ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL); - if (!ptr) - return ERR_PTR(-ENOMEM); - - clk = clk_get(dev, id); - if (!IS_ERR(clk)) { - *ptr = clk; - devres_add(dev, ptr); - } else { - devres_free(ptr); - } - - return clk; } EXPORT_SYMBOL(devm_clk_get); struct clk *devm_clk_get_optional(struct device *dev, const char *id) { - struct clk *clk = devm_clk_get(dev, id); - - if (clk == ERR_PTR(-ENOENT)) - return NULL; - - return clk; + return __devm_clk_get(dev, id, clk_get_optional, NULL, NULL); } EXPORT_SYMBOL(devm_clk_get_optional); -- 2.30.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] clk: generalize devm_clk_get() a bit 2021-03-01 11:08 ` [PATCH v2 1/3] clk: generalize devm_clk_get() a bit Uwe Kleine-König @ 2021-03-01 12:41 ` kernel test robot 2021-03-01 12:46 ` kernel test robot 1 sibling, 0 replies; 8+ messages in thread From: kernel test robot @ 2021-03-01 12:41 UTC (permalink / raw) To: Uwe Kleine-König, Michael Turquette, Stephen Boyd Cc: kbuild-all, linux-pwm, linux-clk, kernel, linux-kernel, Uwe Kleine-König [-- Attachment #1: Type: text/plain, Size: 2611 bytes --] Hi "Uwe, I love your patch! Perhaps something to improve: [auto build test WARNING on fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8] url: https://github.com/0day-ci/linux/commits/Uwe-Kleine-K-nig/clk-provide-new-devm-helpers-for-prepared-and-enabled-clocks/20210301-191522 base: fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8 config: nds32-defconfig (attached as .config) compiler: nds32le-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/bf2779180284ed39480360900c07ce553f75e06a git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Uwe-Kleine-K-nig/clk-provide-new-devm-helpers-for-prepared-and-enabled-clocks/20210301-191522 git checkout bf2779180284ed39480360900c07ce553f75e06a # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nds32 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/clk/clk-devres.c:22:13: warning: no previous prototype for '__devm_clk_get' [-Wmissing-prototypes] 22 | struct clk *__devm_clk_get(struct device *dev, const char *id, | ^~~~~~~~~~~~~~ vim +/__devm_clk_get +22 drivers/clk/clk-devres.c 21 > 22 struct clk *__devm_clk_get(struct device *dev, const char *id, 23 struct clk *(*get)(struct device *dev, const char *id), 24 int (*init)(struct clk *clk), 25 void (*exit)(struct clk *clk)) 26 { 27 struct devm_clk_state *state; 28 struct clk *clk; 29 int ret; 30 31 state = devres_alloc(devm_clk_release, sizeof(*state), GFP_KERNEL); 32 if (!state) 33 return ERR_PTR(-ENOMEM); 34 35 clk = get(dev, id); 36 if (IS_ERR(clk)) { 37 ret = PTR_ERR(clk); 38 goto err_clk_get; 39 } 40 41 if (init) { 42 ret = init(clk); 43 if (ret) 44 goto err_clk_init; 45 } 46 47 state->clk = clk; 48 state->exit = exit; 49 50 devres_add(dev, state); 51 52 return clk; 53 54 err_clk_init: 55 56 clk_put(clk); 57 err_clk_get: 58 59 devres_free(state); 60 return ERR_PTR(ret); 61 } 62 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 10797 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] clk: generalize devm_clk_get() a bit 2021-03-01 11:08 ` [PATCH v2 1/3] clk: generalize devm_clk_get() a bit Uwe Kleine-König 2021-03-01 12:41 ` kernel test robot @ 2021-03-01 12:46 ` kernel test robot 1 sibling, 0 replies; 8+ messages in thread From: kernel test robot @ 2021-03-01 12:46 UTC (permalink / raw) To: Uwe Kleine-König, Michael Turquette, Stephen Boyd Cc: kbuild-all, clang-built-linux, linux-pwm, linux-clk, kernel, linux-kernel, Uwe Kleine-König [-- Attachment #1: Type: text/plain, Size: 3026 bytes --] Hi "Uwe, I love your patch! Perhaps something to improve: [auto build test WARNING on fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8] url: https://github.com/0day-ci/linux/commits/Uwe-Kleine-K-nig/clk-provide-new-devm-helpers-for-prepared-and-enabled-clocks/20210301-191522 base: fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8 config: arm64-randconfig-r036-20210301 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 5de09ef02e24d234d9fc0cd1c6dfe18a1bb784b0) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install arm64 cross compiling tool for clang build # apt-get install binutils-aarch64-linux-gnu # https://github.com/0day-ci/linux/commit/bf2779180284ed39480360900c07ce553f75e06a git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Uwe-Kleine-K-nig/clk-provide-new-devm-helpers-for-prepared-and-enabled-clocks/20210301-191522 git checkout bf2779180284ed39480360900c07ce553f75e06a # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/clk/clk-devres.c:22:13: warning: no previous prototype for function '__devm_clk_get' [-Wmissing-prototypes] struct clk *__devm_clk_get(struct device *dev, const char *id, ^ drivers/clk/clk-devres.c:22:1: note: declare 'static' if the function is not intended to be used outside of this translation unit struct clk *__devm_clk_get(struct device *dev, const char *id, ^ static 1 warning generated. vim +/__devm_clk_get +22 drivers/clk/clk-devres.c 21 > 22 struct clk *__devm_clk_get(struct device *dev, const char *id, 23 struct clk *(*get)(struct device *dev, const char *id), 24 int (*init)(struct clk *clk), 25 void (*exit)(struct clk *clk)) 26 { 27 struct devm_clk_state *state; 28 struct clk *clk; 29 int ret; 30 31 state = devres_alloc(devm_clk_release, sizeof(*state), GFP_KERNEL); 32 if (!state) 33 return ERR_PTR(-ENOMEM); 34 35 clk = get(dev, id); 36 if (IS_ERR(clk)) { 37 ret = PTR_ERR(clk); 38 goto err_clk_get; 39 } 40 41 if (init) { 42 ret = init(clk); 43 if (ret) 44 goto err_clk_init; 45 } 46 47 state->clk = clk; 48 state->exit = exit; 49 50 devres_add(dev, state); 51 52 return clk; 53 54 err_clk_init: 55 56 clk_put(clk); 57 err_clk_get: 58 59 devres_free(state); 60 return ERR_PTR(ret); 61 } 62 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 36937 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 2/3] clk: Provide new devm_clk_helpers for prepared and enabled clocks 2021-03-01 11:08 [PATCH v2 0/3] clk: provide new devm helpers for prepared and enabled clocks Uwe Kleine-König 2021-03-01 11:08 ` [PATCH v2 1/3] clk: generalize devm_clk_get() a bit Uwe Kleine-König @ 2021-03-01 11:08 ` Uwe Kleine-König 2021-03-01 13:00 ` kernel test robot 2021-03-01 13:40 ` kernel test robot 2021-03-01 11:08 ` [PATCH v2 3/3] pwm: atmel: Simplify using devm_clk_get_prepared() Uwe Kleine-König 2 siblings, 2 replies; 8+ messages in thread From: Uwe Kleine-König @ 2021-03-01 11:08 UTC (permalink / raw) To: Michael Turquette, Stephen Boyd Cc: linux-pwm, linux-clk, kernel, linux-kernel, Uwe Kleine-König From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> When a driver keeps a clock prepared (or enabled) during the whole lifetime of the driver, these helpers allow to simplify the drivers. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/clk/clk-devres.c | 31 ++++++++++++++ include/linux/clk.h | 87 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 117 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c index 7ba8670deeb6..7d487e49fca4 100644 --- a/drivers/clk/clk-devres.c +++ b/drivers/clk/clk-devres.c @@ -67,12 +67,43 @@ struct clk *devm_clk_get(struct device *dev, const char *id) } EXPORT_SYMBOL(devm_clk_get); +struct clk *devm_clk_get_prepared(struct device *dev, const char *id) +{ + return __devm_clk_get(dev, id, clk_get, clk_prepare, clk_unprepare); + +} +EXPORT_SYMBOL(devm_clk_get_prepared); + +struct clk *devm_clk_get_enabled(struct device *dev, const char *id) +{ + return __devm_clk_get(dev, id, clk_get, + clk_prepare_enable, clk_disable_unprepare); + +} +EXPORT_SYMBOL(devm_clk_get_prepared); + struct clk *devm_clk_get_optional(struct device *dev, const char *id) { return __devm_clk_get(dev, id, clk_get_optional, NULL, NULL); } EXPORT_SYMBOL(devm_clk_get_optional); +struct clk *devm_clk_get_optional_prepared(struct device *dev, const char *id) +{ + return __devm_clk_get(dev, id, clk_get_optional, + clk_prepare, clk_unprepare); + +} +EXPORT_SYMBOL(devm_clk_get_optional_prepared); + +struct clk *devm_clk_get_optional_enabled(struct device *dev, const char *id) +{ + return __devm_clk_get(dev, id, clk_get_optional, + clk_prepare_enable, clk_disable_unprepare); + +} +EXPORT_SYMBOL(devm_clk_get_optional_prepared); + struct clk_bulk_devres { struct clk_bulk_data *clks; int num_clks; diff --git a/include/linux/clk.h b/include/linux/clk.h index 266e8de3cb51..b3c5da388b08 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -449,7 +449,7 @@ int __must_check devm_clk_bulk_get_all(struct device *dev, * the clock producer. (IOW, @id may be identical strings, but * clk_get may return different clock producers depending on @dev.) * - * Drivers must assume that the clock source is not enabled. + * Drivers must assume that the clock source is neither prepared nor enabled. * * devm_clk_get should not be called from within interrupt context. * @@ -458,6 +458,47 @@ int __must_check devm_clk_bulk_get_all(struct device *dev, */ struct clk *devm_clk_get(struct device *dev, const char *id); +/** + * devm_clk_get_prepared - devm_clk_get() + clk_prepare() + * @dev: device for clock "consumer" + * @id: clock consumer ID + * + * Returns a struct clk corresponding to the clock producer, or + * valid IS_ERR() condition containing errno. The implementation + * uses @dev and @id to determine the clock consumer, and thereby + * the clock producer. (IOW, @id may be identical strings, but + * clk_get may return different clock producers depending on @dev.) + * + * The returned clk (if valid) is prepared. Drivers must however assume that the + * clock is not enabled. + * + * devm_clk_get_prepared should not be called from within interrupt context. + * + * The clock will automatically be unprepared and freed when the + * device is unbound from the bus. + */ +struct clk *devm_clk_get_prepared(struct device *dev, const char *id); + +/** + * devm_clk_get_enabled - devm_clk_get() + clk_prepare_enable() + * @dev: device for clock "consumer" + * @id: clock consumer ID + * + * Returns a struct clk corresponding to the clock producer, or + * valid IS_ERR() condition containing errno. The implementation + * uses @dev and @id to determine the clock consumer, and thereby + * the clock producer. (IOW, @id may be identical strings, but + * clk_get may return different clock producers depending on @dev.) + * + * The returned clk (if valid) is prepared and enabled. + * + * devm_clk_get_prepared should not be called from within interrupt context. + * + * The clock will automatically be disabled, unprepared and freed when the + * device is unbound from the bus. + */ +struct clk *devm_clk_get_enabled(struct device *dev, const char *id); + /** * devm_clk_get_optional - lookup and obtain a managed reference to an optional * clock producer. @@ -469,6 +510,26 @@ struct clk *devm_clk_get(struct device *dev, const char *id); */ struct clk *devm_clk_get_optional(struct device *dev, const char *id); +/** + * devm_clk_get_optional_prepared - devm_clk_get_optional() + clk_prepare() + * @dev: device for clock "consumer" + * @id: clock consumer ID + * + * Behaves the same as devm_clk_get_prepared() except where there is no clock producer. + * In this case, instead of returning -ENOENT, the function returns NULL. + */ +struct clk *devm_clk_get_optional_prepared(struct device *dev, const char *id); + +/** + * devm_clk_get_optional_enabled - devm_clk_get_optional() + clk_prepare_enable() + * @dev: device for clock "consumer" + * @id: clock consumer ID + * + * Behaves the same as devm_clk_get_enabled() except where there is no clock producer. + * In this case, instead of returning -ENOENT, the function returns NULL. + */ +struct clk *devm_clk_get_optional_enabled(struct device *dev, const char *id); + /** * devm_get_clk_from_child - lookup and obtain a managed reference to a * clock producer from child node. @@ -813,12 +874,36 @@ static inline struct clk *devm_clk_get(struct device *dev, const char *id) return NULL; } +static inline struct clk *devm_clk_get_prepared(struct device *dev, + const char *id) +{ + return NULL; +} + +static inline struct clk *devm_clk_get_enabled(struct device *dev, + const char *id) +{ + return NULL; +} + static inline struct clk *devm_clk_get_optional(struct device *dev, const char *id) { return NULL; } +static inline struct clk *devm_clk_get_optional_prepared(struct device *dev, + const char *id) +{ + return NULL; +} + +static inline struct clk *devm_clk_get_optional_enabled(struct device *dev, + const char *id) +{ + return NULL; +} + static inline int __must_check devm_clk_bulk_get(struct device *dev, int num_clks, struct clk_bulk_data *clks) { -- 2.30.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] clk: Provide new devm_clk_helpers for prepared and enabled clocks 2021-03-01 11:08 ` [PATCH v2 2/3] clk: Provide new devm_clk_helpers for prepared and enabled clocks Uwe Kleine-König @ 2021-03-01 13:00 ` kernel test robot 2021-03-01 13:40 ` kernel test robot 1 sibling, 0 replies; 8+ messages in thread From: kernel test robot @ 2021-03-01 13:00 UTC (permalink / raw) To: Uwe Kleine-König, Michael Turquette, Stephen Boyd Cc: kbuild-all, linux-pwm, linux-clk, kernel, linux-kernel, Uwe Kleine-König [-- Attachment #1: Type: text/plain, Size: 8996 bytes --] Hi "Uwe, I love your patch! Yet something to improve: [auto build test ERROR on fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8] url: https://github.com/0day-ci/linux/commits/Uwe-Kleine-K-nig/clk-provide-new-devm-helpers-for-prepared-and-enabled-clocks/20210301-191522 base: fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8 config: sh-randconfig-r035-20210301 (attached as .config) compiler: sh4-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/fb9e331a334ed83c22735b4398e56b121ca9dbf5 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Uwe-Kleine-K-nig/clk-provide-new-devm-helpers-for-prepared-and-enabled-clocks/20210301-191522 git checkout fb9e331a334ed83c22735b4398e56b121ca9dbf5 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sh If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): drivers/clk/clk-devres.c:22:13: warning: no previous prototype for '__devm_clk_get' [-Wmissing-prototypes] 22 | struct clk *__devm_clk_get(struct device *dev, const char *id, | ^~~~~~~~~~~~~~ In file included from include/linux/linkage.h:7, from include/linux/kernel.h:7, from include/linux/clk.h:13, from drivers/clk/clk-devres.c:2: >> include/linux/export.h:67:36: error: redefinition of '__ksymtab_devm_clk_get_prepared' 67 | static const struct kernel_symbol __ksymtab_##sym \ | ^~~~~~~~~~ include/linux/export.h:108:2: note: in expansion of macro '__KSYMTAB_ENTRY' 108 | __KSYMTAB_ENTRY(sym, sec) | ^~~~~~~~~~~~~~~ include/linux/export.h:147:39: note: in expansion of macro '___EXPORT_SYMBOL' 147 | #define __EXPORT_SYMBOL(sym, sec, ns) ___EXPORT_SYMBOL(sym, sec, ns) | ^~~~~~~~~~~~~~~~ include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL' 155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "") | ^~~~~~~~~~~~~~~ include/linux/export.h:158:29: note: in expansion of macro '_EXPORT_SYMBOL' 158 | #define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "") | ^~~~~~~~~~~~~~ drivers/clk/clk-devres.c:83:1: note: in expansion of macro 'EXPORT_SYMBOL' 83 | EXPORT_SYMBOL(devm_clk_get_prepared); | ^~~~~~~~~~~~~ include/linux/export.h:67:36: note: previous definition of '__ksymtab_devm_clk_get_prepared' was here 67 | static const struct kernel_symbol __ksymtab_##sym \ | ^~~~~~~~~~ include/linux/export.h:108:2: note: in expansion of macro '__KSYMTAB_ENTRY' 108 | __KSYMTAB_ENTRY(sym, sec) | ^~~~~~~~~~~~~~~ include/linux/export.h:147:39: note: in expansion of macro '___EXPORT_SYMBOL' 147 | #define __EXPORT_SYMBOL(sym, sec, ns) ___EXPORT_SYMBOL(sym, sec, ns) | ^~~~~~~~~~~~~~~~ include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL' 155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "") | ^~~~~~~~~~~~~~~ include/linux/export.h:158:29: note: in expansion of macro '_EXPORT_SYMBOL' 158 | #define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "") | ^~~~~~~~~~~~~~ drivers/clk/clk-devres.c:75:1: note: in expansion of macro 'EXPORT_SYMBOL' 75 | EXPORT_SYMBOL(devm_clk_get_prepared); | ^~~~~~~~~~~~~ >> include/linux/export.h:67:36: error: redefinition of '__ksymtab_devm_clk_get_optional_prepared' 67 | static const struct kernel_symbol __ksymtab_##sym \ | ^~~~~~~~~~ include/linux/export.h:108:2: note: in expansion of macro '__KSYMTAB_ENTRY' 108 | __KSYMTAB_ENTRY(sym, sec) | ^~~~~~~~~~~~~~~ include/linux/export.h:147:39: note: in expansion of macro '___EXPORT_SYMBOL' 147 | #define __EXPORT_SYMBOL(sym, sec, ns) ___EXPORT_SYMBOL(sym, sec, ns) | ^~~~~~~~~~~~~~~~ include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL' 155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "") | ^~~~~~~~~~~~~~~ include/linux/export.h:158:29: note: in expansion of macro '_EXPORT_SYMBOL' 158 | #define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "") | ^~~~~~~~~~~~~~ drivers/clk/clk-devres.c:105:1: note: in expansion of macro 'EXPORT_SYMBOL' 105 | EXPORT_SYMBOL(devm_clk_get_optional_prepared); | ^~~~~~~~~~~~~ include/linux/export.h:67:36: note: previous definition of '__ksymtab_devm_clk_get_optional_prepared' was here 67 | static const struct kernel_symbol __ksymtab_##sym \ | ^~~~~~~~~~ include/linux/export.h:108:2: note: in expansion of macro '__KSYMTAB_ENTRY' 108 | __KSYMTAB_ENTRY(sym, sec) | ^~~~~~~~~~~~~~~ include/linux/export.h:147:39: note: in expansion of macro '___EXPORT_SYMBOL' 147 | #define __EXPORT_SYMBOL(sym, sec, ns) ___EXPORT_SYMBOL(sym, sec, ns) | ^~~~~~~~~~~~~~~~ include/linux/export.h:155:34: note: in expansion of macro '__EXPORT_SYMBOL' 155 | #define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "") | ^~~~~~~~~~~~~~~ include/linux/export.h:158:29: note: in expansion of macro '_EXPORT_SYMBOL' 158 | #define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "") | ^~~~~~~~~~~~~~ drivers/clk/clk-devres.c:97:1: note: in expansion of macro 'EXPORT_SYMBOL' 97 | EXPORT_SYMBOL(devm_clk_get_optional_prepared); | ^~~~~~~~~~~~~ vim +/__ksymtab_devm_clk_get_prepared +67 include/linux/export.h f50169324df4ad Paul Gortmaker 2011-05-23 41 7290d58095712a Ard Biesheuvel 2018-08-21 42 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS 7290d58095712a Ard Biesheuvel 2018-08-21 43 #include <linux/compiler.h> 7290d58095712a Ard Biesheuvel 2018-08-21 44 /* 7290d58095712a Ard Biesheuvel 2018-08-21 45 * Emit the ksymtab entry as a pair of relative references: this reduces 7290d58095712a Ard Biesheuvel 2018-08-21 46 * the size by half on 64-bit architectures, and eliminates the need for 7290d58095712a Ard Biesheuvel 2018-08-21 47 * absolute relocations that require runtime processing on relocatable 7290d58095712a Ard Biesheuvel 2018-08-21 48 * kernels. 7290d58095712a Ard Biesheuvel 2018-08-21 49 */ 7290d58095712a Ard Biesheuvel 2018-08-21 50 #define __KSYMTAB_ENTRY(sym, sec) \ 7290d58095712a Ard Biesheuvel 2018-08-21 51 __ADDRESSABLE(sym) \ 7290d58095712a Ard Biesheuvel 2018-08-21 52 asm(" .section \"___ksymtab" sec "+" #sym "\", \"a\" \n" \ ed13fc33f76303 Matthias Maennich 2019-09-06 53 " .balign 4 \n" \ 7290d58095712a Ard Biesheuvel 2018-08-21 54 "__ksymtab_" #sym ": \n" \ 7290d58095712a Ard Biesheuvel 2018-08-21 55 " .long " #sym "- . \n" \ 7290d58095712a Ard Biesheuvel 2018-08-21 56 " .long __kstrtab_" #sym "- . \n" \ c3a6cf19e695c8 Masahiro Yamada 2019-10-18 57 " .long __kstrtabns_" #sym "- . \n" \ 7290d58095712a Ard Biesheuvel 2018-08-21 58 " .previous \n") 7290d58095712a Ard Biesheuvel 2018-08-21 59 7290d58095712a Ard Biesheuvel 2018-08-21 60 struct kernel_symbol { 7290d58095712a Ard Biesheuvel 2018-08-21 61 int value_offset; 7290d58095712a Ard Biesheuvel 2018-08-21 62 int name_offset; 8651ec01daedad Matthias Maennich 2019-09-06 63 int namespace_offset; 7290d58095712a Ard Biesheuvel 2018-08-21 64 }; 7290d58095712a Ard Biesheuvel 2018-08-21 65 #else 7290d58095712a Ard Biesheuvel 2018-08-21 66 #define __KSYMTAB_ENTRY(sym, sec) \ 7290d58095712a Ard Biesheuvel 2018-08-21 @67 static const struct kernel_symbol __ksymtab_##sym \ 7290d58095712a Ard Biesheuvel 2018-08-21 68 __attribute__((section("___ksymtab" sec "+" #sym), used)) \ ed13fc33f76303 Matthias Maennich 2019-09-06 69 __aligned(sizeof(void *)) \ c3a6cf19e695c8 Masahiro Yamada 2019-10-18 70 = { (unsigned long)&sym, __kstrtab_##sym, __kstrtabns_##sym } 7290d58095712a Ard Biesheuvel 2018-08-21 71 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 37462 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] clk: Provide new devm_clk_helpers for prepared and enabled clocks 2021-03-01 11:08 ` [PATCH v2 2/3] clk: Provide new devm_clk_helpers for prepared and enabled clocks Uwe Kleine-König 2021-03-01 13:00 ` kernel test robot @ 2021-03-01 13:40 ` kernel test robot 1 sibling, 0 replies; 8+ messages in thread From: kernel test robot @ 2021-03-01 13:40 UTC (permalink / raw) To: Uwe Kleine-König, Michael Turquette, Stephen Boyd Cc: kbuild-all, linux-pwm, linux-clk, kernel, linux-kernel, Uwe Kleine-König [-- Attachment #1: Type: text/plain, Size: 2100 bytes --] Hi "Uwe, I love your patch! Yet something to improve: [auto build test ERROR on fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8] url: https://github.com/0day-ci/linux/commits/Uwe-Kleine-K-nig/clk-provide-new-devm-helpers-for-prepared-and-enabled-clocks/20210301-191522 base: fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8 config: i386-randconfig-s002-20210301 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.3-241-geaceeafa-dirty # https://github.com/0day-ci/linux/commit/fb9e331a334ed83c22735b4398e56b121ca9dbf5 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Uwe-Kleine-K-nig/clk-provide-new-devm-helpers-for-prepared-and-enabled-clocks/20210301-191522 git checkout fb9e331a334ed83c22735b4398e56b121ca9dbf5 # save the attached .config to linux build tree make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): drivers/clk/clk-devres.c:22:13: warning: no previous prototype for '__devm_clk_get' [-Wmissing-prototypes] 22 | struct clk *__devm_clk_get(struct device *dev, const char *id, | ^~~~~~~~~~~~~~ /tmp/ccuTaeUR.s: Assembler messages: >> /tmp/ccuTaeUR.s:37: Error: symbol `__kstrtab_devm_clk_get_prepared' is already defined >> /tmp/ccuTaeUR.s:39: Error: symbol `__kstrtabns_devm_clk_get_prepared' is already defined /tmp/ccuTaeUR.s:45: Error: symbol `__ksymtab_devm_clk_get_prepared' is already defined >> /tmp/ccuTaeUR.s:82: Error: symbol `__kstrtab_devm_clk_get_optional_prepared' is already defined >> /tmp/ccuTaeUR.s:84: Error: symbol `__kstrtabns_devm_clk_get_optional_prepared' is already defined /tmp/ccuTaeUR.s:90: Error: symbol `__ksymtab_devm_clk_get_optional_prepared' is already defined --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 29502 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 3/3] pwm: atmel: Simplify using devm_clk_get_prepared() 2021-03-01 11:08 [PATCH v2 0/3] clk: provide new devm helpers for prepared and enabled clocks Uwe Kleine-König 2021-03-01 11:08 ` [PATCH v2 1/3] clk: generalize devm_clk_get() a bit Uwe Kleine-König 2021-03-01 11:08 ` [PATCH v2 2/3] clk: Provide new devm_clk_helpers for prepared and enabled clocks Uwe Kleine-König @ 2021-03-01 11:08 ` Uwe Kleine-König 2 siblings, 0 replies; 8+ messages in thread From: Uwe Kleine-König @ 2021-03-01 11:08 UTC (permalink / raw) To: Michael Turquette, Stephen Boyd Cc: linux-pwm, linux-clk, kernel, linux-kernel, Uwe Kleine-König From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> With devm_clk_get_prepared() caring to unprepare the clock the error path and remove callback can be simplified accordingly. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/pwm/pwm-atmel.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c index 5813339b597b..d65e23da2582 100644 --- a/drivers/pwm/pwm-atmel.c +++ b/drivers/pwm/pwm-atmel.c @@ -415,16 +415,10 @@ static int atmel_pwm_probe(struct platform_device *pdev) if (IS_ERR(atmel_pwm->base)) return PTR_ERR(atmel_pwm->base); - atmel_pwm->clk = devm_clk_get(&pdev->dev, NULL); + atmel_pwm->clk = devm_clk_get_prepared(&pdev->dev, NULL); if (IS_ERR(atmel_pwm->clk)) return PTR_ERR(atmel_pwm->clk); - ret = clk_prepare(atmel_pwm->clk); - if (ret) { - dev_err(&pdev->dev, "failed to prepare PWM clock\n"); - return ret; - } - atmel_pwm->chip.dev = &pdev->dev; atmel_pwm->chip.ops = &atmel_pwm_ops; atmel_pwm->chip.of_xlate = of_pwm_xlate_with_flags; @@ -435,23 +429,18 @@ static int atmel_pwm_probe(struct platform_device *pdev) ret = pwmchip_add(&atmel_pwm->chip); if (ret < 0) { dev_err(&pdev->dev, "failed to add PWM chip %d\n", ret); - goto unprepare_clk; + return ret; } platform_set_drvdata(pdev, atmel_pwm); return ret; - -unprepare_clk: - clk_unprepare(atmel_pwm->clk); - return ret; } static int atmel_pwm_remove(struct platform_device *pdev) { struct atmel_pwm_chip *atmel_pwm = platform_get_drvdata(pdev); - clk_unprepare(atmel_pwm->clk); mutex_destroy(&atmel_pwm->isr_lock); return pwmchip_remove(&atmel_pwm->chip); -- 2.30.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-03-01 13:42 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-03-01 11:08 [PATCH v2 0/3] clk: provide new devm helpers for prepared and enabled clocks Uwe Kleine-König 2021-03-01 11:08 ` [PATCH v2 1/3] clk: generalize devm_clk_get() a bit Uwe Kleine-König 2021-03-01 12:41 ` kernel test robot 2021-03-01 12:46 ` kernel test robot 2021-03-01 11:08 ` [PATCH v2 2/3] clk: Provide new devm_clk_helpers for prepared and enabled clocks Uwe Kleine-König 2021-03-01 13:00 ` kernel test robot 2021-03-01 13:40 ` kernel test robot 2021-03-01 11:08 ` [PATCH v2 3/3] pwm: atmel: Simplify using devm_clk_get_prepared() Uwe Kleine-König
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox