From patchwork Tue Jun 28 10:30:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 70992 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1509450qgy; Tue, 28 Jun 2016 03:33:55 -0700 (PDT) X-Received: by 10.98.0.83 with SMTP id 80mr593370pfa.0.1467110035198; Tue, 28 Jun 2016 03:33:55 -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.54; Tue, 28 Jun 2016 03:33:55 -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 S1752238AbcF1Kdo (ORCPT + 30 others); Tue, 28 Jun 2016 06:33:44 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:34097 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752737AbcF1Kdd (ORCPT ); Tue, 28 Jun 2016 06:33:33 -0400 Received: by mail-wm0-f41.google.com with SMTP id 187so26443075wmz.1 for ; Tue, 28 Jun 2016 03:33:26 -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=LuFStehQ0TIp8AFIrmwXuOENENGgDvOaqibnGw4RkyE=; b=MIx7E3Zf/osTncjzSA0+ZgDk6nRrC1Eo9TOSOPumCIJR9sd4XoYMFWh0aCZtpOmpKW UnsN6V1i3brkH8zJY25zcT5LIhoji26DB7nyoD8WtCBxjVe/NugEJ/yzWOy+418KS8yC mqCwL51f0vkl1vp2O25UQV0x7VCMOMdDF8yt8= 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=LuFStehQ0TIp8AFIrmwXuOENENGgDvOaqibnGw4RkyE=; b=jIFqngAGflU7SWXmfZm5a/NP7kplGMJCyOHIpfVzR4bGj0kR2WCDzP1fQqakHNSJEe AaBl2VWKK8Z3JVH/PnPiSCqrkvOEahoyjnWt66WBj8Fbh48ENkuuL6EixNDAn8ZJSOY6 dYs8ZMoTNetUYAmpmQAxmEorowHzxXdE0qWHV3Tji5J5M/ZTzOBCE4fdt1Au9o8idmaT +LJhH0Y4ije5N5bZ/+QxtPqqCQGJmvNuKfaGlsXWw1D3qSbonT/Koirmvmtp2+tMJjtq KjPLyYDgSwJha2++dNzLwnNib26+NgytdlmeRA/kHLeS780KpdUHCUQjwkksKBD32AYu +Tig== X-Gm-Message-State: ALyK8tKw5as/XsbnxExLzTWfUOIFGLYpY6GFBLgBnKNNtEdrQvYqtO1uiSBpLx/L+coHI/t+ X-Received: by 10.194.145.244 with SMTP id sx20mr2585687wjb.169.1467110005173; Tue, 28 Jun 2016 03:33:25 -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.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 03:33:24 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH 26/92] clocksource/drivers/fsl_ftm_timer: Convert init function to return error Date: Tue, 28 Jun 2016 12:30:45 +0200 Message-Id: <1467109911-11060-26-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/fsl_ftm_timer.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/fsl_ftm_timer.c b/drivers/clocksource/fsl_ftm_timer.c index 517e1c7..9ad4ca3 100644 --- a/drivers/clocksource/fsl_ftm_timer.c +++ b/drivers/clocksource/fsl_ftm_timer.c @@ -316,15 +316,16 @@ static int __init ftm_calc_closest_round_cyc(unsigned long freq) return 0; } -static void __init ftm_timer_init(struct device_node *np) +static int __init ftm_timer_init(struct device_node *np) { unsigned long freq; - int irq; + int ret, irq; priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) - return; + return -ENOMEM; + ret = -ENXIO; priv->clkevt_base = of_iomap(np, 0); if (!priv->clkevt_base) { pr_err("ftm: unable to map event timer registers\n"); @@ -337,6 +338,7 @@ static void __init ftm_timer_init(struct device_node *np) goto err; } + ret = -EINVAL; irq = irq_of_parse_and_map(np, 0); if (irq <= 0) { pr_err("ftm: unable to get IRQ from DT, %d\n", irq); @@ -349,18 +351,22 @@ static void __init ftm_timer_init(struct device_node *np) if (!freq) goto err; - if (ftm_calc_closest_round_cyc(freq)) + ret = ftm_calc_closest_round_cyc(freq); + if (ret) goto err; - if (ftm_clocksource_init(freq)) + ret = ftm_clocksource_init(freq); + if (ret) goto err; - if (ftm_clockevent_init(freq, irq)) + ret = ftm_clockevent_init(freq, irq); + if (ret) goto err; - return; + return 0; err: kfree(priv); + return ret; } -CLOCKSOURCE_OF_DECLARE(flextimer, "fsl,ftm-timer", ftm_timer_init); +CLOCKSOURCE_OF_DECLARE_RET(flextimer, "fsl,ftm-timer", ftm_timer_init);