From patchwork Tue Jun 28 10:30:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 70994 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1509472qgy; Tue, 28 Jun 2016 03:33:58 -0700 (PDT) X-Received: by 10.98.0.83 with SMTP id 80mr593541pfa.0.1467110036836; Tue, 28 Jun 2016 03:33:56 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 6si33071643pfe.203.2016.06.28.03.33.56; Tue, 28 Jun 2016 03:33:56 -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 S1752845AbcF1Kdt (ORCPT + 30 others); Tue, 28 Jun 2016 06:33:49 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:35758 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752728AbcF1Kdd (ORCPT ); Tue, 28 Jun 2016 06:33:33 -0400 Received: by mail-wm0-f48.google.com with SMTP id v199so133591690wmv.0 for ; Tue, 28 Jun 2016 03:33:21 -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=IEdNEermTknWlILe9HyCgUCN1zjJRmOqk6PJk6kdIZw=; b=BzTgeugFFMTlGzozj6btQ4jUphvfZmjqWpDhTXhxSyE0dwqfKNdwhJ2f3qkDiglk5x yUJtiN8UK1eHw8KfwKnyfuqC+Ra4B8WeMCccKKhgxlPSJysB8QzppY4/m0qZdVZPsAA8 3xTDCT1bBadcIGyrt4NmuO5kHghLc8paKI88Q= 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=IEdNEermTknWlILe9HyCgUCN1zjJRmOqk6PJk6kdIZw=; b=hOd9QZGHQUTgOsToO0asusSygnVQVakEfWxAC0NOnq+BPVFYEnVT0whEDUNQZchbpq QV5lMJ7TmVTrIWgTP+uCESgieh94LxqZlgzLZhLrh9ofilDlm11WN74gDDLOLX3+z2YI bmxWj1TX6CLx1Ie61Ju3eiOXiyuU6yHG2sTeOV0FrzG9F//mJdRiLrYRgrfKbWO2kvGN dJrMWucyYQEGxyWfIFxbxNHabozYzdRAdQsyN2ayTN3/8xIqMVMQpHOZYGPrA1pc86AI Tt6WM8nsae43K7d3Yoy2XmpX9Z0L908bVv22X3EiWBuKHrXLnjXyoNoRTfy3fAVMGCHm KFfg== X-Gm-Message-State: ALyK8tIHZ+63RXwvOP+YUvLK8+13fv2LNEiZmdonyklUBK8vMBsGNSaOrk3ZmDG2YzbL42sd X-Received: by 10.194.115.130 with SMTP id jo2mr2634101wjb.82.1467110000792; Tue, 28 Jun 2016 03:33:20 -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.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 03:33:20 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Eric Anholt , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 23/92] clocksource/drivers/bcm2835_timer: Convert init function to return error Date: Tue, 28 Jun 2016 12:30:42 +0200 Message-Id: <1467109911-11060-23-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 Acked-by: Eric Anholt --- drivers/clocksource/bcm2835_timer.c | 40 +++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 13 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/bcm2835_timer.c b/drivers/clocksource/bcm2835_timer.c index 6f28229..2dcf896 100644 --- a/drivers/clocksource/bcm2835_timer.c +++ b/drivers/clocksource/bcm2835_timer.c @@ -80,19 +80,24 @@ static irqreturn_t bcm2835_time_interrupt(int irq, void *dev_id) } } -static void __init bcm2835_timer_init(struct device_node *node) +static int __init bcm2835_timer_init(struct device_node *node) { void __iomem *base; u32 freq; - int irq; + int irq, ret; struct bcm2835_timer *timer; base = of_iomap(node, 0); - if (!base) - panic("Can't remap registers"); + if (!base) { + pr_err("Can't remap registers"); + return -ENXIO; + } - if (of_property_read_u32(node, "clock-frequency", &freq)) - panic("Can't read clock-frequency"); + ret = of_property_read_u32(node, "clock-frequency", &freq); + if (ret) { + pr_err("Can't read clock-frequency"); + return ret; + } system_clock = base + REG_COUNTER_LO; sched_clock_register(bcm2835_sched_read, 32, freq); @@ -101,12 +106,16 @@ static void __init bcm2835_timer_init(struct device_node *node) freq, 300, 32, clocksource_mmio_readl_up); irq = irq_of_parse_and_map(node, DEFAULT_TIMER); - if (irq <= 0) - panic("Can't parse IRQ"); + if (irq <= 0) { + pr_err("Can't parse IRQ"); + return -EINVAL; + } timer = kzalloc(sizeof(*timer), GFP_KERNEL); - if (!timer) - panic("Can't allocate timer struct\n"); + if (!timer) { + pr_err("Can't allocate timer struct\n"); + return -ENOMEM; + } timer->control = base + REG_CONTROL; timer->compare = base + REG_COMPARE(DEFAULT_TIMER); @@ -121,12 +130,17 @@ static void __init bcm2835_timer_init(struct device_node *node) timer->act.dev_id = timer; timer->act.handler = bcm2835_time_interrupt; - if (setup_irq(irq, &timer->act)) - panic("Can't set up timer IRQ\n"); + ret = setup_irq(irq, &timer->act); + if (ret) { + pr_err("Can't set up timer IRQ\n"); + return ret; + } clockevents_config_and_register(&timer->evt, freq, 0xf, 0xffffffff); pr_info("bcm2835: system timer (irq = %d)\n", irq); + + return 0; } -CLOCKSOURCE_OF_DECLARE(bcm2835, "brcm,bcm2835-system-timer", +CLOCKSOURCE_OF_DECLARE_RET(bcm2835, "brcm,bcm2835-system-timer", bcm2835_timer_init);