forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/media/usb/uvc/uvc_debugfs.c
....@@ -1,14 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * uvc_debugfs.c -- USB Video Class driver - Debugging support
34 *
45 * Copyright (C) 2011
56 * Laurent Pinchart (laurent.pinchart@ideasonboard.com)
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
11
- *
127 */
138
149 #include <linux/module.h>
....@@ -78,56 +73,33 @@
7873 void uvc_debugfs_init_stream(struct uvc_streaming *stream)
7974 {
8075 struct usb_device *udev = stream->dev->udev;
81
- struct dentry *dent;
82
- char dir_name[32];
76
+ char dir_name[33];
8377
8478 if (uvc_debugfs_root_dir == NULL)
8579 return;
8680
87
- sprintf(dir_name, "%u-%u", udev->bus->busnum, udev->devnum);
81
+ snprintf(dir_name, sizeof(dir_name), "%u-%u-%u", udev->bus->busnum,
82
+ udev->devnum, stream->intfnum);
8883
89
- dent = debugfs_create_dir(dir_name, uvc_debugfs_root_dir);
90
- if (IS_ERR_OR_NULL(dent)) {
91
- uvc_printk(KERN_INFO, "Unable to create debugfs %s "
92
- "directory.\n", dir_name);
93
- return;
94
- }
84
+ stream->debugfs_dir = debugfs_create_dir(dir_name,
85
+ uvc_debugfs_root_dir);
9586
96
- stream->debugfs_dir = dent;
97
-
98
- dent = debugfs_create_file("stats", 0444, stream->debugfs_dir,
99
- stream, &uvc_debugfs_stats_fops);
100
- if (IS_ERR_OR_NULL(dent)) {
101
- uvc_printk(KERN_INFO, "Unable to create debugfs stats file.\n");
102
- uvc_debugfs_cleanup_stream(stream);
103
- return;
104
- }
87
+ debugfs_create_file("stats", 0444, stream->debugfs_dir, stream,
88
+ &uvc_debugfs_stats_fops);
10589 }
10690
10791 void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream)
10892 {
109
- if (stream->debugfs_dir == NULL)
110
- return;
111
-
11293 debugfs_remove_recursive(stream->debugfs_dir);
11394 stream->debugfs_dir = NULL;
11495 }
11596
11697 void uvc_debugfs_init(void)
11798 {
118
- struct dentry *dir;
119
-
120
- dir = debugfs_create_dir("uvcvideo", usb_debug_root);
121
- if (IS_ERR_OR_NULL(dir)) {
122
- uvc_printk(KERN_INFO, "Unable to create debugfs directory\n");
123
- return;
124
- }
125
-
126
- uvc_debugfs_root_dir = dir;
99
+ uvc_debugfs_root_dir = debugfs_create_dir("uvcvideo", usb_debug_root);
127100 }
128101
129102 void uvc_debugfs_cleanup(void)
130103 {
131
- if (uvc_debugfs_root_dir != NULL)
132
- debugfs_remove_recursive(uvc_debugfs_root_dir);
104
+ debugfs_remove_recursive(uvc_debugfs_root_dir);
133105 }