On Tue, Apr 06, 2021 at 08:45:51PM +0800, Yicong Yang wrote:
> +static int hisi_ptt_create_trace_entries(struct hisi_ptt *hisi_ptt)
> +{
> +     struct hisi_ptt_debugfs_file_desc *trace_files;
> +     struct dentry *dir;
> +     int i, ret = 0;
> +
> +     dir = debugfs_create_dir("trace", hisi_ptt->debugfs_dir);
> +     if (IS_ERR(dir))
> +             return PTR_ERR(dir);

No need to care about this, please do not check, code should not do
different things based on if debugfs is working or not.

> +
> +     trace_files = devm_kmemdup(&hisi_ptt->pdev->dev, trace_entries,
> +                                sizeof(trace_entries), GFP_KERNEL);
> +     if (IS_ERR(trace_files)) {
> +             ret = PTR_ERR(trace_files);
> +             goto err;
> +     }
> +
> +     for (i = 0; i < ARRAY_SIZE(trace_entries); ++i) {
> +             struct dentry *file;
> +
> +             trace_files[i].hisi_ptt = hisi_ptt;
> +             file = debugfs_create_file(trace_files[i].name, 0600,
> +                                        dir, &trace_files[i],
> +                                        trace_files[i].fops);
> +             if (IS_ERR(file)) {
> +                     ret = PTR_ERR(file);

Same here, why check?

> +static int hisi_ptt_register_debugfs(void)
> +{
> +     if (!debugfs_initialized()) {
> +             pr_err("failed to create debugfs directory: debugfs 
> uninitialized\n");

Why do you care?  How can this happen?

> +             return -ENOENT;
> +     }
> +
> +     hisi_ptt_debugfs_root = debugfs_create_dir("hisi_ptt", NULL);
> +     if (IS_ERR(hisi_ptt_debugfs_root)) {

Again, no need to check.

If you are building the whole functionality of your code on if debugfs
is working or not, that feels really wrong.  Debugfs is for random
kernel debug type things, not a whole driver infrastructure that somehow
relies on it working or not.

thanks,

greg k-h

Reply via email to