@@ -99,16 +99,7 @@ static inline uint64_t counter(void)
9999
100100static inline int get_comparator (uint32_t chan , uint64_t * cc )
101101{
102- nrfx_err_t result ;
103-
104- result = nrfx_grtc_syscounter_cc_value_read (chan , cc );
105- if (result != NRFX_SUCCESS ) {
106- if (result != NRFX_ERROR_INVALID_PARAM ) {
107- return - EAGAIN ;
108- }
109- return - EPERM ;
110- }
111- return 0 ;
102+ return nrfx_grtc_syscounter_cc_value_read (chan , cc );
112103}
113104
114105/*
@@ -175,14 +166,14 @@ static void sys_clock_timeout_handler(int32_t id, uint64_t cc_val, void *p_conte
175166int32_t z_nrf_grtc_timer_chan_alloc (void )
176167{
177168 uint8_t chan ;
178- nrfx_err_t err_code ;
169+ int err_code ;
179170
180171 /* Prevent allocating all available channels - one must be left for system purposes. */
181172 if (ext_channels_allocated >= EXT_CHAN_COUNT ) {
182173 return - ENOMEM ;
183174 }
184175 err_code = nrfx_grtc_channel_alloc (& chan );
185- if (err_code != NRFX_SUCCESS ) {
176+ if (err_code < 0 ) {
186177 return - ENOMEM ;
187178 }
188179 ext_channels_allocated ++ ;
@@ -192,9 +183,9 @@ int32_t z_nrf_grtc_timer_chan_alloc(void)
192183void z_nrf_grtc_timer_chan_free (int32_t chan )
193184{
194185 IS_CHANNEL_ALLOWED_ASSERT (chan );
195- nrfx_err_t err_code = nrfx_grtc_channel_free (chan );
186+ int err_code = nrfx_grtc_channel_free (chan );
196187
197- if (err_code == NRFX_SUCCESS ) {
188+ if (err_code == 0 ) {
198189 ext_channels_allocated -- ;
199190 }
200191}
@@ -251,19 +242,13 @@ int z_nrf_grtc_timer_compare_read(int32_t chan, uint64_t *val)
251242static int compare_set_nolocks (int32_t chan , uint64_t target_time ,
252243 z_nrf_grtc_timer_compare_handler_t handler , void * user_data )
253244{
254- nrfx_err_t result ;
255-
256245 __ASSERT_NO_MSG (target_time < COUNTER_SPAN );
257246 nrfx_grtc_channel_t user_channel_data = {
258247 .handler = handler ,
259248 .p_context = user_data ,
260249 .channel = chan ,
261250 };
262- result = nrfx_grtc_syscounter_cc_absolute_set (& user_channel_data , target_time , true);
263- if (result != NRFX_SUCCESS ) {
264- return - EPERM ;
265- }
266- return 0 ;
251+ return nrfx_grtc_syscounter_cc_absolute_set (& user_channel_data , target_time , true);
267252}
268253
269254static int compare_set (int32_t chan , uint64_t target_time ,
@@ -316,27 +301,19 @@ int z_nrf_grtc_timer_capture_prepare(int32_t chan)
316301 .p_context = NULL ,
317302 .channel = chan ,
318303 };
319- nrfx_err_t result ;
320304
321305 IS_CHANNEL_ALLOWED_ASSERT (chan );
322306
323307 /* Set the CC value to mark channel as not triggered and also to enable it
324308 * (makes CCEN=1). COUNTER_SPAN is used so as not to fire an event unnecessarily
325309 * - it can be assumed that such a large value will never be reached.
326310 */
327- result = nrfx_grtc_syscounter_cc_absolute_set (& user_channel_data , COUNTER_SPAN , false);
328-
329- if (result != NRFX_SUCCESS ) {
330- return - EPERM ;
331- }
332-
333- return 0 ;
311+ return nrfx_grtc_syscounter_cc_absolute_set (& user_channel_data , COUNTER_SPAN , false);
334312}
335313
336314int z_nrf_grtc_timer_capture_read (int32_t chan , uint64_t * captured_time )
337315{
338- uint64_t capt_time ;
339- nrfx_err_t result ;
316+ int result ;
340317
341318 IS_CHANNEL_ALLOWED_ASSERT (chan );
342319
@@ -346,14 +323,8 @@ int z_nrf_grtc_timer_capture_read(int32_t chan, uint64_t *captured_time)
346323 */
347324 return - EBUSY ;
348325 }
349- result = nrfx_grtc_syscounter_cc_value_read (chan , & capt_time );
350- if (result != NRFX_SUCCESS ) {
351- return - EPERM ;
352- }
353-
354- __ASSERT_NO_MSG (capt_time < COUNTER_SPAN );
355-
356- * captured_time = capt_time ;
326+ result = nrfx_grtc_syscounter_cc_value_read (chan , captured_time );
327+ __ASSERT_NO_MSG (* captured_time < COUNTER_SPAN );
357328
358329 return 0 ;
359330}
@@ -370,7 +341,7 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us)
370341 return - ENOTSUP ;
371342 }
372343
373- nrfx_err_t err_code ;
344+ int err_code ;
374345 static struct k_spinlock lock ;
375346 static uint8_t systemoff_channel ;
376347 uint64_t now = counter ();
@@ -394,9 +365,9 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us)
394365 k_spinlock_key_t key = k_spin_lock (& lock );
395366
396367 err_code = nrfx_grtc_channel_alloc (& systemoff_channel );
397- if (err_code != NRFX_SUCCESS ) {
368+ if (err_code < 0 ) {
398369 k_spin_unlock (& lock , key );
399- return - ENOMEM ;
370+ return err_code ;
400371 }
401372 (void )nrfx_grtc_syscounter_cc_int_disable (systemoff_channel );
402373 ret = compare_set (systemoff_channel ,
@@ -479,7 +450,7 @@ void sys_clock_disable(void)
479450
480451static int sys_clock_driver_init (void )
481452{
482- nrfx_err_t err_code ;
453+ int err_code ;
483454
484455#if defined(CONFIG_GEN_SW_ISR_TABLE )
485456 IRQ_CONNECT (DT_IRQN (GRTC_NODE ), DT_IRQ (GRTC_NODE , priority ), nrfx_isr ,
@@ -504,19 +475,19 @@ static int sys_clock_driver_init(void)
504475#endif
505476
506477 err_code = nrfx_grtc_init (0 );
507- if (err_code != NRFX_SUCCESS ) {
508- return - EPERM ;
478+ if (err_code < 0 ) {
479+ return err_code ;
509480 }
510481
511482#if defined(CONFIG_NRF_GRTC_START_SYSCOUNTER )
512483 err_code = nrfx_grtc_syscounter_start (true, & system_clock_channel_data .channel );
513- if (err_code != NRFX_SUCCESS ) {
514- return err_code == NRFX_ERROR_NO_MEM ? - ENOMEM : - EPERM ;
484+ if (err_code < 0 ) {
485+ return err_code ;
515486 }
516487#else
517488 err_code = nrfx_grtc_channel_alloc (& system_clock_channel_data .channel );
518- if (err_code != NRFX_SUCCESS ) {
519- return - ENOMEM ;
489+ if (err_code < 0 ) {
490+ return err_code ;
520491 }
521492#endif /* CONFIG_NRF_GRTC_START_SYSCOUNTER */
522493
0 commit comments