static int timerirq_release(struct inode *inode, struct file *file) { struct timerirq_data *data = file->private_data; dev_dbg(data->dev->this_device, "timerirq_release\n"); if (data->run) stop_timerirq(data); kfree(data); return 0; }
static int timerirq_release(struct inode *inode, struct file *file) { struct timerirq_data *data = file->private_data; printk(KERN_DEBUG "[TIMERIRQ] %s: data->run = %d\n", __func__, data->run); if (data->run) stop_timerirq(data); del_timer_sync(&(data->timer)); kfree(data); return 0; }
/* ioctl - I/O control */ static long timerirq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int retval = 0; int tmp; struct timerirq_data *data = file->private_data; dev_dbg(data->dev->this_device, "%s current->pid %d, %d, %ld\n", __func__, current->pid, cmd, arg); if (!data) return -EFAULT; switch (cmd) { case TIMERIRQ_SET_TIMEOUT: data->timeout = arg; break; case TIMERIRQ_GET_INTERRUPT_CNT: tmp = data->data.interruptcount - 1; if (data->data.interruptcount > 1) data->data.interruptcount = 1; if (copy_to_user((int *)arg, &tmp, sizeof(int))) return -EFAULT; break; case TIMERIRQ_START: data->period = arg; retval = start_timerirq(data); break; case TIMERIRQ_STOP: retval = stop_timerirq(data); break; default: retval = -EINVAL; } return retval; }