> +static void *cgroup_seqfile_start(struct seq_file *seq, loff_t *ppos) > +{ > + struct cftype *cft = seq_cft(seq); > + > + if (cft->seq_start) { > + return cft->seq_start(seq, ppos); > + } else { > + /* > + * The same behavior and code as single_open(). Returns > + * !NULL if pos is at the beginning; otherwise, NULL. > + */ Isn't it simpler to choose between seq_open() and single_open() depending on if cft->seq_start is implemented? > + return NULL + !*ppos; > + } > +} ... > static int cgroup_file_open(struct inode *inode, struct file *file) > { > struct cfent *cfe = __d_cfe(file->f_dentry); > @@ -2338,20 +2384,17 @@ static int cgroup_file_open(struct inode *inode, struct file *file) > WARN_ON_ONCE(cfe->css && cfe->css != css); > cfe->css = css; > > - if (cft->open) { > - err = cft->open(inode, file); > - } else { > - err = single_open_size(file, cgroup_seqfile_show, cfe, > - sizeof(struct cgroup_open_file)); > - if (!err) { > - struct seq_file *sf = file->private_data; > - struct cgroup_open_file *of = sf->private; > + err = seq_open_private(file, &cgroup_seq_operations, > + sizeof(struct cgroup_open_file)); > + if (!err) { > + struct seq_file *sf = file->private_data; > + struct cgroup_open_file *of = sf->private; > > - of->cfe = cfe; > - } > + of->cfe = cfe; > + return 0; > } > > - if (css->ss && err) > + if (css->ss) > css_put(css); > return err; > } _______________________________________________ Containers mailing list Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/containers