summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/timerreset.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-03-07 16:01:57 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-03-14 09:06:27 +0100
commit77e6eba7146ba2e2074b719eec01cc7c40bbe98b (patch)
treeec87c51ccd9c53cb65067a2a06a75d29b32387f3 /cpukit/rtems/src/timerreset.c
parentpc386: Fix linker usage issues with -r and function sections (diff)
downloadrtems-77e6eba7146ba2e2074b719eec01cc7c40bbe98b.tar.bz2
score: Add and use _Objects_Get_local()
This simplifies the handling with local-only objects. Update #2555.
Diffstat (limited to 'cpukit/rtems/src/timerreset.c')
-rw-r--r--cpukit/rtems/src/timerreset.c74
1 files changed, 24 insertions, 50 deletions
diff --git a/cpukit/rtems/src/timerreset.c b/cpukit/rtems/src/timerreset.c
index 72c912baa3..a4090152b3 100644
--- a/cpukit/rtems/src/timerreset.c
+++ b/cpukit/rtems/src/timerreset.c
@@ -18,62 +18,36 @@
#include "config.h"
#endif
-#include <rtems/system.h>
-#include <rtems/rtems/status.h>
-#include <rtems/rtems/support.h>
-#include <rtems/score/thread.h>
#include <rtems/rtems/timerimpl.h>
-#include <rtems/score/watchdogimpl.h>
-
-/*
- * rtems_timer_reset
- *
- * This directive allows a thread to reset a timer.
- *
- * Input parameters:
- * id - timer id
- *
- * Output parameters:
- * RTEMS_SUCCESSFUL - if successful
- * error code - if unsuccessful
- */
rtems_status_code rtems_timer_reset(
rtems_id id
)
{
- Timer_Control *the_timer;
- Objects_Locations location;
- ISR_lock_Context lock_context;
- Per_CPU_Control *cpu;
- rtems_status_code status;
-
- the_timer = _Timer_Get( id, &location, &lock_context );
- switch ( location ) {
-
- case OBJECTS_LOCAL:
- cpu = _Timer_Acquire_critical( the_timer, &lock_context );
-
- if ( _Timer_Is_interval_class( the_timer->the_class ) ) {
- _Timer_Cancel( cpu, the_timer );
- _Watchdog_Insert(
- &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
- &the_timer->Ticker,
- cpu->Watchdog.ticks + the_timer->initial
- );
- status = RTEMS_SUCCESSFUL;
- } else {
- status = RTEMS_NOT_DEFINED;
- }
-
- _Timer_Release( cpu, &lock_context );
- return status;
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE: /* should never return this */
-#endif
- case OBJECTS_ERROR:
- break;
+ Timer_Control *the_timer;
+ ISR_lock_Context lock_context;
+
+ the_timer = _Timer_Get( id, &lock_context );
+ if ( the_timer != NULL ) {
+ Per_CPU_Control *cpu;
+ rtems_status_code status;
+
+ cpu = _Timer_Acquire_critical( the_timer, &lock_context );
+
+ if ( _Timer_Is_interval_class( the_timer->the_class ) ) {
+ _Timer_Cancel( cpu, the_timer );
+ _Watchdog_Insert(
+ &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
+ &the_timer->Ticker,
+ cpu->Watchdog.ticks + the_timer->initial
+ );
+ status = RTEMS_SUCCESSFUL;
+ } else {
+ status = RTEMS_NOT_DEFINED;
+ }
+
+ _Timer_Release( cpu, &lock_context );
+ return status;
}
return RTEMS_INVALID_ID;