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

Input: snvs_pwrkey - use devm_clk_get_optional_enabled()

Switch to using devm_clk_get_optional_enabled() helper instead of
acquiring the clock with devm_clk_get_optional(), enabling it, and
defining and installing a custom devm action to call clk_disable().

Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/ZtDDGMaOFlMYjOrt@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+1 -23
+1 -23
drivers/input/keyboard/snvs_pwrkey.c
··· 100 100 return IRQ_HANDLED; 101 101 } 102 102 103 - static void imx_snvs_pwrkey_disable_clk(void *data) 104 - { 105 - clk_disable_unprepare(data); 106 - } 107 - 108 103 static void imx_snvs_pwrkey_act(void *pdata) 109 104 { 110 105 struct pwrkey_drv_data *pd = pdata; ··· 136 141 dev_warn(&pdev->dev, "KEY_POWER without setting in dts\n"); 137 142 } 138 143 139 - clk = devm_clk_get_optional(&pdev->dev, NULL); 144 + clk = devm_clk_get_optional_enabled(&pdev->dev, NULL); 140 145 if (IS_ERR(clk)) { 141 146 dev_err(&pdev->dev, "Failed to get snvs clock (%pe)\n", clk); 142 147 return PTR_ERR(clk); 143 - } 144 - 145 - error = clk_prepare_enable(clk); 146 - if (error) { 147 - dev_err(&pdev->dev, "Failed to enable snvs clock (%pe)\n", 148 - ERR_PTR(error)); 149 - return error; 150 - } 151 - 152 - error = devm_add_action_or_reset(&pdev->dev, 153 - imx_snvs_pwrkey_disable_clk, clk); 154 - if (error) { 155 - dev_err(&pdev->dev, 156 - "Failed to register clock cleanup handler (%pe)\n", 157 - ERR_PTR(error)); 158 - return error; 159 148 } 160 149 161 150 pdata->wakeup = of_property_read_bool(np, "wakeup-source"); ··· 183 204 error = devm_request_irq(&pdev->dev, pdata->irq, 184 205 imx_snvs_pwrkey_interrupt, 185 206 0, pdev->name, pdev); 186 - 187 207 if (error) { 188 208 dev_err(&pdev->dev, "interrupt not available.\n"); 189 209 return error;