From patchwork Fri Dec 4 15:33:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 7769351 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 26C68BEEE1 for ; Fri, 4 Dec 2015 15:34:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 408D3205BB for ; Fri, 4 Dec 2015 15:34:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F8F620588 for ; Fri, 4 Dec 2015 15:34:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755165AbbLDPd6 (ORCPT ); Fri, 4 Dec 2015 10:33:58 -0500 Received: from xavier.telenet-ops.be ([195.130.132.52]:46807 "EHLO xavier.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755152AbbLDPdz (ORCPT ); Fri, 4 Dec 2015 10:33:55 -0500 Received: from ayla.of.borg ([84.195.106.123]) by xavier.telenet-ops.be with bizsmtp id pTZu1r00A2fm56U01TZulT; Fri, 04 Dec 2015 16:33:54 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1a4sMs-0006Lt-66; Fri, 04 Dec 2015 16:33:54 +0100 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1a4sMt-0002ti-8G; Fri, 04 Dec 2015 16:33:55 +0100 From: Geert Uytterhoeven To: Linus Walleij , Alexandre Courbot Cc: Magnus Damm , linux-gpio@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 2/2] gpio: rcar: Improve clock error handling and reporting Date: Fri, 4 Dec 2015 16:33:53 +0100 Message-Id: <1449243233-11089-3-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449243233-11089-1-git-send-email-geert+renesas@glider.be> References: <1449243233-11089-1-git-send-email-geert+renesas@glider.be> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the Renesas R-Car GPIO driver cannot find a functional clock, it prints a warning, .e.g. gpio_rcar ffc40000.gpio: unable to get clock and continues, as the clock is optional, depending on the SoC type. This warning may confuse users. To fix this, add a flag to indicate that the clock is mandatory or optional: - If the clock is mandatory (on R-Car Gen2 and Gen3), a missing clock is now treated as a fatal error, - If the clock is optional (on R-Car Gen1), the warning is no longer printed. Suggested-by: Magnus Damm Signed-off-by: Geert Uytterhoeven --- v2: - Use booleans instead of bitfields, - Add reference to R-Car Gen3. --- drivers/gpio/gpio-rcar.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index 1ed52fc026cb4dd2..624a435e69889d7e 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -39,6 +39,7 @@ struct gpio_rcar_priv { struct clk *clk; unsigned int irq_parent; bool has_both_edge_trigger; + bool needs_clk; }; #define IOINTSEL 0x00 /* General IO/Interrupt Switching Register */ @@ -317,14 +318,17 @@ static int gpio_rcar_direction_output(struct gpio_chip *chip, unsigned offset, struct gpio_rcar_info { bool has_both_edge_trigger; + bool needs_clk; }; static const struct gpio_rcar_info gpio_rcar_info_gen1 = { .has_both_edge_trigger = false, + .needs_clk = false, }; static const struct gpio_rcar_info gpio_rcar_info_gen2 = { .has_both_edge_trigger = true, + .needs_clk = true, }; static const struct of_device_id gpio_rcar_of_table[] = { @@ -371,6 +375,7 @@ static int gpio_rcar_parse_dt(struct gpio_rcar_priv *p, unsigned int *npins) ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, &args); *npins = ret == 0 ? args.args[2] : RCAR_MAX_GPIO_PER_BANK; p->has_both_edge_trigger = info->has_both_edge_trigger; + p->needs_clk = info->needs_clk; if (*npins == 0 || *npins > RCAR_MAX_GPIO_PER_BANK) { dev_warn(&p->pdev->dev, @@ -409,7 +414,11 @@ static int gpio_rcar_probe(struct platform_device *pdev) p->clk = devm_clk_get(dev, NULL); if (IS_ERR(p->clk)) { - dev_warn(dev, "unable to get clock\n"); + if (p->needs_clk) { + dev_err(dev, "unable to get clock\n"); + ret = PTR_ERR(p->clk); + goto err0; + } p->clk = NULL; }