From patchwork Thu Jul 7 08:01:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71511 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1271760qgy; Thu, 7 Jul 2016 01:04:39 -0700 (PDT) X-Received: by 10.98.62.220 with SMTP id y89mr3020322pfj.9.1467878679092; Thu, 07 Jul 2016 01:04:39 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z78si2979052pfa.122.2016.07.07.01.04.36; Thu, 07 Jul 2016 01:04:39 -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 S1030368AbcGGIEb (ORCPT + 30 others); Thu, 7 Jul 2016 04:04:31 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:38098 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933547AbcGGIDs (ORCPT ); Thu, 7 Jul 2016 04:03:48 -0400 Received: by mail-wm0-f53.google.com with SMTP id n127so5816628wme.1 for ; Thu, 07 Jul 2016 01:03:47 -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=L483maY88lwBrxjEl9yOgMwKSdFWnEpHacIzT6DhxNw=; b=J7XTt5+k8spFlvJ2nT/AhpapKnkRP3gmXX8d2+ItlcZRQTlRVT8xydj5qtQMsian6u B60m93JgfmdUZZLP5jG+VDgHYe+QunIf+YFawYG1H0NyX9hKB5P5/7NxsNBD/jbruYR/ VG/lPVfyk3d6sXDCs/fZeQX1ld0LKToxYr5Oo= 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=L483maY88lwBrxjEl9yOgMwKSdFWnEpHacIzT6DhxNw=; b=GC/U2fP8Sbum6gzSVIus4dfRL/6WZ977NL8ZV9Ydh/IBzwiSoZtEAM3gyfLWpcP3kB Pm+ViRGYJbHFcIYXgFcrzJCzAkcuqvN5cWOe4rN5BHWHHFpc13gg/1lfjFsf0qPznZYS iL5iWrGw+Ii/dOmaThwdKPVXJ2A0Y+KP943vhgJpobvrBquXAZ9CABvZfQmcWp9Gz5Fz ZGmpakiv899ne2Wz1A6ZO8i2pSsOuN0vpQ9jDy0h4n4xUgPM8FXjrjsrgvnTWw7V4YJn 8X3Z7G5FH4eDtjsBDROQ807HTg1fk0VPzu1N2E096AJtlua4GUuFN/k4jEV5YF/UebEH 4cnw== X-Gm-Message-State: ALyK8tKzZYl0ux7Mix68wJcEbjXAgMCQ5qBgRX8g7La7gz/Zj2lqufIlQ6wV1ACY6CAlktJh X-Received: by 10.28.213.145 with SMTP id m139mr1366329wmg.81.1467878626897; Thu, 07 Jul 2016 01:03:46 -0700 (PDT) Received: from localhost.localdomain (lft31-1-88-121-166-205.fbx.proxad.net. [88.121.166.205]) by smtp.gmail.com with ESMTPSA id v70sm51327wmf.18.2016.07.07.01.03.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jul 2016 01:03:46 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 51/93] clocksource/drivers/atmel-st: Convert init function to return error Date: Thu, 7 Jul 2016 10:01:24 +0200 Message-Id: <1467878526-1238-51-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467878526-1238-1-git-send-email-daniel.lezcano@linaro.org> References: <577E0BED.3020608@linaro.org> <1467878526-1238-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-atmel-st.c | 44 +++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 16 deletions(-) -- 1.9.1 diff --git a/drivers/clocksource/timer-atmel-st.c b/drivers/clocksource/timer-atmel-st.c index 29d21d6..e9331d3 100644 --- a/drivers/clocksource/timer-atmel-st.c +++ b/drivers/clocksource/timer-atmel-st.c @@ -194,15 +194,17 @@ static struct clock_event_device clkevt = { /* * ST (system timer) module supports both clockevents and clocksource. */ -static void __init atmel_st_timer_init(struct device_node *node) +static int __init atmel_st_timer_init(struct device_node *node) { struct clk *sclk; unsigned int sclk_rate, val; int irq, ret; regmap_st = syscon_node_to_regmap(node); - if (IS_ERR(regmap_st)) - panic(pr_fmt("Unable to get regmap\n")); + if (IS_ERR(regmap_st)) { + pr_err("Unable to get regmap\n"); + return PTR_ERR(regmap_st); + } /* Disable all timer interrupts, and clear any pending ones */ regmap_write(regmap_st, AT91_ST_IDR, @@ -211,27 +213,37 @@ static void __init atmel_st_timer_init(struct device_node *node) /* Get the interrupts property */ irq = irq_of_parse_and_map(node, 0); - if (!irq) - panic(pr_fmt("Unable to get IRQ from DT\n")); + if (!irq) { + pr_err("Unable to get IRQ from DT\n"); + return -EINVAL; + } /* Make IRQs happen for the system timer */ ret = request_irq(irq, at91rm9200_timer_interrupt, IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL, "at91_tick", regmap_st); - if (ret) - panic(pr_fmt("Unable to setup IRQ\n")); + if (ret) { + pr_err("Unable to setup IRQ\n"); + return ret; + } sclk = of_clk_get(node, 0); - if (IS_ERR(sclk)) - panic(pr_fmt("Unable to get slow clock\n")); + if (IS_ERR(sclk)) { + pr_err("Unable to get slow clock\n"); + return PTR_ERR(sclk); + } - clk_prepare_enable(sclk); - if (ret) - panic(pr_fmt("Could not enable slow clock\n")); + ret = clk_prepare_enable(sclk); + if (ret) { + pr_err("Could not enable slow clock\n"); + return ret; + } sclk_rate = clk_get_rate(sclk); - if (!sclk_rate) - panic(pr_fmt("Invalid slow clock rate\n")); + if (!sclk_rate) { + pr_err("Invalid slow clock rate\n"); + return -EINVAL; + } timer_latch = (sclk_rate + HZ / 2) / HZ; /* The 32KiHz "Slow Clock" (tick every 30517.58 nanoseconds) is used @@ -246,7 +258,7 @@ static void __init atmel_st_timer_init(struct device_node *node) 2, AT91_ST_ALMV); /* register clocksource */ - clocksource_register_hz(&clk32k, sclk_rate); + return clocksource_register_hz(&clk32k, sclk_rate); } -CLOCKSOURCE_OF_DECLARE(atmel_st_timer, "atmel,at91rm9200-st", +CLOCKSOURCE_OF_DECLARE_RET(atmel_st_timer, "atmel,at91rm9200-st", atmel_st_timer_init);