linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: daniel.lezcano@linaro.org, tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, Carlo Caione <carlo@caione.org>,
	Kevin Hilman <khilman@baylibre.com>,
	linux-arm-kernel@lists.infradead.org (moderated list:ARM/Amlogic
	Meson...),
	linux-amlogic@lists.infradead.org (open list:ARM/Amlogic
	Meson...)
Subject: [PATCH V2 22/63] clocksource/drivers/mips-gic-timer: Convert init function to return error
Date: Thu, 16 Jun 2016 23:26:41 +0200	[thread overview]
Message-ID: <1466112442-31105-23-git-send-email-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <1466112442-31105-1-git-send-email-daniel.lezcano@linaro.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 <daniel.lezcano@linaro.org>
---
 drivers/clocksource/meson6_timer.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/clocksource/meson6_timer.c b/drivers/clocksource/meson6_timer.c
index 1fa22c4..3a6e78f 100644
--- a/drivers/clocksource/meson6_timer.c
+++ b/drivers/clocksource/meson6_timer.c
@@ -126,18 +126,22 @@ static struct irqaction meson6_timer_irq = {
 	.dev_id		= &meson6_clockevent,
 };
 
-static void __init meson6_timer_init(struct device_node *node)
+static int __init meson6_timer_init(struct device_node *node)
 {
 	u32 val;
 	int ret, irq;
 
 	timer_base = of_io_request_and_map(node, 0, "meson6-timer");
-	if (IS_ERR(timer_base))
-		panic("Can't map registers");
+	if (IS_ERR(timer_base)) {
+		pr_err("Can't map registers");
+		return -ENXIO;
+	}
 
 	irq = irq_of_parse_and_map(node, 0);
-	if (irq <= 0)
-		panic("Can't parse IRQ");
+	if (irq <= 0) {
+		pr_err("Can't parse IRQ");
+		return -EINVAL;
+	}
 
 	/* Set 1us for timer E */
 	val = readl(timer_base + TIMER_ISA_MUX);
@@ -158,14 +162,17 @@ static void __init meson6_timer_init(struct device_node *node)
 	meson6_clkevt_time_stop(CED_ID);
 
 	ret = setup_irq(irq, &meson6_timer_irq);
-	if (ret)
+	if (ret) {
 		pr_warn("failed to setup irq %d\n", irq);
+		return ret;
+	}
 
 	meson6_clockevent.cpumask = cpu_possible_mask;
 	meson6_clockevent.irq = irq;
 
 	clockevents_config_and_register(&meson6_clockevent, USEC_PER_SEC,
 					1, 0xfffe);
+	return 0;
 }
-CLOCKSOURCE_OF_DECLARE(meson6, "amlogic,meson6-timer",
+CLOCKSOURCE_OF_DECLARE_RET(meson6, "amlogic,meson6-timer",
 		       meson6_timer_init);
-- 
1.9.1

  parent reply	other threads:[~2016-06-16 21:40 UTC|newest]

Thread overview: 112+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16 21:26 [PATCH V2 00/63] clocksource/drivers/clksrc-of: Improve error handling Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 01/63] of: Add a new macro to declare_of for one parameter function returning a value Daniel Lezcano
2016-06-20 21:03   ` Rob Herring
2016-06-16 21:26 ` [PATCH V2 02/63] clocksource/drivers/clksrc-probe: Introduce init functions with return code Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 03/63] clocksource/drivers/rockchip_timer: Convert init function to return error Daniel Lezcano
2016-06-18 10:38   ` Heiko Stübner
2016-06-18 12:54     ` [PATCH V3] " Daniel Lezcano
2016-06-18 13:47       ` Heiko Stübner
2016-06-16 21:26 ` [PATCH V2 04/63] clocksource/drivers/mkt_timer: " Daniel Lezcano
2016-06-17 16:16   ` Matthias Brugger
2016-06-16 21:26 ` [PATCH V2 05/63] clocksource/drivers/exynos_mct: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 06/63] clocksource/drivers/asm9260: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 07/63] clocksource/drivers/cadence_ttc: " Daniel Lezcano
2016-06-16 21:43   ` Sören Brinkmann
2016-06-16 21:26 ` [PATCH V2 08/63] clocksource/drivers/st_lpc: " Daniel Lezcano
2016-06-20  7:39   ` Patrice Chotard
2016-06-20 11:33   ` Maxime Coquelin
2016-06-16 21:26 ` [PATCH V2 09/63] clocksource/drivers/dw_apb_timer: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 10/63] clocksource/drivers/clps711x: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 11/63] clocksource/drivers/digitcolor: " Daniel Lezcano
2016-06-17  3:15   ` Baruch Siach
2016-06-16 21:26 ` [PATCH V2 12/63] clocksource/drivers/armv7m_systick: " Daniel Lezcano
2016-06-20 11:31   ` Maxime Coquelin
2016-06-16 21:26 ` [PATCH V2 13/63] clocksource/drivers/bcm2835_timer: " Daniel Lezcano
2016-06-26  3:10   ` Eric Anholt
2016-06-16 21:26 ` [PATCH V2 14/63] clocksource/drivers/bcm_kona: " Daniel Lezcano
2016-06-20 17:22   ` Ray Jui
2016-06-20 17:40     ` Daniel Lezcano
2016-06-20 17:48     ` [PATCH V3] " Daniel Lezcano
2016-06-20 17:50       ` Ray Jui
2016-06-20 20:12         ` Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 15/63] clocksource/drivers/clksrc-dbx500: " Daniel Lezcano
2016-06-17 16:10   ` Linus Walleij
2016-06-16 21:26 ` [PATCH V2 16/63] clocksource/drivers/fsl_ftm_timer: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 17/63] clocksource/drivers/arm_arch_timer: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 18/63] clocksource/drivers/arm_global_timer: " Daniel Lezcano
2016-06-20 11:32   ` Maxime Coquelin
2016-06-16 21:26 ` [PATCH V2 19/63] clocksource/drivers/h8300_timer16: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 20/63] clocksource/drivers/h8300_tpu: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 21/63] " Daniel Lezcano
2016-06-16 21:26 ` Daniel Lezcano [this message]
2016-06-16 21:26 ` [PATCH V2 23/63] clocksource/drivers/moxart_timer: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 24/63] clocksource/drivers/mps2-timer: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 25/63] clocksource/drivers/mxs_timer: " Daniel Lezcano
2016-06-17  6:33   ` Uwe Kleine-König
2016-06-17 10:43     ` [PATCH V3] clocksource/drivers/mxs: " Daniel Lezcano
2016-06-20  9:15   ` [PATCH V2 25/63] clocksource/drivers/mxs_timer: " Liviu Dudau
2016-06-20  9:24     ` Daniel Lezcano
2016-06-20  9:26     ` [PATCH V3] clocksource/drivers/mps2-timer: " Daniel Lezcano
2016-06-20  9:42       ` liviu.dudau
2016-06-16 21:26 ` [PATCH V2 26/63] clocksource/drivers/nomadik-mtu: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 27/63] clocksource/drivers/pxa_timer: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 28/63] clocksource/drivers/qcom-timer: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 29/63] clocksource/drivers/samsung_pwm_timer: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 30/63] clocksource/drivers/sun4i_time: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 31/63] clocksource/drivers/tango_xtal: " Daniel Lezcano
2016-06-17  9:19   ` Mason
2016-06-17 10:26     ` [PATCH V3] " Daniel Lezcano
2016-06-17 12:35       ` Marc Gonzalez
2016-06-17 12:43         ` Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 32/63] clocksource/drivers/tegra20_timer: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 33/63] clocksource/drivers/time-armada-370-xp: " Daniel Lezcano
2016-06-17  7:21   ` Jon Hunter
2016-06-17  8:09     ` Daniel Lezcano
2016-06-17  9:06     ` [PATCH V3] clocksource/drivers/tegra20: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 34/63] clocksource/drivers/time-efm32: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 35/63] clocksource/drivers/time-lpc32xx: " Daniel Lezcano
2016-06-17  6:52   ` Uwe Kleine-König
2016-06-17  8:44     ` [PATCH V3] clocksource/drivers/time-efm32: " Daniel Lezcano
2016-06-17  9:46       ` Uwe Kleine-König
2016-06-16 21:26 ` [PATCH V2 36/63] clocksource/drivers/time-orion: " Daniel Lezcano
2016-06-20 17:08   ` Sylvain Lemieux
2016-06-16 21:26 ` [PATCH V2 37/63] clocksource/drivers/time-pistachio: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 38/63] " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 39/63] clocksource/drivers/timer-atlas7: " Daniel Lezcano
2016-06-16 21:26 ` [PATCH V2 40/63] clocksource/drivers/timer-atmel-pit: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 41/63] clocksource/drivers/timer-atmel-st: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 42/63] clocksource/drivers/prima2: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 43/63] clocksource/drivers/timer-imx-gpt: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 44/63] clocksource/drivers/timer-integrator-ap: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 45/63] clocksource/drivers/timer-keystone: " Daniel Lezcano
2016-06-17 16:03   ` Santosh Shilimkar
2016-06-16 21:27 ` [PATCH V2 46/63] clocksource/drivers/timer-sp804: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 47/63] clocksource/drivers/timer-stm32: " Daniel Lezcano
2016-06-20 11:32   ` Maxime Coquelin
2016-06-16 21:27 ` [PATCH V2 48/63] clocksource/drivers/timer-sun5i: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 49/63] clocksource/drivers/timer-ti-32k: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 50/63] clocksource/drivers/timer-u300: " Daniel Lezcano
2016-06-17 16:11   ` Linus Walleij
2016-06-16 21:27 ` [PATCH V2 51/63] clocksource/drivers/versatile: " Daniel Lezcano
2016-06-20  9:13   ` Liviu Dudau
2016-06-16 21:27 ` [PATCH V2 52/63] clocksource/drivers/vf_pit_timer: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 53/63] clocksource/drivers/vt8500_timer: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 54/63] clocksource/drivers/zevio-timer: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 55/63] clocksource/drivers/timer-sp804: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 56/63] clocksource/drivers/microblaze: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 57/63] clocksource/drivers/ralink: " Daniel Lezcano
2016-06-17  8:54   ` John Crispin
2016-06-16 21:27 ` [PATCH V2 58/63] clocksource/drivers/nios2: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 59/63] clocksource/drivers/smp_twd: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 60/63] clocksource/drivers/nps: " Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 61/63] clocksource/drivers/arc: " Daniel Lezcano
2016-06-17  8:59   ` Vineet Gupta
2016-06-17 10:09     ` [PATCH V3] " Daniel Lezcano
2016-06-17 14:30       ` Vineet Gupta
2016-06-24  4:06       ` Vineet Gupta
2016-06-24  6:41         ` Daniel Lezcano
2016-06-24  7:52           ` Vineet Gupta
2016-06-24  7:55             ` Daniel Lezcano
2016-06-16 21:27 ` [PATCH V2 62/63] clocksource/drivers/oxnas-rps: " Daniel Lezcano
2016-06-17  6:58   ` Neil Armstrong
     [not found] ` <1466112442-31105-64-git-send-email-daniel.lezcano@linaro.org>
2016-06-17 14:33   ` [PATCH V2 63/63] clocksources: Switch back to the clksrc table Vineet Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1466112442-31105-23-git-send-email-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=carlo@caione.org \
    --cc=khilman@baylibre.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).