[PATCH 2/2] clock: Simplify driver initialization
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Dec 6 08:14:20 UTC 2019
Use a system initialization handler instead of a legacy IO driver.
---
bsps/bfin/shared/dev/clock.c | 13 +----------
bsps/m68k/csb360/dev/ckinit.c | 9 +------
bsps/m68k/gen68340/clock/ckinit.c | 9 +------
bsps/m68k/mcf5206elite/dev/ckinit.c | 7 +-----
bsps/m68k/mrm332/clock/ckinit.c | 8 +------
bsps/m68k/mvme147/clock/ckinit.c | 8 +------
bsps/m68k/mvme162/clock/ckinit.c | 8 +------
bsps/m68k/mvme167/clock/ckinit.c | 11 +--------
bsps/mips/hurricane/clock/ckinit.c | 15 +-----------
bsps/no_cpu/no_bsp/clock/ckinit.c | 14 +----------
bsps/powerpc/shared/clock/clock-ppc-dec.c | 11 +--------
bsps/powerpc/shared/clock/clock-ppc403.c | 6 +----
bsps/powerpc/shared/clock/clock.c | 8 +------
bsps/powerpc/ss555/clock/clock.c | 8 +------
bsps/sh/gensh1/clock/ckinit.c | 14 +----------
bsps/sh/gensh2/clock/ckinit.c | 13 +----------
bsps/sh/gensh4/clock/ckinit.c | 13 +----------
bsps/shared/dev/clock/clockimpl.h | 19 +--------------
bsps/shared/grlib/btimer/tlib_ckinit.c | 13 ++---------
cpukit/include/rtems/clockdrv.h | 39 ++++++++++++++++++++-----------
cpukit/include/rtems/confdefs.h | 12 ++++++----
21 files changed, 53 insertions(+), 205 deletions(-)
diff --git a/bsps/bfin/shared/dev/clock.c b/bsps/bfin/shared/dev/clock.c
index 75cd139e52..4d500f6ccb 100644
--- a/bsps/bfin/shared/dev/clock.c
+++ b/bsps/bfin/shared/dev/clock.c
@@ -53,16 +53,7 @@ static void Clock_exit(void)
*(uint32_t volatile *) TCNTL = 0;
}
-/*
- * Clock_initialize
- *
- * This routine initializes the clock driver.
- */
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
+void _Clock_Initialize( void )
{
Clock_driver_ticks = 0;
@@ -75,6 +66,4 @@ rtems_device_driver Clock_initialize(
*(uint32_t volatile *) TCNTL = TCNTL_TMPWR | TCNTL_TAUTORLD | TCNTL_TMREN;
atexit(Clock_exit);
-
- return RTEMS_SUCCESSFUL;
}
diff --git a/bsps/m68k/csb360/dev/ckinit.c b/bsps/m68k/csb360/dev/ckinit.c
index 839a2748ef..ef0e891cf2 100644
--- a/bsps/m68k/csb360/dev/ckinit.c
+++ b/bsps/m68k/csb360/dev/ckinit.c
@@ -112,14 +112,7 @@ Install_clock(rtems_isr_entry clock_isr)
atexit(Clock_exit);
}
-rtems_device_driver
-Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
+void _Clock_Initialize( void )
{
Install_clock (Clock_isr);
-
- return RTEMS_SUCCESSFUL;
}
diff --git a/bsps/m68k/gen68340/clock/ckinit.c b/bsps/m68k/gen68340/clock/ckinit.c
index 7dfe85d422..adbb14a399 100644
--- a/bsps/m68k/gen68340/clock/ckinit.c
+++ b/bsps/m68k/gen68340/clock/ckinit.c
@@ -91,14 +91,7 @@ Install_clock (rtems_isr_entry clock_isr)
atexit (Clock_exit);
}
-rtems_device_driver
-Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
+void _Clock_Initialize( void )
{
Install_clock (Clock_isr);
-
- return RTEMS_SUCCESSFUL;
}
diff --git a/bsps/m68k/mcf5206elite/dev/ckinit.c b/bsps/m68k/mcf5206elite/dev/ckinit.c
index 6cda45ca05..bbd4f20f46 100644
--- a/bsps/m68k/mcf5206elite/dev/ckinit.c
+++ b/bsps/m68k/mcf5206elite/dev/ckinit.c
@@ -102,12 +102,7 @@ Install_clock(rtems_isr_entry clock_isr)
atexit(Clock_exit);
}
-rtems_device_driver
-Clock_initialize(rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp)
+void _Clock_Initialize( void )
{
Install_clock (Clock_isr);
-
- return RTEMS_SUCCESSFUL;
}
diff --git a/bsps/m68k/mrm332/clock/ckinit.c b/bsps/m68k/mrm332/clock/ckinit.c
index cb7595f955..2b74ed6988 100644
--- a/bsps/m68k/mrm332/clock/ckinit.c
+++ b/bsps/m68k/mrm332/clock/ckinit.c
@@ -63,13 +63,7 @@ void Clock_exit( void )
/* do not restore old vector */
}
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
+void _Clock_Initialize( void )
{
Install_clock( Clock_isr );
-
- return RTEMS_SUCCESSFUL;
}
diff --git a/bsps/m68k/mvme147/clock/ckinit.c b/bsps/m68k/mvme147/clock/ckinit.c
index 4a3e95df86..bf5dba2160 100644
--- a/bsps/m68k/mvme147/clock/ckinit.c
+++ b/bsps/m68k/mvme147/clock/ckinit.c
@@ -70,13 +70,7 @@ void Clock_exit( void )
pcc->timer2_int_control = 0x00; /* Disable T2 Interr. */
}
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
+void _Clock_Initialize( void )
{
Install_clock( Clock_isr );
-
- return RTEMS_SUCCESSFUL;
}
diff --git a/bsps/m68k/mvme162/clock/ckinit.c b/bsps/m68k/mvme162/clock/ckinit.c
index 5412c16d7d..f22359ffd3 100644
--- a/bsps/m68k/mvme162/clock/ckinit.c
+++ b/bsps/m68k/mvme162/clock/ckinit.c
@@ -77,13 +77,7 @@ void Clock_exit( void )
/* Dummy for now. See other m68k BSP's for code examples */
}
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
+void _Clock_Initialize( void )
{
Install_clock( Clock_isr );
-
- return RTEMS_SUCCESSFUL;
}
diff --git a/bsps/m68k/mvme167/clock/ckinit.c b/bsps/m68k/mvme167/clock/ckinit.c
index 8ae7234b8f..bf808435a5 100644
--- a/bsps/m68k/mvme167/clock/ckinit.c
+++ b/bsps/m68k/mvme167/clock/ckinit.c
@@ -1,7 +1,4 @@
/*
- * Implementation of the Clock_initialize() functions
- * prototyped in rtems/c/src/lib/include/clockdrv.h.
- *
* This port does not allow the application to select which timer on the
* MVME167 to use for the clock, nor does it allow the application to
* configure the clock. The clock uses the VMEchip2 Tick Timer #2. This
@@ -147,13 +144,7 @@ void clock_exit( void )
set_vector( Old_ticker, CLOCK_VECTOR, 1 );
}
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
+void _Clock_Initialize( void )
{
VMEchip2_T2_initialize();
-
- return RTEMS_SUCCESSFUL;
}
diff --git a/bsps/mips/hurricane/clock/ckinit.c b/bsps/mips/hurricane/clock/ckinit.c
index 7e692efe0f..411cd5bdbb 100644
--- a/bsps/mips/hurricane/clock/ckinit.c
+++ b/bsps/mips/hurricane/clock/ckinit.c
@@ -198,20 +198,7 @@ void Clock_exit( void )
mips_disable_in_interrupt_mask(~CLOCK_VECTOR_MASK);
}
-/*
- * Clock_initialize
- *
- * Device driver entry point for clock tick driver initialization.
- */
-
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
+void _Clock_Initialize( void )
{
Install_clock( Clock_isr );
-
- return RTEMS_SUCCESSFUL;
}
-
diff --git a/bsps/no_cpu/no_bsp/clock/ckinit.c b/bsps/no_cpu/no_bsp/clock/ckinit.c
index 1d680fe355..ef24c8fbe0 100644
--- a/bsps/no_cpu/no_bsp/clock/ckinit.c
+++ b/bsps/no_cpu/no_bsp/clock/ckinit.c
@@ -109,19 +109,7 @@ void Clock_exit( void )
/* XXX: If necessary, restore the old vector */
}
-/*
- * Clock_initialize
- *
- * Device driver entry point for clock tick driver initialization.
- */
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
+void _Clock_Initialize( void )
{
Install_clock( Clock_isr );
-
- return RTEMS_SUCCESSFUL;
}
-
diff --git a/bsps/powerpc/shared/clock/clock-ppc-dec.c b/bsps/powerpc/shared/clock/clock-ppc-dec.c
index bb12e55902..9684b5bf6a 100644
--- a/bsps/powerpc/shared/clock/clock-ppc-dec.c
+++ b/bsps/powerpc/shared/clock/clock-ppc-dec.c
@@ -197,16 +197,7 @@ int clockIsOn(void* unused)
return 0;
}
-/*
- * Clock_initialize
- *
- * This routine initializes the clock driver.
- */
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
+void _Clock_Initialize( void )
{
rtems_interrupt_level l,tcr;
diff --git a/bsps/powerpc/shared/clock/clock-ppc403.c b/bsps/powerpc/shared/clock/clock-ppc403.c
index 8e3d3bb725..170c17e2cc 100644
--- a/bsps/powerpc/shared/clock/clock-ppc403.c
+++ b/bsps/powerpc/shared/clock/clock-ppc403.c
@@ -265,11 +265,7 @@ void Clock_exit(void)
BSP_remove_rtems_irq_handler (&clockIrqConnData);
}
-rtems_device_driver Clock_initialize(rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp)
+void _Clock_Initialize( void )
{
Install_clock( Clock_isr );
-
- return RTEMS_SUCCESSFUL;
}
diff --git a/bsps/powerpc/shared/clock/clock.c b/bsps/powerpc/shared/clock/clock.c
index a2a19865fb..2130d73147 100644
--- a/bsps/powerpc/shared/clock/clock.c
+++ b/bsps/powerpc/shared/clock/clock.c
@@ -167,11 +167,7 @@ static int ppc_clock_exception_handler_ppc405(BSP_Exception_frame *frame, unsign
return 0;
}
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *arg
-)
+void _Clock_Initialize( void )
{
uint64_t frequency = bsp_time_base_frequency;
uint64_t us_per_tick = rtems_configuration_get_microseconds_per_tick();
@@ -233,6 +229,4 @@ rtems_device_driver Clock_initialize(
ppc_tc.tc_frequency = frequency;
ppc_tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
rtems_timecounter_install(&ppc_tc);
-
- return RTEMS_SUCCESSFUL;
}
diff --git a/bsps/powerpc/ss555/clock/clock.c b/bsps/powerpc/ss555/clock/clock.c
index 74b34180c4..4a46dee242 100644
--- a/bsps/powerpc/ss555/clock/clock.c
+++ b/bsps/powerpc/ss555/clock/clock.c
@@ -130,13 +130,7 @@ static void Install_clock(rtems_isr_entry clock_isr)
atexit(Clock_exit);
}
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
+void _Clock_Initialize( void )
{
Install_clock( Clock_isr );
-
- return RTEMS_SUCCESSFUL;
}
diff --git a/bsps/sh/gensh1/clock/ckinit.c b/bsps/sh/gensh1/clock/ckinit.c
index 76faf2e857..3434692f8e 100644
--- a/bsps/sh/gensh1/clock/ckinit.c
+++ b/bsps/sh/gensh1/clock/ckinit.c
@@ -288,19 +288,7 @@ void Clock_exit( void )
/* old vector shall not be installed */
}
-/*
- * Clock_initialize
- *
- * Device driver entry point for clock tick driver initialization.
- */
-
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
+void _Clock_Initialize( void )
{
Install_clock( Clock_isr );
-
- return RTEMS_SUCCESSFUL;
}
diff --git a/bsps/sh/gensh2/clock/ckinit.c b/bsps/sh/gensh2/clock/ckinit.c
index 30a2e218ed..7b5c789e91 100644
--- a/bsps/sh/gensh2/clock/ckinit.c
+++ b/bsps/sh/gensh2/clock/ckinit.c
@@ -228,18 +228,7 @@ void Clock_exit( void )
/* old vector shall not be installed */
}
-/*
- * Clock_initialize
- *
- * Device driver entry point for clock tick driver initialization.
- */
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
+void _Clock_Initialize( void )
{
Install_clock( Clock_isr );
-
- return RTEMS_SUCCESSFUL;
}
diff --git a/bsps/sh/gensh4/clock/ckinit.c b/bsps/sh/gensh4/clock/ckinit.c
index 48439d670e..7e2b88acdb 100644
--- a/bsps/sh/gensh4/clock/ckinit.c
+++ b/bsps/sh/gensh4/clock/ckinit.c
@@ -229,18 +229,7 @@ Clock_exit(void)
/* old vector shall not be installed */
}
-/*
- * Clock_initialize
- *
- * Device driver entry point for clock tick driver initialization.
- */
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
+void _Clock_Initialize( void )
{
Install_clock( Clock_isr );
-
- return RTEMS_SUCCESSFUL;
}
diff --git a/bsps/shared/dev/clock/clockimpl.h b/bsps/shared/dev/clock/clockimpl.h
index f5eb4dcd1d..163b498a18 100644
--- a/bsps/shared/dev/clock/clockimpl.h
+++ b/bsps/shared/dev/clock/clockimpl.h
@@ -194,22 +194,7 @@ rtems_isr Clock_isr(
#endif
}
-/**
- * @brief Clock_initialize
- *
- * This routine initializes the clock driver.
- *
- * @param[in] major Clock device major number.
- * @param[in] minor Clock device minor number.
- * @param[in] parg Pointer to optional device driver arguments
- *
- * @retval rtems_device_driver status code
- */
-rtems_device_driver Clock_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *pargp
-)
+void _Clock_Initialize( void )
{
Clock_driver_ticks = 0;
@@ -240,6 +225,4 @@ rtems_device_driver Clock_initialize(
#if CLOCK_DRIVER_ISRS_PER_TICK
Clock_driver_isrs = CLOCK_DRIVER_ISRS_PER_TICK_VALUE;
#endif
-
- return RTEMS_SUCCESSFUL;
}
diff --git a/bsps/shared/grlib/btimer/tlib_ckinit.c b/bsps/shared/grlib/btimer/tlib_ckinit.c
index e43c8fdd8e..4f679984d8 100644
--- a/bsps/shared/grlib/btimer/tlib_ckinit.c
+++ b/bsps/shared/grlib/btimer/tlib_ckinit.c
@@ -163,8 +163,7 @@ static void tlib_clock_timecounter_tick(void)
priv.ops->timecounter_tick();
}
-/* Return a value not equal to RTEMS_SUCCESFUL to make Clock_initialize fail. */
-static rtems_device_driver tlib_clock_install_isr(rtems_isr *isr)
+static void tlib_clock_install_isr(rtems_isr *isr)
{
int flags = 0;
@@ -173,8 +172,6 @@ static rtems_device_driver tlib_clock_install_isr(rtems_isr *isr)
flags = TLIB_FLAGS_BROADCAST;
#endif
tlib_irq_register(priv.tlib_tick, isr, NULL, flags);
-
- return RTEMS_SUCCESSFUL;
}
#ifndef RTEMS_SMP
@@ -404,13 +401,7 @@ static const struct ops ops_irqamp = {
} while (0)
#define Clock_driver_support_install_isr( isr ) \
- do { \
- rtems_device_driver ret; \
- ret = tlib_clock_install_isr( isr ); \
- if (RTEMS_SUCCESSFUL != ret) { \
- return ret; \
- } \
- } while (0)
+ tlib_clock_install_isr( isr )
#define Clock_driver_support_set_interrupt_affinity(online_processors) \
/* Done by tlib_clock_install_isr() */
diff --git a/cpukit/include/rtems/clockdrv.h b/cpukit/include/rtems/clockdrv.h
index 543838b964..f3df912e74 100644
--- a/cpukit/include/rtems/clockdrv.h
+++ b/cpukit/include/rtems/clockdrv.h
@@ -1,9 +1,11 @@
/**
* @file
*
- * @brief Clock Driver for all Boards
+ * @ingroup RTEMSDriverClock
*
- * This file describes the Clock Driver for all boards.
+ * @brief Clock Driver API
+ *
+ * This file defines the Clock Driver API.
*/
/*
@@ -18,26 +20,35 @@
#ifndef _RTEMS_CLOCKDRV_H
#define _RTEMS_CLOCKDRV_H
-#include <rtems/io.h> /* rtems_device_driver */
+#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
-/* variables */
-
-extern volatile uint32_t Clock_driver_ticks;
+/**
+ * @defgroup RTEMSDriverClock Clock Driver
+ *
+ * @ingroup RTEMSDeviceDrivers
+ *
+ * @brief The Clock Driver API.
+ *
+ * @{
+ */
-/* default clock driver entry */
+/**
+ * @brief Count of clock driver ticks since system boot or last overflow.
+ *
+ * This counter may overflow.
+ */
+extern volatile uint32_t Clock_driver_ticks;
-#define CLOCK_DRIVER_TABLE_ENTRY \
- { Clock_initialize, NULL, NULL, NULL, NULL, NULL }
+/**
+ * @brief Initialize the clock driver.
+ */
+void _Clock_Initialize( void );
-rtems_device_driver Clock_initialize(
- rtems_device_major_number,
- rtems_device_minor_number,
- void *
-);
+/** @} */
#ifdef __cplusplus
}
diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h
index 4e6b91ad2c..7e089cefb2 100644
--- a/cpukit/include/rtems/confdefs.h
+++ b/cpukit/include/rtems/confdefs.h
@@ -1558,6 +1558,14 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
#ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#include <rtems/clockdrv.h>
+
+ #ifdef CONFIGURE_INIT
+ RTEMS_SYSINIT_ITEM(
+ _Clock_Initialize,
+ RTEMS_SYSINIT_DEVICE_DRIVERS,
+ RTEMS_SYSINIT_ORDER_THIRD
+ );
+ #endif
#endif
#ifdef CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
@@ -1619,9 +1627,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
#ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
CONSOLE_DRIVER_TABLE_ENTRY,
#endif
- #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
- CLOCK_DRIVER_TABLE_ENTRY,
- #endif
#ifdef CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER
RTC_DRIVER_TABLE_ENTRY,
#endif
@@ -1649,7 +1654,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
#ifdef CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER
NULL_DRIVER_TABLE_ENTRY
#elif !defined(CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER) && \
- !defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER) && \
!defined(CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER) && \
!defined(CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER) && \
!defined(CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER) && \
--
2.16.4
More information about the devel
mailing list