[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200323180632.14119-5-Sergey.Semin@baikalelectronics.ru>
Date: Mon, 23 Mar 2020 21:06:30 +0300
From: <Sergey.Semin@...kalelectronics.ru>
To: Hoan Tran <hoan@...amperecomputing.com>,
Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <bgolaszewski@...libre.com>
CC: Serge Semin <Sergey.Semin@...kalelectronics.ru>,
Serge Semin <fancer.lancer@...il.com>,
Alexey Malahov <Alexey.Malahov@...kalelectronics.ru>,
Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
Paul Burton <paulburton@...nel.org>,
Ralf Baechle <ralf@...ux-mips.org>,
"Enrico Weigelt, metux IT consult" <info@...ux.net>,
Thomas Gleixner <tglx@...utronix.de>,
Kate Stewart <kstewart@...uxfoundation.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
<linux-gpio@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH v2 4/6] gpio: dwapb: Use optional-clocks interface for APB ref-clock
From: Serge Semin <Sergey.Semin@...kalelectronics.ru>
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@...kalelectronics.ru>
Reviewed-by: Linus Walleij <linus.walleij@...aro.org>
Cc: Alexey Malahov <Alexey.Malahov@...kalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@...ha.franken.de>
Cc: Paul Burton <paulburton@...nel.org>
Cc: Ralf Baechle <ralf@...ux-mips.org>
---
Changelog v2:
- Print error instead of info-message if APB clock either failed to be
acquired or couldn't be enabled.
---
drivers/gpio/gpio-dwapb.c | 20 +++++++++++---------
1 file 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++) {
--
2.25.1
Powered by blists - more mailing lists