From patchwork Mon Mar 23 18:06:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 207165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AEC8C3F2CD for ; Mon, 23 Mar 2020 18:08:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 745DE2072D for ; Mon, 23 Mar 2020 18:08:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727942AbgCWSH5 (ORCPT ); Mon, 23 Mar 2020 14:07:57 -0400 Received: from mail.baikalelectronics.com ([87.245.175.226]:37616 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727938AbgCWSH4 (ORCPT ); Mon, 23 Mar 2020 14:07:56 -0400 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id B8C87803078E; Mon, 23 Mar 2020 18:07:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KMehCRwK9X57; Mon, 23 Mar 2020 21:07:53 +0300 (MSK) From: To: Hoan Tran , Linus Walleij , Bartosz Golaszewski CC: Serge Semin , Serge Semin , Alexey Malahov , Thomas Bogendoerfer , Paul Burton , Ralf Baechle , "Enrico Weigelt, metux IT consult" , Thomas Gleixner , Kate Stewart , Andy Shevchenko , , Subject: [PATCH v2 4/6] gpio: dwapb: Use optional-clocks interface for APB ref-clock Date: Mon, 23 Mar 2020 21:06:30 +0300 Message-ID: <20200323180632.14119-5-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20200323180632.14119-1-Sergey.Semin@baikalelectronics.ru> References: <20200306132505.8D3B88030795@mail.baikalelectronics.ru> <20200323180632.14119-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Serge Semin 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 Reviewed-by: Linus Walleij Cc: Alexey Malahov Cc: Thomas Bogendoerfer Cc: Paul Burton Cc: Ralf Baechle --- 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++) {