Skip to content

Commit 7e7828b

Browse files
Fix-Pointjerpelea
authored andcommitted
timers/oneshot: Remove oneshot tick API.
This commit removed all oneshot tick API for new clkdev API. Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
1 parent fc28b93 commit 7e7828b

File tree

3 files changed

+14
-289
lines changed

3 files changed

+14
-289
lines changed

arch/tricore/src/common/tricore_systimer.c

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ static int tricore_systimer_cancel(struct oneshot_lowerhalf_s *lower,
6464
struct timespec *ts);
6565
static int tricore_systimer_current(struct oneshot_lowerhalf_s *lower,
6666
struct timespec *ts);
67-
static int
68-
tricore_systimer_tick_start(struct oneshot_lowerhalf_s *lower,
69-
oneshot_callback_t callback, void *arg,
70-
clock_t ticks);
7167

7268
/****************************************************************************
7369
* Private Data
@@ -79,7 +75,6 @@ static const struct oneshot_operations_s g_tricore_systimer_ops =
7975
.start = tricore_systimer_start,
8076
.cancel = tricore_systimer_cancel,
8177
.current = tricore_systimer_current,
82-
.tick_start = tricore_systimer_tick_start,
8378
};
8479

8580
static struct tricore_systimer_lowerhalf_s g_systimer_lower =
@@ -270,48 +265,6 @@ static int tricore_systimer_current(struct oneshot_lowerhalf_s *lower,
270265
return 0;
271266
}
272267

273-
/****************************************************************************
274-
* Name: tricore_systimer_tick_start
275-
*
276-
* Description:
277-
* Start the oneshot timer
278-
*
279-
* Input Parameters:
280-
* lower An instance of the lower-half oneshot state structure. This
281-
* structure must have been previously initialized via a call to
282-
* oneshot_initialize();
283-
* handler The function to call when when the oneshot timer expires.
284-
* arg An opaque argument that will accompany the callback.
285-
* ticks Provides the duration of the one shot timer.
286-
*
287-
* Returned Value:
288-
* Zero (OK) is returned on success; a negated errno value is returned
289-
* on failure.
290-
*
291-
****************************************************************************/
292-
293-
static int
294-
tricore_systimer_tick_start(struct oneshot_lowerhalf_s *lower,
295-
oneshot_callback_t callback, void *arg,
296-
clock_t ticks)
297-
{
298-
struct tricore_systimer_lowerhalf_s *priv =
299-
(struct tricore_systimer_lowerhalf_s *)lower;
300-
uint64_t mtime = tricore_systimer_get_time(priv);
301-
302-
priv->alarm = mtime + priv->freq * ticks / TICK_PER_SEC;
303-
if (priv->alarm < mtime)
304-
{
305-
priv->alarm = UINT64_MAX;
306-
}
307-
308-
priv->callback = callback;
309-
priv->arg = arg;
310-
311-
tricore_systimer_set_timecmp(priv, priv->alarm);
312-
return 0;
313-
}
314-
315268
/****************************************************************************
316269
* Name: tricore_systimer_interrupt
317270
*

arch/x86_64/src/intel64/intel64_oneshot_lower.c

Lines changed: 1 addition & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ static int intel64_cancel(struct oneshot_lowerhalf_s *lower,
6565
struct timespec *ts);
6666
static int intel64_current(struct oneshot_lowerhalf_s *lower,
6767
struct timespec *ts);
68-
static int intel64_tick_max_delay(struct oneshot_lowerhalf_s *lower,
69-
clock_t *ticks);
70-
static int intel64_tick_start(struct oneshot_lowerhalf_s *lower,
71-
clock_t ticks);
72-
static int intel64_tick_cancel(struct oneshot_lowerhalf_s *lower,
73-
clock_t *ticks);
74-
static int intel64_tick_current(struct oneshot_lowerhalf_s *lower,
75-
clock_t *ticks);
7668

7769
/****************************************************************************
7870
* Private Data
@@ -85,11 +77,7 @@ static const struct oneshot_operations_s g_oneshot_ops =
8577
.max_delay = intel64_max_delay,
8678
.start = intel64_start,
8779
.cancel = intel64_cancel,
88-
.current = intel64_current,
89-
.tick_max_delay = intel64_tick_max_delay,
90-
.tick_start = intel64_tick_start,
91-
.tick_cancel = intel64_tick_cancel,
92-
.tick_current = intel64_tick_current,
80+
.current = intel64_current
9381
};
9482

9583
static spinlock_t g_oneshotlow_spin;
@@ -295,142 +283,6 @@ static int intel64_current(struct oneshot_lowerhalf_s *lower,
295283
return OK;
296284
}
297285

298-
/****************************************************************************
299-
* Name: intel64_tick_max_delay
300-
*
301-
* Description:
302-
* Determine the maximum delay of the one-shot timer (in microseconds)
303-
*
304-
* Input Parameters:
305-
* lower An instance of the lower-half oneshot state structure. This
306-
* structure must have been previously initialized via a call to
307-
* oneshot_initialize();
308-
* ticks The location in which to return the maximum delay.
309-
*
310-
* Returned Value:
311-
* Zero (OK) is returned on success; a negated errno value is returned
312-
* on failure.
313-
*
314-
****************************************************************************/
315-
316-
static int intel64_tick_max_delay(struct oneshot_lowerhalf_s *lower,
317-
clock_t *ticks)
318-
{
319-
struct timespec ts;
320-
int ret;
321-
322-
ret = intel64_max_delay(lower, &ts);
323-
324-
/* Convert time to ticks */
325-
326-
*ticks = clock_time2ticks(&ts);
327-
328-
return ret;
329-
}
330-
331-
/****************************************************************************
332-
* Name: intel64_tick_start
333-
*
334-
* Description:
335-
* Start the oneshot timer
336-
*
337-
* Input Parameters:
338-
* lower An instance of the lower-half oneshot state structure. This
339-
* structure must have been previously initialized via a call to
340-
* oneshot_initialize();
341-
* handler The function to call when when the oneshot timer expires.
342-
* arg An opaque argument that will accompany the callback.
343-
* ticks Provides the duration of the one shot timer.
344-
*
345-
* Returned Value:
346-
* Zero (OK) is returned on success; a negated errno value is returned
347-
* on failure.
348-
*
349-
****************************************************************************/
350-
351-
static int intel64_tick_start(struct oneshot_lowerhalf_s *lower,
352-
clock_t ticks)
353-
{
354-
struct timespec ts;
355-
356-
/* Convert ticks to time */
357-
358-
clock_ticks2time(&ts, ticks);
359-
360-
return intel64_start(lower, &ts);
361-
}
362-
363-
/****************************************************************************
364-
* Name: intel64_tick_cancel
365-
*
366-
* Description:
367-
* Cancel the oneshot timer and return the time remaining on the timer.
368-
*
369-
* NOTE: This function may execute at a high rate with no timer running (as
370-
* when pre-emption is enabled and disabled).
371-
*
372-
* Input Parameters:
373-
* lower Caller allocated instance of the oneshot state structure. This
374-
* structure must have been previously initialized via a call to
375-
* oneshot_initialize();
376-
* ticks The location in which to return the time remaining on the
377-
* oneshot timer.
378-
*
379-
* Returned Value:
380-
* Zero (OK) is returned on success. A call to up_timer_cancel() when
381-
* the timer is not active should also return success; a negated errno
382-
* value is returned on any failure.
383-
*
384-
****************************************************************************/
385-
386-
static int intel64_tick_cancel(struct oneshot_lowerhalf_s *lower,
387-
clock_t *ticks)
388-
{
389-
struct timespec ts;
390-
int ret;
391-
392-
ret = intel64_cancel(lower, &ts);
393-
394-
/* Convert time to ticks */
395-
396-
*ticks = clock_time2ticks(&ts);
397-
398-
return ret;
399-
}
400-
401-
/****************************************************************************
402-
* Name: intel64_tick_current
403-
*
404-
* Description:
405-
* Get the current time.
406-
*
407-
* Input Parameters:
408-
* lower Caller allocated instance of the oneshot state structure. This
409-
* structure must have been previously initialized via a call to
410-
* oneshot_initialize();
411-
* ticks The location in which to return the current time.
412-
*
413-
* Returned Value:
414-
* Zero (OK) is returned on success, a negated errno value is returned on
415-
* any failure.
416-
*
417-
****************************************************************************/
418-
419-
static int intel64_tick_current(struct oneshot_lowerhalf_s *lower,
420-
clock_t *ticks)
421-
{
422-
struct timespec ts;
423-
int ret;
424-
425-
ret = intel64_current(lower, &ts);
426-
427-
/* Convert time to ticks */
428-
429-
*ticks = clock_time2ticks(&ts);
430-
431-
return ret;
432-
}
433-
434286
/****************************************************************************
435287
* Public Functions
436288
****************************************************************************/

include/nuttx/timers/oneshot.h

Lines changed: 13 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,8 @@
9595
*
9696
****************************************************************************/
9797

98-
#define ONESHOT_MAX_DELAY(l,t) \
99-
((l)->ops->max_delay ? (l)->ops->max_delay(l,t) : oneshot_max_delay(l,t))
100-
#define ONESHOT_TICK_MAX_DELAY(l,t) \
101-
((l)->ops->tick_max_delay ? (l)->ops->tick_max_delay(l,t) : oneshot_tick_max_delay(l,t))
98+
#define ONESHOT_MAX_DELAY(l,t) (l)->ops->max_delay(l,t)
99+
#define ONESHOT_TICK_MAX_DELAY(l,t) oneshot_tick_max_delay(l,t)
102100

103101
/****************************************************************************
104102
* Name: ONESHOT_START
@@ -120,10 +118,8 @@
120118
*
121119
****************************************************************************/
122120

123-
#define ONESHOT_START(l,t) \
124-
((l)->ops->start ? (l)->ops->start(l,t) : oneshot_start(l,t))
125-
#define ONESHOT_TICK_START(l,t) \
126-
((l)->ops->tick_start ? (l)->ops->tick_start(l,t) : oneshot_tick_start(l,t))
121+
#define ONESHOT_START(l,t) (l)->ops->start(l,t)
122+
#define ONESHOT_TICK_START(l,t) oneshot_tick_start(l,t)
127123

128124
/****************************************************************************
129125
* Name: ONESHOT_CANCEL
@@ -149,10 +145,8 @@
149145
*
150146
****************************************************************************/
151147

152-
#define ONESHOT_CANCEL(l,t) \
153-
((l)->ops->cancel ? (l)->ops->cancel(l,t) : oneshot_cancel(l,t))
154-
#define ONESHOT_TICK_CANCEL(l,t) \
155-
((l)->ops->tick_cancel ? (l)->ops->tick_cancel(l,t) : oneshot_tick_cancel(l,t))
148+
#define ONESHOT_CANCEL(l,t) (l)->ops->cancel(l,t)
149+
#define ONESHOT_TICK_CANCEL(l,t) oneshot_tick_cancel(l,t)
156150

157151
/****************************************************************************
158152
* Name: ONESHOT_CURRENT
@@ -173,10 +167,8 @@
173167
*
174168
****************************************************************************/
175169

176-
#define ONESHOT_CURRENT(l,t) \
177-
((l)->ops->current ? (l)->ops->current(l,t) : oneshot_current(l,t))
178-
#define ONESHOT_TICK_CURRENT(l,t) \
179-
((l)->ops->tick_current ? (l)->ops->tick_current(l,t) : oneshot_tick_current(l,t))
170+
#define ONESHOT_CURRENT(l,t) (l)->ops->current(l,t)
171+
#define ONESHOT_TICK_CURRENT(l,t) oneshot_tick_current(l,t)
180172

181173
/****************************************************************************
182174
* Public Types
@@ -207,14 +199,6 @@ struct oneshot_operations_s
207199
FAR struct timespec *ts);
208200
CODE int (*current)(FAR struct oneshot_lowerhalf_s *lower,
209201
FAR struct timespec *ts);
210-
CODE int (*tick_max_delay)(FAR struct oneshot_lowerhalf_s *lower,
211-
FAR clock_t *ticks);
212-
CODE int (*tick_start)(FAR struct oneshot_lowerhalf_s *lower,
213-
clock_t ticks);
214-
CODE int (*tick_cancel)(FAR struct oneshot_lowerhalf_s *lower,
215-
FAR clock_t *ticks);
216-
CODE int (*tick_current)(FAR struct oneshot_lowerhalf_s *lower,
217-
FAR clock_t *ticks);
218202
};
219203

220204
/* This structure describes the state of the oneshot timer lower-half
@@ -260,77 +244,9 @@ extern "C"
260244
#endif
261245

262246
/****************************************************************************
263-
* Public Function Prototypes
247+
* Inline Functions
264248
****************************************************************************/
265249

266-
static inline
267-
int oneshot_max_delay(FAR struct oneshot_lowerhalf_s *lower,
268-
FAR struct timespec *ts)
269-
{
270-
clock_t tick;
271-
int ret;
272-
273-
if (lower->ops->tick_max_delay == NULL)
274-
{
275-
return -ENOTSUP;
276-
}
277-
278-
ret = lower->ops->tick_max_delay(lower, &tick);
279-
clock_ticks2time(ts, tick);
280-
return ret;
281-
}
282-
283-
static inline
284-
int oneshot_start(FAR struct oneshot_lowerhalf_s *lower,
285-
FAR const struct timespec *ts)
286-
{
287-
clock_t tick;
288-
289-
if (lower->ops->tick_start == NULL)
290-
{
291-
return -ENOTSUP;
292-
}
293-
294-
tick = clock_time2ticks(ts);
295-
return lower->ops->tick_start(lower, tick);
296-
}
297-
298-
static inline
299-
int oneshot_cancel(FAR struct oneshot_lowerhalf_s *lower,
300-
FAR struct timespec *ts)
301-
{
302-
clock_t tick;
303-
int ret;
304-
305-
if (lower->ops->tick_cancel == NULL)
306-
{
307-
return -ENOTSUP;
308-
}
309-
310-
ret = lower->ops->tick_cancel(lower, &tick);
311-
clock_ticks2time(ts, tick);
312-
313-
return ret;
314-
}
315-
316-
static inline
317-
int oneshot_current(FAR struct oneshot_lowerhalf_s *lower,
318-
FAR struct timespec *ts)
319-
{
320-
clock_t tick;
321-
int ret;
322-
323-
if (lower->ops->tick_current == NULL)
324-
{
325-
return -ENOTSUP;
326-
}
327-
328-
ret = lower->ops->tick_current(lower, &tick);
329-
clock_ticks2time(ts, tick);
330-
331-
return ret;
332-
}
333-
334250
static inline
335251
int oneshot_tick_max_delay(FAR struct oneshot_lowerhalf_s *lower,
336252
FAR clock_t *ticks)
@@ -408,6 +324,10 @@ void oneshot_process_callback(FAR struct oneshot_lowerhalf_s *lower)
408324
}
409325
}
410326

327+
/****************************************************************************
328+
* Public Function Prototypes
329+
****************************************************************************/
330+
411331
/****************************************************************************
412332
* Name: oneshot_initialize
413333
*

0 commit comments

Comments
 (0)