summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpio-dwapb.c
diff options
context:
space:
mode:
authorSerge Semin <Sergey.Semin@baikalelectronics.ru>2020-03-23 22:53:59 +0300
committerLinus Walleij <linus.walleij@linaro.org>2020-04-17 12:29:21 +0200
commit3ea8094c3b45495a18b75afd27cfda9597bf0e7d (patch)
treec3c94994362a028ce2260792e6b23e95f36cfe27 /drivers/gpio/gpio-dwapb.c
parentc55812afd3954c20c0d06b00ee9271ca6a3d8eab (diff)
gpio: dwapb: Use optional-clocks interface for APB ref-clock
The common clocks kernel framework provides a generic way to use an optional reference clock sources. If it's utilized there is no need in checking whether the clock descriptor pointer is actually a negative error at the moment of the prepare/unprepare clocks method calling. So if the corresponding clock source is provided, then getting an error shall actually terminate the device probe procedure. If it isn't specified then the driver shall proceed with further initializations. We'll use the optional clocks getting method to handle the APB reference clock, which can be provided for instance in the device of-node with "bus" clock-name. Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Paul Burton <paulburton@kernel.org> Cc: Ralf Baechle <ralf@linux-mips.org> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20200323195401.30338-5-Sergey.Semin@baikalelectronics.ru Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-dwapb.c')
-rw-r--r--drivers/gpio/gpio-dwapb.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
index 92e127e74813..0c5abfa361e6 100644
--- a/drivers/gpio/gpio-dwapb.c
+++ b/drivers/gpio/gpio-dwapb.c
@@ -690,13 +690,16 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
return PTR_ERR(gpio->regs);
/* Optional bus clock */
- gpio->clk = devm_clk_get(&pdev->dev, "bus");
- if (!IS_ERR(gpio->clk)) {
- err = clk_prepare_enable(gpio->clk);
- if (err) {
- dev_info(&pdev->dev, "Cannot enable clock\n");
- return err;
- }
+ gpio->clk = devm_clk_get_optional(&pdev->dev, "bus");
+ if (IS_ERR(gpio->clk)) {
+ dev_err(&pdev->dev, "Cannot get APB clock\n");
+ return PTR_ERR(gpio->clk);
+ }
+
+ err = clk_prepare_enable(gpio->clk);
+ if (err) {
+ dev_err(&pdev->dev, "Cannot enable APB clock\n");
+ return err;
}
gpio->flags = 0;
@@ -793,8 +796,7 @@ static int dwapb_gpio_resume(struct device *dev)
unsigned long flags;
int i;
- if (!IS_ERR(gpio->clk))
- clk_prepare_enable(gpio->clk);
+ clk_prepare_enable(gpio->clk);
spin_lock_irqsave(&gc->bgpio_lock, flags);
for (i = 0; i < gpio->nr_ports; i++) {