| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * uvc_debugfs.c -- USB Video Class driver - Debugging support |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2011 |
|---|
| 5 | 6 | * 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 | | - * |
|---|
| 12 | 7 | */ |
|---|
| 13 | 8 | |
|---|
| 14 | 9 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 78 | 73 | void uvc_debugfs_init_stream(struct uvc_streaming *stream) |
|---|
| 79 | 74 | { |
|---|
| 80 | 75 | struct usb_device *udev = stream->dev->udev; |
|---|
| 81 | | - struct dentry *dent; |
|---|
| 82 | | - char dir_name[32]; |
|---|
| 76 | + char dir_name[33]; |
|---|
| 83 | 77 | |
|---|
| 84 | 78 | if (uvc_debugfs_root_dir == NULL) |
|---|
| 85 | 79 | return; |
|---|
| 86 | 80 | |
|---|
| 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); |
|---|
| 88 | 83 | |
|---|
| 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); |
|---|
| 95 | 86 | |
|---|
| 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); |
|---|
| 105 | 89 | } |
|---|
| 106 | 90 | |
|---|
| 107 | 91 | void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream) |
|---|
| 108 | 92 | { |
|---|
| 109 | | - if (stream->debugfs_dir == NULL) |
|---|
| 110 | | - return; |
|---|
| 111 | | - |
|---|
| 112 | 93 | debugfs_remove_recursive(stream->debugfs_dir); |
|---|
| 113 | 94 | stream->debugfs_dir = NULL; |
|---|
| 114 | 95 | } |
|---|
| 115 | 96 | |
|---|
| 116 | 97 | void uvc_debugfs_init(void) |
|---|
| 117 | 98 | { |
|---|
| 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); |
|---|
| 127 | 100 | } |
|---|
| 128 | 101 | |
|---|
| 129 | 102 | void uvc_debugfs_cleanup(void) |
|---|
| 130 | 103 | { |
|---|
| 131 | | - if (uvc_debugfs_root_dir != NULL) |
|---|
| 132 | | - debugfs_remove_recursive(uvc_debugfs_root_dir); |
|---|
| 104 | + debugfs_remove_recursive(uvc_debugfs_root_dir); |
|---|
| 133 | 105 | } |
|---|