Ejemplo n.º 1
0
static ssize_t hwsampler_write(struct file *file, char const __user *buf,
		size_t count, loff_t *offset)
{
	unsigned long val;
	int retval;

	if (*offset)
		return -EINVAL;

	retval = oprofilefs_ulong_from_user(&val, buf, count);
	if (retval <= 0)
		return retval;

	if (val != 0 && val != 1)
		return -EINVAL;

	if (oprofile_started)
		/*
		 * save to do without locking as we set
		 * hwsampler_running in start() when start_mutex is
		 * held
		 */
		return -EBUSY;

	hwsampler_enabled = val;

	return count;
}
Ejemplo n.º 2
0
static ssize_t timer_enabled_write(struct file *file, char const __user *buf,
				   size_t count, loff_t *offset)
{
	unsigned long val;
	int retval;

	if (*offset)
		return -EINVAL;

	retval = oprofilefs_ulong_from_user(&val, buf, count);
	if (retval <= 0)
		return retval;

	if (val != 0 && val != 1)
		return -EINVAL;

	/* Timer cannot be disabled without having hardware sampling.  */
	if (val == 0 && !hwsampler_available)
		return -EINVAL;

	if (oprofile_started)
		/*
		 * save to do without locking as we set
		 * hwsampler_running in start() when start_mutex is
		 * held
		 */
		return -EBUSY;

	hwsampler_enabled = !val;

	return count;
}
Ejemplo n.º 3
0
static ssize_t ulong_write_file(struct file * file, char const __user * buf, size_t count, loff_t * offset)
{
	unsigned long * value = file->private_data;
	int retval;

	if (*offset)
		return -EINVAL;

	retval = oprofilefs_ulong_from_user(value, buf, count);

	if (retval)
		return retval;
	return count;
}
Ejemplo n.º 4
0
static ssize_t hwsampler_zero_write(struct file *file, char const __user *buf,
				     size_t count, loff_t *offset)
{
	unsigned long val;
	int retval;

	if (*offset)
		return -EINVAL;

	retval = oprofilefs_ulong_from_user(&val, buf, count);
	if (retval <= 0)
		return retval;
	if (val != 0)
		return -EINVAL;
	return count;
}
Ejemplo n.º 5
0
static ssize_t depth_write(struct file *file, char const __user *buf, size_t count, loff_t *offset)
{
	unsigned long val;
	int retval;

	if (*offset)
		return -EINVAL;

	retval = oprofilefs_ulong_from_user(&val, buf, count);
	if (retval)
		return retval;

	retval = oprofile_set_backtrace(val);

	if (retval)
		return retval;
	return count;
}
Ejemplo n.º 6
0
static ssize_t hw_interval_write(struct file *file, char const __user *buf,
				 size_t count, loff_t *offset)
{
	unsigned long val;
	int retval;

	if (*offset)
		return -EINVAL;
	retval = oprofilefs_ulong_from_user(&val, buf, count);
	if (retval <= 0)
		return retval;
	if (val < oprofile_min_interval)
		oprofile_hw_interval = oprofile_min_interval;
	else if (val > oprofile_max_interval)
		oprofile_hw_interval = oprofile_max_interval;
	else
		oprofile_hw_interval = val;

	return count;
}
Ejemplo n.º 7
0
static ssize_t hwsampler_kernel_write(struct file *file, char const __user *buf,
				      size_t count, loff_t *offset)
{
	unsigned long val;
	int retval;

	if (*offset)
		return -EINVAL;

	retval = oprofilefs_ulong_from_user(&val, buf, count);
	if (retval)
		return retval;

	if (val != 0 && val != 1)
		return -EINVAL;

	counter_config.kernel = val;

	return count;
}
Ejemplo n.º 8
0
static ssize_t enable_write(struct file *file, char const __user *buf, size_t count, loff_t *offset)
{
	unsigned long val;
	int retval;

	if (*offset)
		return -EINVAL;

	retval = oprofilefs_ulong_from_user(&val, buf, count);
	if (retval)
		return retval;

	if (val)
		retval = oprofile_start();
	else
		oprofile_stop();

	if (retval)
		return retval;
	return count;
}
ssize_t ca_css_tgid_write(struct file * file, char const __user * buf, size_t count, loff_t * offset)
{
	unsigned long val;
	int retval;

	if (*offset)
		return -EINVAL;

	if (!oprofile_ops.ca_css)
		return -EINVAL;

	retval = oprofilefs_ulong_from_user(&val, buf, count);
	if (retval)
		return retval;

	retval = oprofile_set_ulong(&ca_css_tgid, val);
	if (retval)
		return retval;

	return count;
}
Ejemplo n.º 10
0
static ssize_t sh7750_write_count(struct file *file, const char __user *buf,
				  size_t count, loff_t *ppos)
{
	int counter = to_counter(file);
	unsigned long val;

	if (oprofilefs_ulong_from_user(&val, buf, count))
		return -EFAULT;

	/*
	 * Any write will clear the counter, although only 0 should be
	 * written for this purpose, as we do not support setting the
	 * counter to an arbitrary value.
	 */
	WARN_ON(val != 0);

	if (counter == 0) {
		ctrl_outw(ctrl_inw(PMCR1) | PMCR_PMCLR, PMCR1);
	} else {
		ctrl_outw(ctrl_inw(PMCR2) | PMCR_PMCLR, PMCR2);
	}

	return count;
}
Ejemplo n.º 11
0
static ssize_t enhanced_backtrace_write(struct file *file,
		char const __user *buf, size_t count, loff_t *offset)
{
	unsigned long val;
	int retval = 0;

	if (*offset)
		return -EINVAL;

	retval = oprofilefs_ulong_from_user(&val, buf, count);
	if (retval)
		return retval;

	/* Allow for additional backtracing features, but for now the only
	 * additional capability is tracing across the system call boundary
	 */
	if (val & OPROFILE_SYSCALL_TRACE_ENABLE)
		retval = oprofile_set_trace_thru_syscall(1);

	if (retval)
		return retval;

	return count;
}