From patchwork Thu Jun 16 21:26:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 70232 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp465214qgy; Thu, 16 Jun 2016 14:30:53 -0700 (PDT) X-Received: by 10.67.5.73 with SMTP id ck9mr7348114pad.127.1466112653407; Thu, 16 Jun 2016 14:30:53 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id e190si7962964pfe.193.2016.06.16.14.30.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jun 2016 14:30:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bDerC-0004BA-Hf; Thu, 16 Jun 2016 21:29:46 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bDeqC-0003CN-1q for linux-arm-kernel@bombadil.infradead.org; Thu, 16 Jun 2016 21:28:44 +0000 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]) by merlin.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bDeqA-0005Be-Ea for linux-arm-kernel@lists.infradead.org; Thu, 16 Jun 2016 21:28:43 +0000 Received: by mail-wm0-x236.google.com with SMTP id f126so66400373wma.1 for ; Thu, 16 Jun 2016 14:28: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=gK1aUKL2wLgjvzLgSA49HBy5+xH+pUt0j1retEbfY9c=; b=ZH2p00FLTh73OZcJKg6g7ax34CEZSwZ71QVX+gG27clspNIAbtU17RzNnclT4OSxob SmpDRST1f8lOYUrQphUmqWco66tiQ/dT0ukgTDW1uFSlBrwaoNjNOUPI/8D9J64Shwtj CacdHioYf1GvMeDKzj8jimXOnYjXXYLuoyvtM= 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=gK1aUKL2wLgjvzLgSA49HBy5+xH+pUt0j1retEbfY9c=; b=XRARSHGTYKnCc/k4sPtBWdIms7vPPgDKeWEvz1d+GgWhzp5je733KpNElm08QojW9L //xBQg/gw4CDzN9IQKGLylj+TLbW36TnkYc16hzaTKVFfCZsZD1DZWQuLLucC/yv1pBu 2PHmyTlc+KUnEPJfo5xpLAVjucJcFUEsjC8eVAZSreHi0H8PyUUPbqBxo9e1nnUPwCqR lgSsK3d3Hzv1YUPSyArxibyFab6SZZiq3TKO3TsGz1RNiaLiWSNxeS9xvkJgrKihcicW aab5HJmUixUiSO1gm+WqbAVWyK6BijrrV9OWKNd7VZtcCMmZjWMA6X/va9Ta1Qk39XjE jNQg== X-Gm-Message-State: ALyK8tINXuvaWuU1UyeecuihZg7VWwFcvoSCbU+Z8Q/GJ3lP6nljFTficXqp4Jy7sJnTwbGe X-Received: by 10.194.34.202 with SMTP id b10mr1538467wjj.47.1466112499626; Thu, 16 Jun 2016 14:28:19 -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.28.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jun 2016 14:28:19 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Subject: [PATCH V2 13/63] clocksource/drivers/bcm2835_timer: Convert init function to return error Date: Thu, 16 Jun 2016 23:26:32 +0200 Message-Id: <1466112442-31105-14-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160616_172842_649889_5C14E260 X-CRM114-Status: GOOD ( 17.11 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:236 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephen Warren , Lee Jones , linux-kernel@vger.kernel.org, Eric Anholt , "moderated list:BROADCOM BCM2835..." , "moderated list:BROADCOM BCM2835..." MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.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/bcm2835_timer.c | 40 +++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 13 deletions(-) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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);