summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/watchdogadjust.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-04-10 15:51:50 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-04-13 13:08:55 +0200
commitbcf536a50a0563b854773cb45bc0fd7b19cd5c51 (patch)
treebf613e7459c487dc8cc64ba28e2ff5cbc3a08d70 /cpukit/score/src/watchdogadjust.c
parentbsp/altera-cyclone-v: Add RTC driver (diff)
downloadrtems-bcf536a50a0563b854773cb45bc0fd7b19cd5c51.tar.bz2
score: Split _Watchdog_Adjust()
Split _Watchdog_Adjust() into _Watchdog_Adjust_backward() and _Watchdog_Adjust_forward(). Remove Watchdog_Adjust_directions, _Watchdog_Adjust_seconds() and _Watchdog_Adjust_ticks(). This avoids to check the same condition again. Update #2307.
Diffstat (limited to 'cpukit/score/src/watchdogadjust.c')
-rw-r--r--cpukit/score/src/watchdogadjust.c67
1 files changed, 31 insertions, 36 deletions
diff --git a/cpukit/score/src/watchdogadjust.c b/cpukit/score/src/watchdogadjust.c
index bbfda4d0cf..5d841049dc 100644
--- a/cpukit/score/src/watchdogadjust.c
+++ b/cpukit/score/src/watchdogadjust.c
@@ -18,57 +18,52 @@
#include "config.h"
#endif
-#include <rtems/system.h>
-#include <rtems/score/isr.h>
#include <rtems/score/watchdogimpl.h>
+#include <rtems/score/chainimpl.h>
+#include <rtems/score/isrlevel.h>
-void _Watchdog_Adjust(
- Chain_Control *header,
- Watchdog_Adjust_directions direction,
- Watchdog_Interval units
+void _Watchdog_Adjust_backward(
+ Chain_Control *header,
+ Watchdog_Interval units
)
{
ISR_Level level;
_ISR_Disable( level );
- /*
- * NOTE: It is safe NOT to make 'header' a pointer
- * to volatile data (contrast this with watchdoginsert.c)
- * because we call _Watchdog_Tickle() below and
- * hence the compiler must not assume *header to remain
- * unmodified across that call.
- *
- * Till Straumann, 7/2003
- */
if ( !_Chain_Is_empty( header ) ) {
- switch ( direction ) {
- case WATCHDOG_BACKWARD:
- _Watchdog_First( header )->delta_interval += units;
- break;
- case WATCHDOG_FORWARD:
- while ( units ) {
- if ( units < _Watchdog_First( header )->delta_interval ) {
- _Watchdog_First( header )->delta_interval -= units;
- break;
- } else {
- units -= _Watchdog_First( header )->delta_interval;
- _Watchdog_First( header )->delta_interval = 1;
+ _Watchdog_First( header )->delta_interval += units;
+ }
+
+ _ISR_Enable( level );
+}
+
+void _Watchdog_Adjust_forward(
+ Chain_Control *header,
+ Watchdog_Interval units
+)
+{
+ ISR_Level level;
+
+ _ISR_Disable( level );
+
+ while ( !_Chain_Is_empty( header ) && units > 0 ) {
+ Watchdog_Control *first = _Watchdog_First( header );
- _ISR_Enable( level );
+ if ( units < first->delta_interval ) {
+ first->delta_interval -= units;
+ break;
+ } else {
+ units -= first->delta_interval;
+ first->delta_interval = 1;
- _Watchdog_Tickle( header );
+ _ISR_Enable( level );
- _ISR_Disable( level );
+ _Watchdog_Tickle( header );
- if ( _Chain_Is_empty( header ) )
- break;
- }
- }
- break;
+ _ISR_Disable( level );
}
}
_ISR_Enable( level );
-
}