From patchwork Tue Jun 28 10:31:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71033 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1512855qgy; Tue, 28 Jun 2016 03:42:45 -0700 (PDT) X-Received: by 10.98.82.68 with SMTP id g65mr521011pfb.157.1467110565654; Tue, 28 Jun 2016 03:42:45 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11si33132268pfi.178.2016.06.28.03.42.45; Tue, 28 Jun 2016 03:42:45 -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 S1753120AbcF1Kmk (ORCPT + 30 others); Tue, 28 Jun 2016 06:42:40 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:35967 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752233AbcF1KeB (ORCPT ); Tue, 28 Jun 2016 06:34:01 -0400 Received: by mail-wm0-f50.google.com with SMTP id f126so133920006wma.1 for ; Tue, 28 Jun 2016 03:33:55 -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=Wo77IvZsqOC9x0mJeO4w94t2OztI97Xdd1CXfjPoWxo=; b=WrkjkaBfaAtP2Of8DO5UIBcmJk1Zs2NTjS/4WzzciZFTo4Hi4XzxYM4ruXDgmA/wAK CUOkMQfis0UyNgp1vwglXDdNDOOW/URB9O3fsvooEL4/ug8Xk+A/r6qvXG6YSJqAqw3q kZ78znyP71r460brHymcRyEr2j2fywupSWoWY= 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=Wo77IvZsqOC9x0mJeO4w94t2OztI97Xdd1CXfjPoWxo=; b=cADm0ve9jUOuLmaeEyiECwm22zMgOYXrWf29jLunGBYistY4lbaNGjc2CCo0/KG4Xk RW8hH6O8gHRcskBye8F9AeHipawKgmzY7xk2e4psNawKi1BlnLFqCjaP/iNfUeMnRo1K puuD+UM8jNGHcxSEhZ2nlc6+eKRWhVIrmMGFxTc0LEFRC5SDhhWdxyu6CC4JuFbPHQ4/ VzT1GqjI0smo2opevdB3Ymow5jEJN0Cym/ly++SZzn0iJpJ8DuABx3qDIOqWx6iHl86w E0hFg3HGL4yul1QvVT9XzJj9VQWUFzzx9iMimKfl40uxJZE2IY+NYH0MMUUvn3bhi1bd VjAw== X-Gm-Message-State: ALyK8tJzyC+2+a7mvzO7pOAQiqT9xMTySlcfIAaJRDLQJbATO6Fu6ON9vIxu7CE2IVmQdgtd X-Received: by 10.28.181.80 with SMTP id e77mr15907362wmf.24.1467110034690; Tue, 28 Jun 2016 03:33:54 -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.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 03:33:54 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH 47/92] clocksource/drivers/orion: Convert init function to return error Date: Tue, 28 Jun 2016 12:31:06 +0200 Message-Id: <1467109911-11060-47-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/time-orion.c | 52 ++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 15 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/time-orion.c b/drivers/clocksource/time-orion.c index 0ece742..5fdeb5d 100644 --- a/drivers/clocksource/time-orion.c +++ b/drivers/clocksource/time-orion.c @@ -104,25 +104,36 @@ static struct irqaction orion_clkevt_irq = { .handler = orion_clkevt_irq_handler, }; -static void __init orion_timer_init(struct device_node *np) +static int __init orion_timer_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)) - panic("%s: unable to get clk\n", np->name); - clk_prepare_enable(clk); + if (IS_ERR(clk)) { + pr_err("%s: unable to get clk\n", np->name); + return PTR_ERR(clk); + } + + ret = clk_prepare_enable(clk); + if (ret) { + pr_err("Failed to prepare clock"); + return ret; + } /* we are only interested in timer1 irq */ irq = irq_of_parse_and_map(np, 1); - if (irq <= 0) - panic("%s: unable to parse timer1 irq\n", np->name); + if (irq <= 0) { + pr_err("%s: unable to parse timer1 irq\n", np->name); + return -EINVAL; + } /* setup timer0 as free-running clocksource */ writel(~0, timer_base + TIMER0_VAL); @@ -130,19 +141,30 @@ static void __init orion_timer_init(struct device_node *np) atomic_io_modify(timer_base + TIMER_CTRL, TIMER0_RELOAD_EN | TIMER0_EN, TIMER0_RELOAD_EN | TIMER0_EN); - clocksource_mmio_init(timer_base + TIMER0_VAL, "orion_clocksource", - clk_get_rate(clk), 300, 32, - clocksource_mmio_readl_down); + + ret = clocksource_mmio_init(timer_base + TIMER0_VAL, "orion_clocksource", + clk_get_rate(clk), 300, 32, + clocksource_mmio_readl_down); + if (ret) { + pr_err("Failed to initialize mmio timer"); + return ret; + } + sched_clock_register(orion_read_sched_clock, 32, clk_get_rate(clk)); /* setup timer1 as clockevent timer */ - if (setup_irq(irq, &orion_clkevt_irq)) - panic("%s: unable to setup irq\n", np->name); + ret = setup_irq(irq, &orion_clkevt_irq); + if (ret) { + pr_err("%s: unable to setup irq\n", np->name); + return ret; + } ticks_per_jiffy = (clk_get_rate(clk) + HZ/2) / HZ; orion_clkevt.cpumask = cpumask_of(0); orion_clkevt.irq = irq; clockevents_config_and_register(&orion_clkevt, clk_get_rate(clk), ORION_ONESHOT_MIN, ORION_ONESHOT_MAX); + + return 0; } -CLOCKSOURCE_OF_DECLARE(orion_timer, "marvell,orion-timer", orion_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(orion_timer, "marvell,orion-timer", orion_timer_init);