Re: [PATCH V3 6/9] trace/hwlat: Use the generic function to read/write width and window

From: Steven Rostedt
Date: Thu Jun 03 2021 - 17:27:15 EST


On Fri, 14 May 2021 22:51:15 +0200
Daniel Bristot de Oliveira <bristot@xxxxxxxxxx> wrote:

> @@ -733,16 +624,18 @@ static ssize_t hwlat_mode_write(struct file *filp, const char __user *ubuf,
> return ret;
> }
>
> -static const struct file_operations width_fops = {
> - .open = tracing_open_generic,
> - .read = hwlat_read,
> - .write = hwlat_width_write,
> +static struct trace_ull_config hwlat_width = {
> + .lock = &hwlat_data.lock,
> + .val = &hwlat_data.sample_width,
> + .max = &hwlat_data.sample_window,
> + .min = NULL,
> };
>
> -static const struct file_operations window_fops = {
> - .open = tracing_open_generic,
> - .read = hwlat_read,
> - .write = hwlat_window_write,
> +static struct trace_ull_config hwlat_window = {

Yeah, the naming convention needs to be changed, because ull_config is
meaningless, and this code makes no sense. I know what it is doing, but if
I didn't, I'd have no clue what it was doing by reading it. :-p

-- Steve


> + .lock = &hwlat_data.lock,
> + .val = &hwlat_data.sample_window,
> + .max = NULL,
> + .min = &hwlat_data.sample_width,
> };
>
> static const struct file_operations thread_mode_fops = {
> @@ -775,15 +668,15 @@ static int init_tracefs(void)
>
> hwlat_sample_window = tracefs_create_file("window", 0640,
> top_dir,
> - &hwlat_data.sample_window,
> - &window_fops);
> + &hwlat_window,
> + &trace_ull_config_fops);
> if (!hwlat_sample_window)
> goto err;
>
> hwlat_sample_width = tracefs_create_file("width", 0644,
> top_dir,
> - &hwlat_data.sample_width,
> - &width_fops);
> + &hwlat_width,
> + &trace_ull_config_fops);
> if (!hwlat_sample_width)
> goto err;
>