From patchwork Thu Jun 16 21:26:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 70251 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp466996qgy; Thu, 16 Jun 2016 14:36:05 -0700 (PDT) X-Received: by 10.36.26.134 with SMTP id 128mr30056703iti.28.1466112965310; Thu, 16 Jun 2016 14:36:05 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v1si39442820pab.217.2016.06.16.14.36.05; Thu, 16 Jun 2016 14:36:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755355AbcFPVgB (ORCPT + 30 others); Thu, 16 Jun 2016 17:36:01 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:35999 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754846AbcFPV2y (ORCPT ); Thu, 16 Jun 2016 17:28:54 -0400 Received: by mail-wm0-f49.google.com with SMTP id f126so66413330wma.1 for ; Thu, 16 Jun 2016 14:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/cybx4wub3wqDU+Rnrn5cJMxnazLhs/1b0m5LZUP2a0=; b=CWIZVQnCmrAieUt0xX0YDermQjjI5Lj8fWswrGGgSpe4hgRcoxqW1ITqNWez5pTRsv Eq7kmWwR/7hbJCuqV1jvumDdgXhTedaCmJdMLr6Ov6W81d/fViN6cLqiuzd6KTQ2ITPE TLXbozyKJ8wEkMpjTjxDpBCE5OqyA+jCtJH9s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/cybx4wub3wqDU+Rnrn5cJMxnazLhs/1b0m5LZUP2a0=; b=kAHbyVI7WnpXk/HIhbt9JHUE/gdXgaF6YAEXiInIxfF8KES26oVUH3FFJMcLXZmho8 4w+Gd0ELYsKML2lwNptlZRSEUNsUq5F8g0XedWKB1YjBvXYzl8OgM994FCgjeerH8vWG 5czwvMStZ1A/Y8zjPzxqKCFeWfu5VFdY0Fj18kSZpNHjOJarC/D5jh3ltT9VO4NU0G7T tbdz08wOm+tqX1BwWtxyebEplcehjZCIh07gbZmHSpfDsVv/zmMwDB6gisbRdZpKk2Db SY9/Ej1zv0NI6SN/Hgr3GMrT2U1cxnSIEJfEKBRUfJYsDAhStFvIgHMa2cs4l8d02oYN yGUA== X-Gm-Message-State: ALyK8tLWiG/5t8WNPG1EXpjmKJ1RA0e9ret+iPtO7WHuZAodkQXrUkKXGWR91yNPjfB9Tz2V X-Received: by 10.194.34.202 with SMTP id b10mr1539903wjj.47.1466112532858; Thu, 16 Jun 2016 14:28:52 -0700 (PDT) Received: from localhost.localdomain (sju31-1-78-210-255-2.fbx.proxad.net. [78.210.255.2]) by smtp.gmail.com with ESMTPSA id x128sm16705606wmf.6.2016.06.16.14.28.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jun 2016 14:28:52 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH V2 38/63] clocksource/drivers/time-pistachio: Convert init function to return error Date: Thu, 16 Jun 2016 23:26:57 +0200 Message-Id: <1466112442-31105-39-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466112442-31105-1-git-send-email-daniel.lezcano@linaro.org> References: <1466112442-31105-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The init functions do not return any error. They behave as the following: - panic, thus leading to a kernel crash while another timer may work and make the system boot up correctly or - print an error and let the caller unaware if the state of the system Change that by converting the init functions to return an error conforming to the CLOCKSOURCE_OF_RET prototype. Proper error handling (rollback, errno value) will be changed later case by case, thus this change just return back an error or success in the init function. Signed-off-by: Daniel Lezcano --- drivers/clocksource/time-pistachio.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/time-pistachio.c b/drivers/clocksource/time-pistachio.c index 376e59b..adaaec5 100644 --- a/drivers/clocksource/time-pistachio.c +++ b/drivers/clocksource/time-pistachio.c @@ -148,7 +148,7 @@ static struct pistachio_clocksource pcs_gpt = { }, }; -static void __init pistachio_clksrc_of_init(struct device_node *node) +static int __init pistachio_clksrc_of_init(struct device_node *node) { struct clk *sys_clk, *fast_clk; struct regmap *periph_regs; @@ -158,45 +158,45 @@ static void __init pistachio_clksrc_of_init(struct device_node *node) pcs_gpt.base = of_iomap(node, 0); if (!pcs_gpt.base) { pr_err("cannot iomap\n"); - return; + return -ENXIO; } periph_regs = syscon_regmap_lookup_by_phandle(node, "img,cr-periph"); if (IS_ERR(periph_regs)) { pr_err("cannot get peripheral regmap (%ld)\n", PTR_ERR(periph_regs)); - return; + return PTR_ERR(periph_regs); } /* Switch to using the fast counter clock */ ret = regmap_update_bits(periph_regs, PERIP_TIMER_CONTROL, 0xf, 0x0); if (ret) - return; + return ret; sys_clk = of_clk_get_by_name(node, "sys"); if (IS_ERR(sys_clk)) { pr_err("clock get failed (%ld)\n", PTR_ERR(sys_clk)); - return; + return PTR_ERR(sys_clk); } fast_clk = of_clk_get_by_name(node, "fast"); if (IS_ERR(fast_clk)) { pr_err("clock get failed (%lu)\n", PTR_ERR(fast_clk)); - return; + return PTR_ERR(fast_clk); } ret = clk_prepare_enable(sys_clk); if (ret < 0) { pr_err("failed to enable clock (%d)\n", ret); - return; + return ret; } ret = clk_prepare_enable(fast_clk); if (ret < 0) { pr_err("failed to enable clock (%d)\n", ret); clk_disable_unprepare(sys_clk); - return; + return ret; } rate = clk_get_rate(fast_clk); @@ -212,7 +212,7 @@ static void __init pistachio_clksrc_of_init(struct device_node *node) raw_spin_lock_init(&pcs_gpt.lock); sched_clock_register(pistachio_read_sched_clock, 32, rate); - clocksource_register_hz(&pcs_gpt.cs, rate); + return clocksource_register_hz(&pcs_gpt.cs, rate); } -CLOCKSOURCE_OF_DECLARE(pistachio_gptimer, "img,pistachio-gptimer", +CLOCKSOURCE_OF_DECLARE_RET(pistachio_gptimer, "img,pistachio-gptimer", pistachio_clksrc_of_init);