From patchwork Thu Jun 16 21:27:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 70225 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp464885qgy; Thu, 16 Jun 2016 14:29:57 -0700 (PDT) X-Received: by 10.98.110.73 with SMTP id j70mr7568142pfc.101.1466112591637; Thu, 16 Jun 2016 14:29:51 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n188si7982154pfn.2.2016.06.16.14.29.51; Thu, 16 Jun 2016 14:29:51 -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 S1755377AbcFPV33 (ORCPT + 30 others); Thu, 16 Jun 2016 17:29:29 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:35356 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933241AbcFPV3L (ORCPT ); Thu, 16 Jun 2016 17:29:11 -0400 Received: by mail-wm0-f49.google.com with SMTP id v199so207666756wmv.0 for ; Thu, 16 Jun 2016 14:29:10 -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=OnWcHeeSVyMB87DXTjOO6VTWh+9sO/+5GEJgL0q402E=; b=jVlHc09ez8AIOjD8ViOvWDUwfrO2T14yW7tS1EyI8uj1ASpfTgpzg/hi3SxOa3srBr 4A8gkV4O8QZyeLjC82QOoYWlOr3yBOjRI4+21R4x/k974Vl98ZwWqDSo8zpMN4lW8GE7 irda03m7dDts/tLRhRzNUcVUCkM6SDMQaiaj4= 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=OnWcHeeSVyMB87DXTjOO6VTWh+9sO/+5GEJgL0q402E=; b=d8l5WEYxqlZZ5qtcKscpxdX+cK8cyeT2pPFXyZxG3Z7/qUk9h9PDz4u79JuE/ZPrt+ ueGK8imZhPoj5GwGBY5aFA45kMb3emBYsKoinUOOZmdmnhmG2qwOrUdxZQs3oOlkqdHJ kKfEwZOVKOtljpDb2019Az9vorPn357iSo3cmAVJl9/fD7OjxHeYTpR1m/Pdx9eSRunB CZYq/uzXrYxIV/JzBvxqkjNb0nzPPgHdTfqc7Rh+wG39zKq8ecgu6nnMNQ/HQkNIk9N3 uYzGtgE1hNB5yWZM1spB1M7tiQbf/C/w8c8czL7IyS8+QI42CmBNljzpc35tWikvTM4C nCMw== X-Gm-Message-State: ALyK8tLO3Bl3d8g4YibhQYFzwPhqpOVfEEzbuKZyEEe8w1mUYhpQDo3hN5yxhEycit8rRdrE X-Received: by 10.194.134.164 with SMTP id pl4mr1636139wjb.113.1466112549989; Thu, 16 Jun 2016 14:29:09 -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.29.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jun 2016 14:29:09 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Linus Walleij , linux-arm-kernel@lists.infradead.org (moderated list:ARM/U300 MACHINE...) Subject: [PATCH V2 50/63] clocksource/drivers/timer-u300: Convert init function to return error Date: Thu, 16 Jun 2016 23:27:09 +0200 Message-Id: <1466112442-31105-51-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/timer-u300.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) -- 1.9.1 Acked-by: Linus Walleij diff --git a/drivers/clocksource/timer-u300.c b/drivers/clocksource/timer-u300.c index 1744b24..a6a0dec 100644 --- a/drivers/clocksource/timer-u300.c +++ b/drivers/clocksource/timer-u300.c @@ -359,27 +359,37 @@ static struct delay_timer u300_delay_timer; /* * This sets up the system timers, clock source and clock event. */ -static void __init u300_timer_init_of(struct device_node *np) +static int __init u300_timer_init_of(struct device_node *np) { unsigned int irq; struct clk *clk; unsigned long rate; + int ret; u300_timer_base = of_iomap(np, 0); - if (!u300_timer_base) - panic("could not ioremap system timer\n"); + if (!u300_timer_base) { + pr_err("could not ioremap system timer\n"); + return -ENXIO; + } /* Get the IRQ for the GP1 timer */ irq = irq_of_parse_and_map(np, 2); - if (!irq) - panic("no IRQ for system timer\n"); + if (!irq) { + pr_err("no IRQ for system timer\n"); + return -EINVAL; + } pr_info("U300 GP1 timer @ base: %p, IRQ: %u\n", u300_timer_base, irq); /* Clock the interrupt controller */ clk = of_clk_get(np, 0); - BUG_ON(IS_ERR(clk)); - clk_prepare_enable(clk); + if (IS_ERR(clk)) + return PTR_ERR(clk); + + ret = clk_prepare_enable(clk); + if (ret) + return ret; + rate = clk_get_rate(clk); u300_clockevent_data.ticks_per_jiffy = DIV_ROUND_CLOSEST(rate, HZ); @@ -410,7 +420,9 @@ static void __init u300_timer_init_of(struct device_node *np) u300_timer_base + U300_TIMER_APP_RGPT1); /* Set up the IRQ handler */ - setup_irq(irq, &u300_timer_irq); + ret = setup_irq(irq, &u300_timer_irq); + if (ret) + return ret; /* Reset the General Purpose timer 2 */ writel(U300_TIMER_APP_RGPT2_TIMER_RESET, @@ -428,9 +440,12 @@ static void __init u300_timer_init_of(struct device_node *np) u300_timer_base + U300_TIMER_APP_EGPT2); /* Use general purpose timer 2 as clock source */ - if (clocksource_mmio_init(u300_timer_base + U300_TIMER_APP_GPT2CC, - "GPT2", rate, 300, 32, clocksource_mmio_readl_up)) + ret = clocksource_mmio_init(u300_timer_base + U300_TIMER_APP_GPT2CC, + "GPT2", rate, 300, 32, clocksource_mmio_readl_up); + if (ret) { pr_err("timer: failed to initialize U300 clock source\n"); + return ret; + } /* Configure and register the clockevent */ clockevents_config_and_register(&u300_clockevent_data.cevd, rate, @@ -440,7 +455,8 @@ static void __init u300_timer_init_of(struct device_node *np) * TODO: init and register the rest of the timers too, they can be * used by hrtimers! */ + return 0; } -CLOCKSOURCE_OF_DECLARE(u300_timer, "stericsson,u300-apptimer", +CLOCKSOURCE_OF_DECLARE_RET(u300_timer, "stericsson,u300-apptimer", u300_timer_init_of);