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

watchdog: meson_gxbb: Use devm_clk_get_enabled() helper

The devm_clk_get_enabled() helper:
- calls devm_clk_get()
- calls clk_prepare_enable() and registers what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.

This simplifies the code and avoids the need of a dedicated function used
with devm_add_action_or_reset().

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://lore.kernel.org/r/6c5948373d309408095c1a098b7b4c491c5265f7.1672490071.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>

authored by

Christophe JAILLET and committed by
Wim Van Sebroeck
2cf46c63 616a2fe3

+1 -15
+1 -15
drivers/watchdog/meson_gxbb_wdt.c
··· 146 146 }; 147 147 MODULE_DEVICE_TABLE(of, meson_gxbb_wdt_dt_ids); 148 148 149 - static void meson_clk_disable_unprepare(void *data) 150 - { 151 - clk_disable_unprepare(data); 152 - } 153 - 154 149 static int meson_gxbb_wdt_probe(struct platform_device *pdev) 155 150 { 156 151 struct device *dev = &pdev->dev; 157 152 struct meson_gxbb_wdt *data; 158 - int ret; 159 153 u32 ctrl_reg; 160 154 161 155 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); ··· 160 166 if (IS_ERR(data->reg_base)) 161 167 return PTR_ERR(data->reg_base); 162 168 163 - data->clk = devm_clk_get(dev, NULL); 169 + data->clk = devm_clk_get_enabled(dev, NULL); 164 170 if (IS_ERR(data->clk)) 165 171 return PTR_ERR(data->clk); 166 - 167 - ret = clk_prepare_enable(data->clk); 168 - if (ret) 169 - return ret; 170 - ret = devm_add_action_or_reset(dev, meson_clk_disable_unprepare, 171 - data->clk); 172 - if (ret) 173 - return ret; 174 172 175 173 platform_set_drvdata(pdev, data); 176 174