blob: 39fd43b3e1d2302317c321e5c7d0dcc4a0a2b8c9 [file] [log] [blame]
Alexey Fisheredbaa392011-11-03 09:39:37 -03001/*
2 * uvc_debugfs.c -- USB Video Class driver - Debugging support
3 *
4 * Copyright (C) 2011
5 * 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 */
13
14#include <linux/module.h>
15#include <linux/debugfs.h>
16#include <linux/slab.h>
17#include <linux/usb.h>
18
19#include "uvcvideo.h"
20
21/* -----------------------------------------------------------------------------
22 * Global and stream initialization/cleanup
23 */
24
25static struct dentry *uvc_debugfs_root_dir;
26
27int uvc_debugfs_init_stream(struct uvc_streaming *stream)
28{
29 struct usb_device *udev = stream->dev->udev;
30 struct dentry *dent;
31 char dir_name[32];
32
33 if (uvc_debugfs_root_dir == NULL)
34 return -ENODEV;
35
36 sprintf(dir_name, "%u-%u", udev->bus->busnum, udev->devnum);
37
38 dent = debugfs_create_dir(dir_name, uvc_debugfs_root_dir);
39 if (IS_ERR_OR_NULL(dent)) {
40 uvc_printk(KERN_INFO, "Unable to create debugfs %s directory.\n",
41 dir_name);
42 return -ENODEV;
43 }
44
45 stream->debugfs_dir = dent;
46
47 return 0;
48}
49
50void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream)
51{
52 if (stream->debugfs_dir == NULL)
53 return;
54
55 debugfs_remove_recursive(stream->debugfs_dir);
56 stream->debugfs_dir = NULL;
57}
58
59int uvc_debugfs_init(void)
60{
61 struct dentry *dir;
62
63 dir = debugfs_create_dir("uvcvideo", usb_debug_root);
64 if (IS_ERR_OR_NULL(dir)) {
65 uvc_printk(KERN_INFO, "Unable to create debugfs directory\n");
66 return -ENODATA;
67 }
68
69 uvc_debugfs_root_dir = dir;
70 return 0;
71}
72
73void uvc_debugfs_cleanup(void)
74{
75 if (uvc_debugfs_root_dir != NULL)
76 debugfs_remove_recursive(uvc_debugfs_root_dir);
77}