void cleanup_module(void) { rtdm_task_destroy(&stask1); rtdm_task_destroy(&stask2); rtdm_sem_destroy(&sem1); rtdm_sem_destroy(&sem2); stop_rt_timer(); }
void cleanup_timer_handler(void) { rtdm_task_destroy(&tx_handler_task); rtdm_task_destroy(&rx_handler_task); rtdm_sem_destroy(&rx_sem); rtdm_sem_destroy(&tx_sem); }
/* releases rtcfg_dev->dev_mutex on return */ static void rtcfg_client_detach(int ifindex, struct rt_proc_call *call) { struct rtcfg_device *rtcfg_dev = &device[ifindex]; struct rtcfg_cmd *cmd_event; cmd_event = rtpc_get_priv(call, struct rtcfg_cmd); cmd_event->args.detach.station_addr_list = rtcfg_dev->spec.clt.station_addr_list; cmd_event->args.detach.stage2_chain = rtcfg_dev->spec.clt.stage2_chain; while (1) { call = rtcfg_dequeue_blocking_call(ifindex); if (call == NULL) break; rtpc_complete_call(call, -ENODEV); } if (rtcfg_dev->flags & FLAG_TIMER_STARTED) { /* It's safe to kill the task, it either waits for dev_mutex or the next period. */ rtdm_task_destroy(&rtcfg_dev->timer_task); } rtcfg_reset_device(ifindex); rtcfg_next_main_state(cmd_event->internal.data.ifindex, RTCFG_MAIN_OFF); rtdm_mutex_unlock(&rtcfg_dev->dev_mutex); }
void __exit __rtdmtest_exit(void) { rtdm_task_destroy(&task); rtdm_task_join_nrt(&task, 100); printk("%s: unregistering device %s\n", __FUNCTION__, device.device_name); rtdm_dev_unregister(&device, 1000); }
/* Detach callback */ int loop_detach(struct a4l_device *dev) { lpprv_t *priv = (lpprv_t *)dev->priv; rtdm_task_destroy(&priv->loop_task); return 0; }
int setup_timer_handler(void) { int ret = 0; priv = netdev_priv(get_vlc_dev()); //Get the first packets in the packet ring rx_packet = get_rx_packet(); tx_packet = get_tx_packet(); //Init semas rtdm_sem_init(&tx_sem, 1); rtdm_sem_init(&rx_sem, 1); //Store the current time rx_sleep_slot = rtdm_clock_read_monotonic(); tx_sleep_slot = rx_sleep_slot + sleep_increment / 2; early_late_slot = do_div(sleep_increment, 5); //Return an error if either is NULL if(!rx_packet || !tx_packet) goto error; //Start the rx and tx handler tasks rtdm_task_init(&rx_handler_task, "VLC rx handler", rx_handler, NULL, RTDM_TASK_HIGHEST_PRIORITY, 0); if(ret) goto error; rtdm_task_init(&tx_handler_task, "VLC tx handler", tx_handler, NULL, RTDM_TASK_HIGHEST_PRIORITY, 0); if(ret) goto error; return 0; error: rtdm_task_destroy(&rx_handler_task); rtdm_task_destroy(&tx_handler_task); return -1; }
static void __exit rtnetproxy_cleanup_module(void) { /* Unregister the fallback at rtnet */ rt_ip_register_fallback(0); /* free the rtai srq */ rtdm_nrtsig_destroy(&rtnetproxy_signal); rtdm_task_destroy(&rtnetproxy_thread); rtdm_sem_destroy(&rtnetproxy_sem); /* Free the ringbuffers... */ { struct sk_buff *del_skb; /* standard skb */ while ((del_skb = read_from_ringbuffer(&ring_skb_rtnet_kernel)) != 0) { dev_kfree_skb(del_skb); } while ((del_skb = read_from_ringbuffer(&ring_skb_kernel_rtnet)) != 0) { dev_kfree_skb(del_skb); } } { struct rtskb *del; /* rtnet skb */ while ((del=read_from_ringbuffer(&ring_rtskb_kernel_rtnet))!=0) { kfree_rtskb(del); // Although this is kernel mode, freeing should work... } while ((del=read_from_ringbuffer(&ring_rtskb_rtnet_kernel))!=0) { kfree_rtskb(del); // Although this is kernel mode, freeing should work... } } /* Unregister the net device: */ unregister_netdev(&dev_rtnetproxy); kfree(dev_rtnetproxy.priv); memset(&dev_rtnetproxy, 0, sizeof(dev_rtnetproxy)); dev_rtnetproxy.init = rtnetproxy_init; rtskb_pool_release(&rtskb_pool); }
static int rtdmtest_ioctl(struct rtdm_dev_context *context, rtdm_user_info_t *user_info, unsigned int request, void *arg) { struct rtdmtest_context *ctx; struct rttst_rtdmtest_config config_buf, *config; rtdm_toseq_t toseq_local, *toseq = NULL; int i, err = 0; ctx = (struct rtdmtest_context *)context->dev_private; switch (request) { case RTTST_RTIOC_RTDMTEST_SEM_TIMEDDOWN: case RTTST_RTIOC_RTDMTEST_EVENT_TIMEDWAIT: case RTTST_RTIOC_RTDMTEST_MUTEX_TIMEDTEST: case RTTST_RTIOC_RTDMTEST_MUTEX_TEST: config = arg; if (user_info) { if (rtdm_safe_copy_from_user (user_info, &config_buf, arg, sizeof(struct rttst_rtdmtest_config)) < 0) return -EFAULT; config = &config_buf; } if (!config->seqcount) config->seqcount = 1; if (config->timeout && config->seqcount > 1) { toseq = &toseq_local; rtdm_toseq_init(toseq, config->timeout); } switch(request) { case RTTST_RTIOC_RTDMTEST_SEM_TIMEDDOWN: for (i = 0; i < config->seqcount; i++) { err = rtdm_sem_timeddown(&ctx->sem, config->timeout, toseq); if (err) break; } break; case RTTST_RTIOC_RTDMTEST_EVENT_TIMEDWAIT: for (i = 0; i < config->seqcount; i++) { err = rtdm_event_timedwait(&ctx->event, config->timeout, toseq); if (err) break; } break; case RTTST_RTIOC_RTDMTEST_MUTEX_TIMEDTEST: for (i = 0; i < config->seqcount; i++) { err = rtdm_mutex_timedlock(&ctx->mutex, config->timeout, toseq); if (err) break; if (config->delay_jiffies) { __set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(config->delay_jiffies); } rtdm_lock_count++; rtdm_mutex_unlock(&ctx->mutex); } break; case RTTST_RTIOC_RTDMTEST_MUTEX_TEST: for (i = 0; i < config->seqcount; i++) { if ((err = rtdm_mutex_lock(&ctx->mutex))) break; rtdm_lock_count++; rtdm_mutex_unlock(&ctx->mutex); } break; } break; case RTTST_RTIOC_RTDMTEST_SEM_DOWN: err = rtdm_sem_down(&ctx->sem); break; case RTTST_RTIOC_RTDMTEST_SEM_UP: rtdm_sem_up(&ctx->sem); break; case RTTST_RTIOC_RTDMTEST_SEM_DESTROY: rtdm_sem_destroy(&ctx->sem); break; case RTTST_RTIOC_RTDMTEST_EVENT_WAIT: err = rtdm_event_wait(&ctx->event); break; case RTTST_RTIOC_RTDMTEST_EVENT_SIGNAL: rtdm_event_signal(&ctx->event); break; case RTTST_RTIOC_RTDMTEST_EVENT_DESTROY: rtdm_event_destroy(&ctx->event); break; case RTTST_RTIOC_RTDMTEST_MUTEX_DESTROY: rtdm_mutex_destroy(&ctx->mutex); break; case RTTST_RTIOC_RTDMTEST_MUTEX_GETSTAT: printk("RTTST_RTIOC_RTDMTEST_MUTEX_GETSTAT\n"); if (user_info) config = &config_buf; else config = arg; config->seqcount = rtdm_lock_count; if (user_info) { if (rtdm_safe_copy_to_user (user_info, arg, &config_buf, sizeof(struct rttst_rtdmtest_config)) < 0) return -EFAULT; } break; case RTTST_RTIOC_RTDMTEST_NRTSIG_PEND: rtdm_nrtsig_pend(&ctx->nrtsig); break; case RTTST_RTIOC_RTDMTEST_TASK_CREATE: case RTTST_RTIOC_RTDMTEST_TASK_SET_PRIO: config = arg; if (user_info) { if (rtdm_safe_copy_from_user (user_info, &config_buf, arg, sizeof(struct rttst_rtdmtest_config)) < 0) return -EFAULT; config = &config_buf; } if (request == RTTST_RTIOC_RTDMTEST_TASK_CREATE) { task_period = config->timeout; rtdm_task_init(&task, "RTDMTEST", rtdmtest_task, (void *)config, config->priority, 0); } else { rtdm_task_set_priority(&task, config->priority); } break; case RTTST_RTIOC_RTDMTEST_TASK_DESTROY: rtdm_task_destroy(&task); rtdm_task_join_nrt(&task, 100); break; default: printk("request=%d\n", request); err = -ENOTTY; } return err; }