From patchwork Tue Jun 28 10:30:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71048 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1516002qgy; Tue, 28 Jun 2016 03:51:54 -0700 (PDT) X-Received: by 10.66.75.72 with SMTP id a8mr580284paw.99.1467111114616; Tue, 28 Jun 2016 03:51:54 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 62si33120434pff.74.2016.06.28.03.51.54; Tue, 28 Jun 2016 03:51:54 -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 S1753268AbcF1Kvo (ORCPT + 30 others); Tue, 28 Jun 2016 06:51:44 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:36716 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752772AbcF1Kdf (ORCPT ); Tue, 28 Jun 2016 06:33:35 -0400 Received: by mail-wm0-f46.google.com with SMTP id f126so133907705wma.1 for ; Tue, 28 Jun 2016 03:33:34 -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=feP+Ioz4hUAWac2Q/VKG9fE2IuSKQGY40BCy0UibR+s=; b=bstXkZ+jCnXVqMZICmmdgIJMYzfeNyPf4/vi7nbGwo8I4kLoFpnVh74vnaLTUuQzRd NZyYeJYs6rYBgFs5lEB7n0EoKfTEiT0uSnh+zufYL3EvhXEmJ9+KtgQh3y5jbs4YrArq kIDzHyrVA2asB6nsOxhn64gqTAAxo/KUKn8Sw= 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=feP+Ioz4hUAWac2Q/VKG9fE2IuSKQGY40BCy0UibR+s=; b=MKrFsBDWA2Wztsd9Cnhj60Ep91+IP3DM5TmfjpiQi8F13sTjREiIPePt7nbSWljaxw W2kSZxPQn5/tnW5I2oH/9L93S1siKFP/qe9/UQLbtyl5JVklbU53A5/I1PCG/QcLMBGd +9O9G9nOeaIzgCi+5ZJKbCJ5HawEEN4IrJpqs4RtIJ0afc958s2ZbbZW/opV9EtVT5BB DWO38oH63Cy1zMjYN16cFab+PSMPpCq2tq/05imsrRI3dWZgLvb7osd697fBhGMipjSQ TZBRaSoouMQSx4n6mnDDrnAS2+trWngj+sw1LsBjq4bJvPEBFDaDOaeruVV5/lqB2fXp NYYA== X-Gm-Message-State: ALyK8tIyO4Gwfp/k0K3u81MYQlGJZvvZtfUoVGnY3mcDjrFtgtL/jU8GAEv/pYNF4CLSEmIw X-Received: by 10.28.10.196 with SMTP id 187mr2924868wmk.48.1467110013854; Tue, 28 Jun 2016 03:33:33 -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 a84sm5377403wma.0.2016.06.28.03.33.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 03:33:33 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH 33/92] clocksource/drivers/mips-gic-timer: Convert init function to return error Date: Tue, 28 Jun 2016 12:30:52 +0200 Message-Id: <1467109911-11060-33-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467109911-11060-1-git-send-email-daniel.lezcano@linaro.org> References: <577251A4.7030508@linaro.org> <1467109911-11060-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/mips-gic-timer.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/mips-gic-timer.c b/drivers/clocksource/mips-gic-timer.c index 89d3e4d..b164b87 100644 --- a/drivers/clocksource/mips-gic-timer.c +++ b/drivers/clocksource/mips-gic-timer.c @@ -146,7 +146,7 @@ static struct clocksource gic_clocksource = { .archdata = { .vdso_clock_mode = VDSO_CLOCK_GIC }, }; -static void __init __gic_clocksource_init(void) +static int __init __gic_clocksource_init(void) { int ret; @@ -159,6 +159,8 @@ static void __init __gic_clocksource_init(void) ret = clocksource_register_hz(&gic_clocksource, gic_frequency); if (ret < 0) pr_warn("GIC: Unable to register clocksource\n"); + + return ret; } void __init gic_clocksource_init(unsigned int frequency) @@ -179,31 +181,35 @@ static void __init gic_clocksource_of_init(struct device_node *node) struct clk *clk; int ret; - if (WARN_ON(!gic_present || !node->parent || - !of_device_is_compatible(node->parent, "mti,gic"))) - return; + if (!gic_present || !node->parent || + !of_device_is_compatible(node->parent, "mti,gic")) { + pr_warn("No DT definition for the mips gic driver"); + return -ENXIO; + } clk = of_clk_get(node, 0); if (!IS_ERR(clk)) { if (clk_prepare_enable(clk) < 0) { pr_err("GIC failed to enable clock\n"); clk_put(clk); - return; + return PTR_ERR(clk); } gic_frequency = clk_get_rate(clk); } else if (of_property_read_u32(node, "clock-frequency", &gic_frequency)) { pr_err("GIC frequency not specified.\n"); - return; + return -EINVAL;; } gic_timer_irq = irq_of_parse_and_map(node, 0); if (!gic_timer_irq) { pr_err("GIC timer IRQ not specified.\n"); - return; + return -EINVAL;; } - __gic_clocksource_init(); + ret = __gic_clocksource_init(); + if (ret) + return ret; ret = gic_clockevent_init(); if (!ret && !IS_ERR(clk)) { @@ -213,6 +219,8 @@ static void __init gic_clocksource_of_init(struct device_node *node) /* And finally start the counter */ gic_start_count(); + + return 0; } -CLOCKSOURCE_OF_DECLARE(mips_gic_timer, "mti,gic-timer", +CLOCKSOURCE_OF_DECLARE_RET(mips_gic_timer, "mti,gic-timer", gic_clocksource_of_init);