Skip to content

Commit 162b169

Browse files
Zhang ZekunBartosz Golaszewski
authored andcommitted
gpio: mb86s7x: Use helper function devm_clk_get_optional_enabled()
devm_clk_get_optional() and clk_prepare_enable() can be replaced by helper function devm_clk_get_optional_enabled(). Let's simplify code with use of devm_clk_get_optional_enabled() and avoid calling clk_disable_unprepare(). Signed-off-by: Zhang Zekun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 8abc67a commit 162b169

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

drivers/gpio/gpio-mb86s7x.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
struct mb86s70_gpio_chip {
3636
struct gpio_chip gc;
3737
void __iomem *base;
38-
struct clk *clk;
3938
spinlock_t lock;
4039
};
4140

@@ -157,6 +156,7 @@ static int mb86s70_gpio_to_irq(struct gpio_chip *gc, unsigned int offset)
157156
static int mb86s70_gpio_probe(struct platform_device *pdev)
158157
{
159158
struct mb86s70_gpio_chip *gchip;
159+
struct clk *clk;
160160
int ret;
161161

162162
gchip = devm_kzalloc(&pdev->dev, sizeof(*gchip), GFP_KERNEL);
@@ -169,13 +169,9 @@ static int mb86s70_gpio_probe(struct platform_device *pdev)
169169
if (IS_ERR(gchip->base))
170170
return PTR_ERR(gchip->base);
171171

172-
gchip->clk = devm_clk_get_optional(&pdev->dev, NULL);
173-
if (IS_ERR(gchip->clk))
174-
return PTR_ERR(gchip->clk);
175-
176-
ret = clk_prepare_enable(gchip->clk);
177-
if (ret)
178-
return ret;
172+
clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
173+
if (IS_ERR(clk))
174+
return PTR_ERR(clk);
179175

180176
spin_lock_init(&gchip->lock);
181177

@@ -193,11 +189,9 @@ static int mb86s70_gpio_probe(struct platform_device *pdev)
193189
gchip->gc.base = -1;
194190

195191
ret = gpiochip_add_data(&gchip->gc, gchip);
196-
if (ret) {
197-
dev_err(&pdev->dev, "couldn't register gpio driver\n");
198-
clk_disable_unprepare(gchip->clk);
199-
return ret;
200-
}
192+
if (ret)
193+
return dev_err_probe(&pdev->dev, ret,
194+
"couldn't register gpio driver\n");
201195

202196
acpi_gpiochip_request_interrupts(&gchip->gc);
203197

@@ -210,7 +204,6 @@ static void mb86s70_gpio_remove(struct platform_device *pdev)
210204

211205
acpi_gpiochip_free_interrupts(&gchip->gc);
212206
gpiochip_remove(&gchip->gc);
213-
clk_disable_unprepare(gchip->clk);
214207
}
215208

216209
static const struct of_device_id mb86s70_gpio_dt_ids[] = {

0 commit comments

Comments
 (0)