From patchwork Tue Jun 28 10:30: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: 71045 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1515799qgy; Tue, 28 Jun 2016 03:51:20 -0700 (PDT) X-Received: by 10.98.96.67 with SMTP id u64mr682101pfb.70.1467111080791; Tue, 28 Jun 2016 03:51:20 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wu1si2275681pab.81.2016.06.28.03.51.20; Tue, 28 Jun 2016 03:51:20 -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 S1753222AbcF1KvR (ORCPT + 30 others); Tue, 28 Jun 2016 06:51:17 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:36798 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752778AbcF1Kdl (ORCPT ); Tue, 28 Jun 2016 06:33:41 -0400 Received: by mail-wm0-f52.google.com with SMTP id f126so133911342wma.1 for ; Tue, 28 Jun 2016 03:33:40 -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=EiW7IjeANlSvXFnJYBGUCDWHuw+YGOuGZX9vQ2IWaNk=; b=XbZRrf7IaDdDZ1YSbP8ySXVziGhRkxIvM4sYWURS2127IxFJsRimeMQaKzFECyDRPc IvoGFPSgAU5yPe3vso8j4o6xb4kIqerWOxuLoQLcXm/Be00XD4cgnlN9p78KUyZUekAF AX7FIRuKVURBzaQl5jUNbH+MuXuFq4gMUJKJk= 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=EiW7IjeANlSvXFnJYBGUCDWHuw+YGOuGZX9vQ2IWaNk=; b=CMCsDZ0wCfNpnw4sX4qJFUhz1VjLn9skuvt2RQEPsbhyABaMZB3aRMIuhlEHN/1+oP OEHc9l//El97n+HoXIkBd4bIegElQIdAeV14ItjIN9sIA/lXfpn823qBf5Qxr5I33g1v TsvBYJm50/pOv3Yv2K8Lq9ZCPBqaMMPn5eQsgBbh7ty8IbgUXbr1O0aDUmK0OQUPliWh SZvWTvBpTpQxUNvMygpooUbIag32kpMY8HZ/DCn9USCKS4o2qHsNQdWhryLWUAnIv1ud F23N9f0zJ0U9sIjP5dj6BsfngadBWu/I4PUYOrDT3S0VYZAcHiw6MFXlf206LLyakkfj nOvA== X-Gm-Message-State: ALyK8tIoTBsZOPs47dABlA9M4dpO5mGQkjPuOLQuaLgf/z7mfzSe9J9a5X5EOz7egDrsZNW/ X-Received: by 10.194.145.244 with SMTP id sx20mr2586996wjb.169.1467110019806; Tue, 28 Jun 2016 03:33:39 -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.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 03:33:39 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH 38/92] clocksource/drivers/pxa: Convert init function to return error Date: Tue, 28 Jun 2016 12:30:57 +0200 Message-Id: <1467109911-11060-38-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/pxa_timer.c | 46 +++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 13 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/pxa_timer.c b/drivers/clocksource/pxa_timer.c index 45b6a49..59af75c 100644 --- a/drivers/clocksource/pxa_timer.c +++ b/drivers/clocksource/pxa_timer.c @@ -150,8 +150,10 @@ static struct irqaction pxa_ost0_irq = { .dev_id = &ckevt_pxa_osmr0, }; -static void __init pxa_timer_common_init(int irq, unsigned long clock_tick_rate) +static int __init pxa_timer_common_init(int irq, unsigned long clock_tick_rate) { + int ret; + timer_writel(0, OIER); timer_writel(OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3, OSSR); @@ -159,41 +161,59 @@ static void __init pxa_timer_common_init(int irq, unsigned long clock_tick_rate) ckevt_pxa_osmr0.cpumask = cpumask_of(0); - setup_irq(irq, &pxa_ost0_irq); + ret = setup_irq(irq, &pxa_ost0_irq); + if (ret) { + pr_err("Failed to setup irq"); + return ret; + } + + ret = clocksource_mmio_init(timer_base + OSCR, "oscr0", clock_tick_rate, 200, + 32, clocksource_mmio_readl_up); + if (ret) { + pr_err("Failed to init clocksource"); + return ret; + } - clocksource_mmio_init(timer_base + OSCR, "oscr0", clock_tick_rate, 200, - 32, clocksource_mmio_readl_up); clockevents_config_and_register(&ckevt_pxa_osmr0, clock_tick_rate, MIN_OSCR_DELTA * 2, 0x7fffffff); + + return 0; } -static void __init pxa_timer_dt_init(struct device_node *np) +static int __init pxa_timer_dt_init(struct device_node *np) { struct clk *clk; - int irq; + int irq, ret; /* timer registers are shared with watchdog timer */ timer_base = of_iomap(np, 0); - if (!timer_base) - panic("%s: unable to map resource\n", np->name); + if (!timer_base) { + pr_err("%s: unable to map resource\n", np->name); + return -ENXIO; + } clk = of_clk_get(np, 0); if (IS_ERR(clk)) { pr_crit("%s: unable to get clk\n", np->name); - return; + return PTR_ERR(clk); + } + + ret = clk_prepare_enable(clk); + if (ret) { + pr_crit("Failed to prepare clock"); + return ret; } - clk_prepare_enable(clk); /* we are only interested in OS-timer0 irq */ irq = irq_of_parse_and_map(np, 0); if (irq <= 0) { pr_crit("%s: unable to parse OS-timer0 irq\n", np->name); - return; + return -EINVAL; } - pxa_timer_common_init(irq, clk_get_rate(clk)); + return pxa_timer_common_init(irq, clk_get_rate(clk)); } -CLOCKSOURCE_OF_DECLARE(pxa_timer, "marvell,pxa-timer", pxa_timer_dt_init); +CLOCKSOURCE_OF_DECLARE_RET(pxa_timer, "marvell,pxa-timer", pxa_timer_dt_init); /* * Legacy timer init for non device-tree boards.