All of lore.kernel.org
 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, linux-arch@vger.kernel.org
Subject: [PATCH 12/92] clocksource/drivers/clksrc-probe: Introduce init functions with return code
Date: Tue, 28 Jun 2016 12:30:31 +0200	[thread overview]
Message-ID: <1467109911-11060-12-git-send-email-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <1467109911-11060-1-git-send-email-daniel.lezcano@linaro.org>

Currently, the clksrc-probe is not able to handle any error from the init
functions. There are different issues with the current code:
 - the code is duplicated in the init functions by writing error
 - every driver tends to panic in its own init function
 - counting the number of clocksources is not reliable

This patch adds another table to store the functions returning an error.
The table is temporary while we convert all the drivers to return an error
and will disappear.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/clocksource/clksrc-probe.c | 22 ++++++++++++++++++++++
 include/asm-generic/vmlinux.lds.h  |  2 ++
 include/linux/clocksource.h        |  3 +++
 3 files changed, 27 insertions(+)

diff --git a/drivers/clocksource/clksrc-probe.c b/drivers/clocksource/clksrc-probe.c
index 7cb6c92..5fa6a55 100644
--- a/drivers/clocksource/clksrc-probe.c
+++ b/drivers/clocksource/clksrc-probe.c
@@ -20,16 +20,22 @@
 #include <linux/clocksource.h>
 
 extern struct of_device_id __clksrc_of_table[];
+extern struct of_device_id __clksrc_ret_of_table[];
 
 static const struct of_device_id __clksrc_of_table_sentinel
 	__used __section(__clksrc_of_table_end);
 
+static const struct of_device_id __clksrc_ret_of_table_sentinel
+	__used __section(__clksrc_ret_of_table_end);
+
 void __init clocksource_probe(void)
 {
 	struct device_node *np;
 	const struct of_device_id *match;
 	of_init_fn_1 init_func;
+	of_init_fn_1_ret init_func_ret;
 	unsigned clocksources = 0;
+	int ret;
 
 	for_each_matching_node_and_match(np, __clksrc_of_table, &match) {
 		if (!of_device_is_available(np))
@@ -40,6 +46,22 @@ void __init clocksource_probe(void)
 		clocksources++;
 	}
 
+	for_each_matching_node_and_match(np, __clksrc_ret_of_table, &match) {
+		if (!of_device_is_available(np))
+			continue;
+
+		init_func_ret = match->data;
+
+		ret = init_func_ret(np);
+		if (ret) {
+			pr_err("Failed to initialize '%s': %d",
+			       of_node_full_name(np), ret);
+			continue;
+		}
+
+		clocksources++;
+	}
+
 	clocksources += acpi_probe_device_table(clksrc);
 
 	if (!clocksources)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 6a67ab9..8c6c626 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -173,6 +173,7 @@
 	*(__##name##_of_table_end)
 
 #define CLKSRC_OF_TABLES()	OF_TABLE(CONFIG_CLKSRC_OF, clksrc)
+#define CLKSRC_RET_OF_TABLES()	OF_TABLE(CONFIG_CLKSRC_OF, clksrc_ret)
 #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip)
 #define CLK_OF_TABLES()		OF_TABLE(CONFIG_COMMON_CLK, clk)
 #define IOMMU_OF_TABLES()	OF_TABLE(CONFIG_OF_IOMMU, iommu)
@@ -531,6 +532,7 @@
 	CLK_OF_TABLES()							\
 	RESERVEDMEM_OF_TABLES()						\
 	CLKSRC_OF_TABLES()						\
+	CLKSRC_RET_OF_TABLES()						\
 	IOMMU_OF_TABLES()						\
 	CPU_METHOD_OF_TABLES()						\
 	CPUIDLE_METHOD_OF_TABLES()					\
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 44a1aff..15c3839 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -246,6 +246,9 @@ extern int clocksource_i8253_init(void);
 #define CLOCKSOURCE_OF_DECLARE(name, compat, fn) \
 	OF_DECLARE_1(clksrc, name, compat, fn)
 
+#define CLOCKSOURCE_OF_DECLARE_RET(name, compat, fn) \
+	OF_DECLARE_1_RET(clksrc_ret, name, compat, fn)
+
 #ifdef CONFIG_CLKSRC_PROBE
 extern void clocksource_probe(void);
 #else
-- 
1.9.1

  parent reply	other threads:[~2016-06-28 11:01 UTC|newest]

Thread overview: 153+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <577251A4.7030508@linaro.org>
2016-06-28 10:30 ` [PATCH 01/92] clocksource/drivers/armada-370-xp: Make syscore_ops static Daniel Lezcano
2016-06-28 10:30   ` [PATCH 02/92] clocksource/drivers/digicolor: Fix warning of non-static function Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 03/92] clocksource/drivers/samsung_pwm_timer: Fix endian accessors Daniel Lezcano
2016-06-28 10:30   ` [PATCH 04/92] clocksource/drivers/samsung_pwm: Fix typo in Kconfig Daniel Lezcano
2016-06-28 10:30   ` [PATCH 05/92] dt-bindings: Document rk3399 rk-timer bindings Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 06/92] clocksource/drivers/rockchip: Add the dynamic irq flag to the timer Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 07/92] clocksource/drivers/rockchip: Add support for the rk3399 SoC Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 08/92] arm64: dts: rockchip: Add rktimer device node for rk3399 Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 09/92] clocksource/drivers/oxnas-rps: Add Oxford Semiconductor RPS Dual Timer Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 10/92] dt-bindings: clocksource: Add Oxford Semiconductor RPS Timer bindings Daniel Lezcano
2016-06-28 10:30   ` [PATCH 11/92] of: Add a new macro to declare_of for one parameter function returning a value Daniel Lezcano
2016-06-28 10:30   ` Daniel Lezcano [this message]
2016-06-28 10:30   ` [PATCH 13/92] clocksource/drivers/rockchip_timer: Convert init function to return error Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 14/92] clocksource/drivers/mtk_timer: " Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 15/92] clocksource/drivers/exynos_mct: " Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 16/92] clocksource/drivers/asm9260: " Daniel Lezcano
2016-06-28 10:30   ` [PATCH 17/92] clocksource/drivers/cadence_ttc: " Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 18/92] clocksource/drivers/st_lpc: " Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 19/92] clocksource/drivers/dw_apb_timer: " Daniel Lezcano
2016-06-28 10:30   ` [PATCH 20/92] clocksource/drivers/clps711x: " Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 21/92] clocksource/drivers/digicolor: " Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 22/92] clocksource/drivers/armv7m_systick: " Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 23/92] clocksource/drivers/bcm2835_timer: " Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 24/92] clocksource/drivers/bcm_kona: " Daniel Lezcano
2016-06-28 10:30   ` [PATCH 25/92] clocksource/drivers/clksrc-dbx500: " Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 26/92] clocksource/drivers/fsl_ftm_timer: " Daniel Lezcano
2016-06-28 10:30   ` [PATCH 27/92] clocksource/drivers/arm_arch_timer: " Daniel Lezcano
2016-06-28 10:30   ` [PATCH 28/92] clocksource/drivers/arm_global_timer: " Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 29/92] clocksource/drivers/h8300_timer16: " Daniel Lezcano
2016-06-28 10:30   ` [PATCH 30/92] clocksource/drivers/h8300_timer8: " Daniel Lezcano
2016-06-28 10:30   ` [PATCH 31/92] clocksource/drivers/h8300_tpu: " Daniel Lezcano
2016-06-28 10:30   ` [PATCH 32/92] clocksource/drivers/meson6_timer.c: " Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 33/92] clocksource/drivers/mips-gic-timer: " Daniel Lezcano
2016-06-28 10:30   ` [PATCH 34/92] clocksource/drivers/moxart: " Daniel Lezcano
2016-06-28 10:30   ` [PATCH 35/92] clocksource/drivers/mps2-timer: " Daniel Lezcano
2016-06-28 10:30     ` Daniel Lezcano
2016-06-28 10:30   ` [PATCH 36/92] clocksource/drivers/mxs: " Daniel Lezcano
2016-06-28 10:30   ` [PATCH 37/92] clocksource/drivers/nomadik-mtu: " Daniel Lezcano
2016-06-28 10:30   ` [PATCH 38/92] clocksource/drivers/pxa: " Daniel Lezcano
2016-06-28 10:30   ` [PATCH 39/92] clocksource/drivers/qcom: " Daniel Lezcano
2016-06-28 10:30   ` [PATCH 40/92] clocksource/drivers/samsung_pwm: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 41/92] clocksource/drivers/sun4i: " Daniel Lezcano
2016-06-28 10:31     ` Daniel Lezcano
2016-06-28 10:31   ` [PATCH 42/92] clocksource/drivers/tango_xtal: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 43/92] clocksource/drivers/tegra20: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 44/92] clocksource/drivers/time-armada-370-xp: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 45/92] clocksource/drivers/time-efm32: " Daniel Lezcano
2016-06-28 10:31     ` Daniel Lezcano
2016-06-28 10:31   ` [PATCH 46/92] clocksource/drivers/time-lpc32xx: " Daniel Lezcano
2016-06-28 10:31     ` Daniel Lezcano
2016-06-28 10:31   ` [PATCH 47/92] clocksource/drivers/orion: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 48/92] clocksource/drivers/pistachio: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 49/92] clocksource/drivers/atlas7: " Daniel Lezcano
2016-06-28 10:31     ` Daniel Lezcano
2016-06-28 10:31   ` [PATCH 50/92] clocksource/drivers/atmel-pit: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 51/92] clocksource/drivers/atmel-st: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 52/92] clocksource/drivers/prima2: " Daniel Lezcano
2016-06-28 10:31     ` Daniel Lezcano
2016-06-28 10:31   ` [PATCH 53/92] clocksource/drivers/imx-gpt: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 54/92] clocksource/drivers/integrator-ap: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 55/92] clocksource/drivers/keystone: " Daniel Lezcano
2016-06-28 10:31     ` Daniel Lezcano
2016-06-28 10:31   ` [PATCH 56/92] clocksource/drivers/sp804: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 57/92] clocksource/drivers/stm32: " Daniel Lezcano
2016-06-28 10:31     ` Daniel Lezcano
2016-06-28 10:31   ` [PATCH 58/92] clocksource/drivers/sun5i: " Daniel Lezcano
2016-06-28 10:31     ` Daniel Lezcano
2016-06-28 10:31   ` [PATCH 59/92] clocksource/drivers/ti-32k: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 60/92] clocksource/drivers/u300: " Daniel Lezcano
2016-06-28 10:31     ` Daniel Lezcano
2016-06-28 10:31   ` [PATCH 61/92] clocksource/drivers/versatile: " Daniel Lezcano
2016-06-28 10:31     ` Daniel Lezcano
2016-06-28 10:31   ` [PATCH 62/92] clocksource/drivers/vf_pit_timer: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 63/92] clocksource/drivers/vt8500: " Daniel Lezcano
2016-06-28 10:31     ` Daniel Lezcano
2016-06-28 10:31   ` [PATCH 64/92] clocksource/drivers/zevio: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 65/92] clocksource/drivers/microblaze: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 66/92] clocksource/drivers/ralink: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 67/92] clocksource/drivers/nios2: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 68/92] clocksource/drivers/smp_twd: " Daniel Lezcano
2016-06-28 10:31     ` Daniel Lezcano
2016-06-28 10:31   ` [PATCH 69/92] clocksource/drivers/nps: " Daniel Lezcano
2016-06-28 10:31   ` [PATCH 70/92] clocksource/drivers/arc: " Daniel Lezcano
2016-06-28 10:31     ` Daniel Lezcano
2016-06-28 10:31   ` [PATCH 71/92] clocksource/drivers/oxnas-rps: " Daniel Lezcano
2016-06-28 10:31     ` Daniel Lezcano
     [not found]   ` <1467109911-11060-1-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-06-28 10:31     ` [PATCH 72/92] clocksources: Switch back to the clksrc table Daniel Lezcano
2016-06-28 10:31       ` Daniel Lezcano
2016-06-28 10:31       ` Daniel Lezcano
2016-06-28 10:31       ` Daniel Lezcano
2016-06-28 10:31       ` Daniel Lezcano
2016-06-28 10:31   ` [PATCH 73/92] clk: Add missing clk_get_sys() stub Daniel Lezcano
2016-06-28 10:31   ` [PATCH 74/92] clocksource/drivers/bcm_kona: Remove useless header <asm/mach/time.h> Daniel Lezcano
2016-06-29  5:53     ` Ray Jui
2016-06-28 10:31   ` [PATCH 75/92] clocksource/drivers/bcm2835: Add the COMPILE_TEST option Daniel Lezcano
2016-06-28 10:31     ` Daniel Lezcano
2016-06-28 10:51 ` [PATCH 76/92] clocksource/drivers/armv7m_systick: " Daniel Lezcano
2016-06-28 10:51   ` Daniel Lezcano
2016-06-28 10:51   ` [PATCH 77/92] clocksource/drivers/bcm_kona: " Daniel Lezcano
2016-06-28 10:51     ` Daniel Lezcano
2016-06-28 10:51   ` [PATCH 78/92] clocksource/drivers/clps_711x: " Daniel Lezcano
2016-06-28 10:51     ` Daniel Lezcano
2016-06-28 10:51   ` [PATCH 79/92] clocksource/drivers/atlas7: " Daniel Lezcano
2016-06-28 10:51     ` Daniel Lezcano
2016-06-28 10:51   ` [PATCH 80/92] clocksource/drivers/moxart: " Daniel Lezcano
2016-06-28 10:51     ` Daniel Lezcano
2016-06-28 10:51   ` [PATCH 81/92] clocksource/drivers/mxs: Remove useless header <asm/mach/time.h> Daniel Lezcano
2016-06-28 10:51   ` [PATCH 82/92] clocksource/drivers/mxs: Add the COMPILE_TEST option Daniel Lezcano
2016-06-28 10:51     ` Daniel Lezcano
2016-06-28 10:51   ` [PATCH 83/92] clocksource/drivers/prima2: Remove useless header <asm/mach/time.h> Daniel Lezcano
2016-06-28 10:51     ` Daniel Lezcano
2016-06-28 10:51   ` [PATCH 84/92] clocksource/drivers/prima2: Add the COMPILE_TEST option Daniel Lezcano
2016-06-28 10:51     ` Daniel Lezcano
2016-06-28 10:51   ` [PATCH 85/92] clocksource/drivers/u300: " Daniel Lezcano
2016-06-28 10:51     ` Daniel Lezcano
2016-06-28 10:51   ` [PATCH 86/92] clocksource/drivers/nspire: " Daniel Lezcano
2016-06-28 10:51     ` Daniel Lezcano
2016-06-28 10:51   ` [PATCH 87/92] clocksource/drivers/keystone: " Daniel Lezcano
2016-06-28 10:51     ` Daniel Lezcano
2016-06-28 10:51   ` [PATCH 88/92] clocksource/drivers/integrator-ap: " Daniel Lezcano
2016-06-28 10:51     ` Daniel Lezcano
2016-06-28 10:51   ` [PATCH 89/92] clocksource/drivers/arm_global_timer: " Daniel Lezcano
2016-06-28 10:51   ` [PATCH 90/92] clocksource/drivers/timer-atmel-st: " Daniel Lezcano
2016-06-28 10:51   ` [PATCH 91/92] clocksource/drivers/versatile: " Daniel Lezcano
2016-06-28 10:51   ` [PATCH 92/92] clocksource/drivers/arm_arch_timer: Control the evtstrm via the cmdline Daniel Lezcano
2016-07-06 10:24 ` [PULL] : clockevents for 4.8 Daniel Lezcano
2016-07-06 10:44   ` Thomas Gleixner
2016-07-06 10:47     ` Thomas Gleixner
2016-07-06 13:21       ` Daniel Lezcano

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=1467109911-11060-12-git-send-email-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=linux-arch@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.