-int dib3000_init_pid_list(struct dib3000_state *state, int num)
-{
- int i;
- if (state != NULL) {
- state->pid_list = kmalloc(sizeof(struct dib3000_pid) * num,GFP_KERNEL);
- if (state->pid_list == NULL)
- return -ENOMEM;
-
- deb_info("initializing %d pids for the pid_list.\n",num);
- state->pid_list_lock = SPIN_LOCK_UNLOCKED;
- memset(state->pid_list,0,num*(sizeof(struct dib3000_pid)));
- for (i=0; i < num; i++) {
- state->pid_list[i].pid = 0;
- state->pid_list[i].active = 0;
- }
- state->feedcount = 0;
- } else
- return -EINVAL;
-
- return 0;
-}
-
-void dib3000_dealloc_pid_list(struct dib3000_state *state)
-{
- if (state != NULL && state->pid_list != NULL)
- kfree(state->pid_list);
-}
-
-/* fetch a pid from pid_list */
-int dib3000_get_pid_index(struct dib3000_pid pid_list[], int num_pids, int pid,
- spinlock_t *pid_list_lock,int onoff)
-{
- int i,ret = -1;
- unsigned long flags;
-
- spin_lock_irqsave(pid_list_lock,flags);
- for (i=0; i < num_pids; i++)
- if (onoff) {
- if (!pid_list[i].active) {
- pid_list[i].pid = pid;
- pid_list[i].active = 1;
- ret = i;
- break;
- }
- } else {
- if (pid_list[i].active && pid_list[i].pid == pid) {
- pid_list[i].pid = 0;
- pid_list[i].active = 0;
- ret = i;
- break;
- }
- }
-
- deb_info("setting pid: %5d %04x at index %d '%s'\n",pid,pid,ret,onoff ? "on" : "off");
-
- spin_unlock_irqrestore(pid_list_lock,flags);
- return ret;
-}
-