[rtems commit] libchip: Simplify RTC driver

Sebastian Huber sebh at rtems.org
Mon Jul 4 09:10:44 UTC 2016


Module:    rtems
Branch:    master
Commit:    0057e38f9d2af5a78c0da8ee24ace790b3e6bb81
Changeset: http://git.rtems.org/rtems/commit/?id=0057e38f9d2af5a78c0da8ee24ace790b3e6bb81

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Jul  4 11:06:53 2016 +0200

libchip: Simplify RTC driver

---

 c/src/lib/libbsp/arm/altera-cyclone-v/rtc/rtc.c |  2 --
 c/src/lib/libbsp/arm/beagle/rtc.c               |  1 -
 c/src/lib/libbsp/arm/lpc176x/rtc/rtc-config.c   |  2 --
 c/src/lib/libbsp/arm/lpc24xx/rtc/rtc-config.c   |  2 --
 c/src/lib/libbsp/arm/lpc32xx/rtc/rtc-config.c   |  2 --
 c/src/lib/libbsp/i386/pc386/clock/todcfg.c      |  2 --
 c/src/lib/libbsp/m68k/mcf5206elite/tod/todcfg.c |  2 --
 c/src/lib/libbsp/powerpc/beatnik/tod/todcfg.c   |  2 --
 c/src/lib/libbsp/powerpc/gen5200/tod/todcfg.c   |  2 --
 c/src/lib/libbsp/powerpc/mvme3100/tod/todcfg.c  |  2 --
 c/src/lib/libbsp/powerpc/mvme5500/tod/todcfg.c  |  2 --
 c/src/lib/libbsp/powerpc/qoriq/rtc/rtc-config.c |  2 --
 c/src/lib/libbsp/powerpc/shared/tod/todcfg.c    |  2 --
 c/src/lib/libbsp/shared/tod.c                   | 27 ++++++++++++-------------
 14 files changed, 13 insertions(+), 39 deletions(-)

diff --git a/c/src/lib/libbsp/arm/altera-cyclone-v/rtc/rtc.c b/c/src/lib/libbsp/arm/altera-cyclone-v/rtc/rtc.c
index aab39b3..20b9ae8 100644
--- a/c/src/lib/libbsp/arm/altera-cyclone-v/rtc/rtc.c
+++ b/c/src/lib/libbsp/arm/altera-cyclone-v/rtc/rtc.c
@@ -808,8 +808,6 @@ const rtc_fns  altera_cyclone_v_m41st87_ops =
 
 
 size_t  RTC_Count = ALTERA_CYCLONE_V_RTC_NUMBER;
-rtems_device_minor_number  RTC_Minor = 0;
-
 
 rtc_tbl  RTC_Table[ALTERA_CYCLONE_V_RTC_NUMBER] =
 {
diff --git a/c/src/lib/libbsp/arm/beagle/rtc.c b/c/src/lib/libbsp/arm/beagle/rtc.c
index 342caf7..abce5df 100644
--- a/c/src/lib/libbsp/arm/beagle/rtc.c
+++ b/c/src/lib/libbsp/arm/beagle/rtc.c
@@ -29,7 +29,6 @@
 #define dec(a) (((a / 10) << 4) | (a % 10))
 #define WRITE_WAIT_MAX_COUNT 10000
 
-rtems_device_minor_number RTC_Minor;
 size_t RTC_Count = 1;
 
 static void rtc_write_enable(void);
diff --git a/c/src/lib/libbsp/arm/lpc176x/rtc/rtc-config.c b/c/src/lib/libbsp/arm/lpc176x/rtc/rtc-config.c
index 22c7638..7d1512c 100644
--- a/c/src/lib/libbsp/arm/lpc176x/rtc/rtc-config.c
+++ b/c/src/lib/libbsp/arm/lpc176x/rtc/rtc-config.c
@@ -107,8 +107,6 @@ const rtc_fns lpc176x_rtc_ops = {
 
 size_t RTC_Count = LPC176X_RTC_NUMBER;
 
-rtems_device_minor_number RTC_Minor = 0;
-
 /**
  * @brief Table to describes the rtc device.
  */
diff --git a/c/src/lib/libbsp/arm/lpc24xx/rtc/rtc-config.c b/c/src/lib/libbsp/arm/lpc24xx/rtc/rtc-config.c
index 3a25f5d..c154a98 100644
--- a/c/src/lib/libbsp/arm/lpc24xx/rtc/rtc-config.c
+++ b/c/src/lib/libbsp/arm/lpc24xx/rtc/rtc-config.c
@@ -81,8 +81,6 @@ const rtc_fns lpc24xx_rtc_ops = {
 
 size_t RTC_Count = LPC24XX_RTC_NUMBER;
 
-rtems_device_minor_number RTC_Minor = 0;
-
 rtc_tbl	RTC_Table [LPC24XX_RTC_NUMBER] = {
   {
     .sDeviceName = "/dev/rtc",
diff --git a/c/src/lib/libbsp/arm/lpc32xx/rtc/rtc-config.c b/c/src/lib/libbsp/arm/lpc32xx/rtc/rtc-config.c
index cdae825..bd22524 100644
--- a/c/src/lib/libbsp/arm/lpc32xx/rtc/rtc-config.c
+++ b/c/src/lib/libbsp/arm/lpc32xx/rtc/rtc-config.c
@@ -127,8 +127,6 @@ const rtc_fns lpc32xx_rtc_ops = {
 
 size_t RTC_Count = LPC32XX_RTC_COUNT;
 
-rtems_device_minor_number RTC_Minor = 0;
-
 rtc_tbl	RTC_Table [LPC32XX_RTC_COUNT] = {
   {
     .sDeviceName = "/dev/rtc",
diff --git a/c/src/lib/libbsp/i386/pc386/clock/todcfg.c b/c/src/lib/libbsp/i386/pc386/clock/todcfg.c
index f53e1c2..7a1d369 100644
--- a/c/src/lib/libbsp/i386/pc386/clock/todcfg.c
+++ b/c/src/lib/libbsp/i386/pc386/clock/todcfg.c
@@ -30,5 +30,3 @@ rtc_tbl RTC_Table[] = {
 #define NUM_RTCS (sizeof(RTC_Table)/sizeof(rtc_tbl))
 
 size_t RTC_Count = NUM_RTCS;
-
-rtems_device_minor_number RTC_Minor;
diff --git a/c/src/lib/libbsp/m68k/mcf5206elite/tod/todcfg.c b/c/src/lib/libbsp/m68k/mcf5206elite/tod/todcfg.c
index 548f3fa..aacb857 100644
--- a/c/src/lib/libbsp/m68k/mcf5206elite/tod/todcfg.c
+++ b/c/src/lib/libbsp/m68k/mcf5206elite/tod/todcfg.c
@@ -41,8 +41,6 @@ rtc_tbl RTC_Table[] = {
 
 size_t RTC_Count = NUM_RTCS;
 
-rtems_device_minor_number RTC_Minor;
-
 /* mcf5206elite_ds1307_probe --
  *     RTC presence probe function. Return TRUE, if device is present.
  *     Device presence checked by probe access to RTC device over I2C bus.
diff --git a/c/src/lib/libbsp/powerpc/beatnik/tod/todcfg.c b/c/src/lib/libbsp/powerpc/beatnik/tod/todcfg.c
index ea5b056..e8faccc 100644
--- a/c/src/lib/libbsp/powerpc/beatnik/tod/todcfg.c
+++ b/c/src/lib/libbsp/powerpc/beatnik/tod/todcfg.c
@@ -30,5 +30,3 @@ rtc_tbl RTC_Table[] = {
 #define NUM_RTCS (sizeof(RTC_Table)/sizeof(rtc_tbl))
 
 size_t RTC_Count = NUM_RTCS;
-
-rtems_device_minor_number RTC_Minor;
diff --git a/c/src/lib/libbsp/powerpc/gen5200/tod/todcfg.c b/c/src/lib/libbsp/powerpc/gen5200/tod/todcfg.c
index 2460b8f..2120fa3 100644
--- a/c/src/lib/libbsp/powerpc/gen5200/tod/todcfg.c
+++ b/c/src/lib/libbsp/powerpc/gen5200/tod/todcfg.c
@@ -63,8 +63,6 @@ rtc_tbl RTC_Table[] = {
 
 size_t RTC_Count = NUM_RTCS;
 
-rtems_device_minor_number RTC_Minor;
-
 /* mpc5200_pcf8563_probe --
  *     RTC presence probe function. Return TRUE, if device is present.
  *     Device presence checked by probe access to RTC device over I2C bus.
diff --git a/c/src/lib/libbsp/powerpc/mvme3100/tod/todcfg.c b/c/src/lib/libbsp/powerpc/mvme3100/tod/todcfg.c
index b8327a9..939bea0 100644
--- a/c/src/lib/libbsp/powerpc/mvme3100/tod/todcfg.c
+++ b/c/src/lib/libbsp/powerpc/mvme3100/tod/todcfg.c
@@ -22,5 +22,3 @@ rtc_tbl RTC_Table[] = {
 #define NUM_RTCS (sizeof(RTC_Table)/sizeof(rtc_tbl))
 
 size_t RTC_Count = NUM_RTCS;
-
-rtems_device_minor_number RTC_Minor;
diff --git a/c/src/lib/libbsp/powerpc/mvme5500/tod/todcfg.c b/c/src/lib/libbsp/powerpc/mvme5500/tod/todcfg.c
index a1e3c52..39089db 100644
--- a/c/src/lib/libbsp/powerpc/mvme5500/tod/todcfg.c
+++ b/c/src/lib/libbsp/powerpc/mvme5500/tod/todcfg.c
@@ -30,5 +30,3 @@ rtc_tbl RTC_Table[] = {
 #define NUM_RTCS (sizeof(RTC_Table)/sizeof(rtc_tbl))
 
 size_t RTC_Count = NUM_RTCS;
-
-rtems_device_minor_number RTC_Minor;
diff --git a/c/src/lib/libbsp/powerpc/qoriq/rtc/rtc-config.c b/c/src/lib/libbsp/powerpc/qoriq/rtc/rtc-config.c
index ce0c175..c3e39e0 100644
--- a/c/src/lib/libbsp/powerpc/qoriq/rtc/rtc-config.c
+++ b/c/src/lib/libbsp/powerpc/qoriq/rtc/rtc-config.c
@@ -52,8 +52,6 @@ const rtc_fns qoriq_rtc_ops = {
 
 size_t RTC_Count = RTC_COUNT;
 
-rtems_device_minor_number RTC_Minor = 0;
-
 rtc_tbl	RTC_Table [RTC_COUNT] = {
   {
     .sDeviceName = "/dev/rtc",
diff --git a/c/src/lib/libbsp/powerpc/shared/tod/todcfg.c b/c/src/lib/libbsp/powerpc/shared/tod/todcfg.c
index 2859ac8..17ef18d 100644
--- a/c/src/lib/libbsp/powerpc/shared/tod/todcfg.c
+++ b/c/src/lib/libbsp/powerpc/shared/tod/todcfg.c
@@ -44,8 +44,6 @@ rtc_tbl RTC_Table[] = {
 
 size_t RTC_Count = NUM_RTCS;
 
-rtems_device_minor_number RTC_Minor;
-
 #if !defined(mvme2100)
 #include <rtems/bspIo.h>
 void mvmertc_set_register(
diff --git a/c/src/lib/libbsp/shared/tod.c b/c/src/lib/libbsp/shared/tod.c
index 2a69bc9..560d2ea 100644
--- a/c/src/lib/libbsp/shared/tod.c
+++ b/c/src/lib/libbsp/shared/tod.c
@@ -18,12 +18,12 @@
 /*
  *  Configuration Information
  */
-extern size_t                     RTC_Count;
-extern rtems_device_minor_number  RTC_Minor;
+static rtems_device_minor_number RTC_Minor = UINT32_MAX;
 
-int RTC_Present;
-
-extern void setRealTimeToRTEMS(void);
+static bool RTC_Is_present(void)
+{
+  return RTC_Minor != UINT32_MAX;
+}
 
 /*
  *  rtc_initialize
@@ -50,12 +50,11 @@ rtems_device_driver rtc_initialize(
        * Use this device as the primary RTC
        */
       RTC_Minor = minor;
-      RTC_Present = 1;
       break;
     }
   }
 
-  if ( !RTC_Present ) {
+  if ( !RTC_Is_present() ) {
     /*
      * Failed to find an RTC -- this is not a fatal error.
      */
@@ -116,7 +115,7 @@ rtems_device_driver rtc_read(
   rw->offset = 0;
   rw->bytes_moved = 0;
 
-  if (!RTC_Present) {
+  if (!RTC_Is_present()) {
     return RTEMS_NOT_CONFIGURED;
   }
 
@@ -150,7 +149,7 @@ rtems_device_driver rtc_write(
   rw->offset = 0;
   rw->bytes_moved = 0;
 
-  if (!RTC_Present) {
+  if (!RTC_Is_present()) {
     return RTEMS_NOT_CONFIGURED;
   }
 
@@ -205,7 +204,7 @@ void setRealTimeToRTEMS()
 {
   rtems_time_of_day rtc_tod;
 
-  if (!RTC_Present)
+  if (!RTC_Is_present())
     return;
 
   RTC_Table[RTC_Minor].pDeviceFns->deviceGetTime(RTC_Minor, &rtc_tod);
@@ -221,7 +220,7 @@ void setRealTimeFromRTEMS(void)
 {
   rtems_time_of_day rtems_tod;
 
-  if (!RTC_Present)
+  if (!RTC_Is_present())
     return;
 
   rtems_clock_get_tod( &rtems_tod );
@@ -237,7 +236,7 @@ void getRealTime(
   rtems_time_of_day *tod
 )
 {
-  if (!RTC_Present)
+  if (!RTC_Is_present())
     return;
 
   RTC_Table[RTC_Minor].pDeviceFns->deviceGetTime(RTC_Minor, tod);
@@ -252,7 +251,7 @@ int setRealTime(
   const rtems_time_of_day *tod
 )
 {
-  if (!RTC_Present)
+  if (!RTC_Is_present())
     return -1;
 
   if ( !_TOD_Validate(tod) )
@@ -275,7 +274,7 @@ int checkRealTime(void)
   uint32_t   rtems_time;
   uint32_t   rtc_time;
 
-  if (!RTC_Present)
+  if (!RTC_Is_present())
     return -1;
 
   rtems_clock_get_tod( &rtems_tod );



More information about the vc mailing list