From patchwork Mon Jun 20 17:48:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 70472 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1629353qgy; Mon, 20 Jun 2016 10:57:29 -0700 (PDT) X-Received: by 10.98.52.65 with SMTP id b62mr23225004pfa.40.1466445437305; Mon, 20 Jun 2016 10:57:17 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p190si34459784pfp.130.2016.06.20.10.57.17; Mon, 20 Jun 2016 10:57:17 -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 S1754272AbcFTR4x (ORCPT + 30 others); Mon, 20 Jun 2016 13:56:53 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:35373 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754743AbcFTR4X (ORCPT ); Mon, 20 Jun 2016 13:56:23 -0400 Received: by mail-wm0-f48.google.com with SMTP id v199so78976826wmv.0 for ; Mon, 20 Jun 2016 10:56:16 -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=sJMkObu0lxfy/5CP9gQBmqj0Vdz447KIZK5UNafP8TQ=; b=HyVjyBiixEL5sdkmRtvIsSpF0MnCpxNgwTlhSmFFQy0HwQoeZmWKXGZaXMwuWY/Wom zrT1gcE+hPLaLuBgqaEoNZljCtUjpYvr+VfXktt/MD81DcWY3cQ8vylJ1SfQrlfNsXyw pFRe3k25nwIi7H1sBBKcu2owE2JUPgU+yhAuQ= 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=sJMkObu0lxfy/5CP9gQBmqj0Vdz447KIZK5UNafP8TQ=; b=YuxtPyyIL8q/MMuJ8IshMVhaQVYm8RTbINQ7n6Pqy3DfM8uVsgnaWOdt2zJRlWwKrn kV1gzQcnJ4ON/dQTUaRR2sU7G0iVe1UPpjPAQNd1l5jKTEB0StWj9eGechmBhhcxtPpU ersPt7Y3vt5ZXbfGCytdFykgQ8NtxX5pCHp6CnHAAwzgWRx6Xv+Vm3+UO66CrAK4jdjx IwrIuDpPP7UFxIDsZaRyRtPIJQlOodjIUTZDNmhDQWSjrhLNJUBGAJqWzr9CFqYZ7u+t RzzTGRRDOoZ87nZOipOowV/NLA5ekqlEFqtC/MlDAae+/Ya5PtYrOmZL4Vyb7yqyJLU/ u8rQ== X-Gm-Message-State: ALyK8tJZyh6AWp1ZBFRHfC0TlR3GQg+WmKjicigxZlDFxfViYNak2oKQnh3zDelRd0bfFeYi X-Received: by 10.194.236.195 with SMTP id uw3mr18273676wjc.149.1466444907958; Mon, 20 Jun 2016 10:48:27 -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 e5sm64685111wjj.10.2016.06.20.10.48.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Jun 2016 10:48:27 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de, ray.jui@broadcom.com Cc: linux-kernel@vger.kernel.org, f.fainelli@gmail.com, sbranden@broadcom.com, bcm-kernel-feedback-list@broadcom.com Subject: [PATCH V3] clocksource/drivers/bcm_kona: Convert init function to return error Date: Mon, 20 Jun 2016 19:48:00 +0200 Message-Id: <1466444880-16355-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <707bd49d-5aea-485f-4efc-6d1d5e8d7506@broadcom.com> References: <707bd49d-5aea-485f-4efc-6d1d5e8d7506@broadcom.com> 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/bcm_kona_timer.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/bcm_kona_timer.c b/drivers/clocksource/bcm_kona_timer.c index e717e87..c251aa6 100644 --- a/drivers/clocksource/bcm_kona_timer.c +++ b/drivers/clocksource/bcm_kona_timer.c @@ -163,16 +163,11 @@ static struct irqaction kona_timer_irq = { .handler = kona_timer_interrupt, }; -static void __init kona_timer_init(struct device_node *node) +static int __init kona_timer_init(struct device_node *node) { u32 freq; struct clk *external_clk; - if (!of_device_is_available(node)) { - pr_info("Kona Timer v1 marked as disabled in device tree\n"); - return; - } - external_clk = of_clk_get_by_name(node, NULL); if (!IS_ERR(external_clk)) { @@ -182,7 +177,7 @@ static void __init kona_timer_init(struct device_node *node) arch_timer_rate = freq; } else { pr_err("Kona Timer v1 unable to determine clock-frequency"); - return; + return -EINVAL; } /* Setup IRQ numbers */ @@ -196,11 +191,13 @@ static void __init kona_timer_init(struct device_node *node) kona_timer_clockevents_init(); setup_irq(timers.tmr_irq, &kona_timer_irq); kona_timer_set_next_event((arch_timer_rate / HZ), NULL); + + return 0; } -CLOCKSOURCE_OF_DECLARE(brcm_kona, "brcm,kona-timer", kona_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(brcm_kona, "brcm,kona-timer", kona_timer_init); /* * bcm,kona-timer is deprecated by brcm,kona-timer * being kept here for driver compatibility */ -CLOCKSOURCE_OF_DECLARE(bcm_kona, "bcm,kona-timer", kona_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(bcm_kona, "bcm,kona-timer", kona_timer_init);