mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-09-21 12:11:49 +08:00
gpio: lpc18xx: Use helper function devm_clk_get_enabled()
devm_clk_get() and clk_prepare_enable() can be replaced by helper function devm_clk_get_enabled(). Let's use devm_clk_get_enabled() to simplify code and avoid calling clk_disable_unprepare(). Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Link: https://lore.kernel.org/r/20240904092311.9544-3-zhangzekun11@huawei.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
da426eda1b
commit
8abc67adc9
@ -47,7 +47,6 @@ struct lpc18xx_gpio_pin_ic {
|
||||
struct lpc18xx_gpio_chip {
|
||||
struct gpio_chip gpio;
|
||||
void __iomem *base;
|
||||
struct clk *clk;
|
||||
struct lpc18xx_gpio_pin_ic *pin_ic;
|
||||
spinlock_t lock;
|
||||
};
|
||||
@ -328,6 +327,7 @@ static int lpc18xx_gpio_probe(struct platform_device *pdev)
|
||||
struct device *dev = &pdev->dev;
|
||||
struct lpc18xx_gpio_chip *gc;
|
||||
int index, ret;
|
||||
struct clk *clk;
|
||||
|
||||
gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL);
|
||||
if (!gc)
|
||||
@ -352,16 +352,10 @@ static int lpc18xx_gpio_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(gc->base))
|
||||
return PTR_ERR(gc->base);
|
||||
|
||||
gc->clk = devm_clk_get(dev, NULL);
|
||||
if (IS_ERR(gc->clk)) {
|
||||
clk = devm_clk_get_enabled(dev, NULL);
|
||||
if (IS_ERR(clk)) {
|
||||
dev_err(dev, "input clock not found\n");
|
||||
return PTR_ERR(gc->clk);
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(gc->clk);
|
||||
if (ret) {
|
||||
dev_err(dev, "unable to enable clock\n");
|
||||
return ret;
|
||||
return PTR_ERR(clk);
|
||||
}
|
||||
|
||||
spin_lock_init(&gc->lock);
|
||||
@ -369,11 +363,8 @@ static int lpc18xx_gpio_probe(struct platform_device *pdev)
|
||||
gc->gpio.parent = dev;
|
||||
|
||||
ret = devm_gpiochip_add_data(dev, &gc->gpio, gc);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to add gpio chip\n");
|
||||
clk_disable_unprepare(gc->clk);
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to add gpio chip\n");
|
||||
|
||||
/* On error GPIO pin interrupt controller just won't be registered */
|
||||
lpc18xx_gpio_pin_ic_probe(gc);
|
||||
@ -387,8 +378,6 @@ static void lpc18xx_gpio_remove(struct platform_device *pdev)
|
||||
|
||||
if (gc->pin_ic)
|
||||
irq_domain_remove(gc->pin_ic->domain);
|
||||
|
||||
clk_disable_unprepare(gc->clk);
|
||||
}
|
||||
|
||||
static const struct of_device_id lpc18xx_gpio_match[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user