Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: Introduce optional unprepare_unused callback

An unprepare_unused callback is introduced due to the same reasons to
why the disable_unused callback was added.

During the clk_disable_unused sequence, those clk_hw that needs specific
treatment with regards to being unprepared, shall implement the
unprepare_unused callback.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mike Turquette <mturquette@linaro.org>

authored by

Ulf Hansson and committed by
Mike Turquette
3cc8247f 1c155b3d

+10 -2
+5 -2
drivers/clk/clk.c
··· 352 352 if (clk->flags & CLK_IGNORE_UNUSED) 353 353 return; 354 354 355 - if (__clk_is_prepared(clk)) 356 - if (clk->ops->unprepare) 355 + if (__clk_is_prepared(clk)) { 356 + if (clk->ops->unprepare_unused) 357 + clk->ops->unprepare_unused(clk->hw); 358 + else if (clk->ops->unprepare) 357 359 clk->ops->unprepare(clk->hw); 360 + } 358 361 } 359 362 360 363 /* caller must hold prepare_lock */
+5
include/linux/clk-provider.h
··· 49 49 * This function is allowed to sleep. Optional, if this op is not 50 50 * set then the prepare count will be used. 51 51 * 52 + * @unprepare_unused: Unprepare the clock atomically. Only called from 53 + * clk_disable_unused for prepare clocks with special needs. 54 + * Called with prepare mutex held. This function may sleep. 55 + * 52 56 * @enable: Enable the clock atomically. This must not return until the 53 57 * clock is generating a valid clock signal, usable by consumer 54 58 * devices. Called with enable_lock held. This function must not ··· 117 113 int (*prepare)(struct clk_hw *hw); 118 114 void (*unprepare)(struct clk_hw *hw); 119 115 int (*is_prepared)(struct clk_hw *hw); 116 + void (*unprepare_unused)(struct clk_hw *hw); 120 117 int (*enable)(struct clk_hw *hw); 121 118 void (*disable)(struct clk_hw *hw); 122 119 int (*is_enabled)(struct clk_hw *hw);