summaryrefslogtreecommitdiffstats
path: root/drivers/media/video/uvc/uvc_debugfs.c
diff options
context:
space:
mode:
authorAlexey Fisher <bug-track@fisher-privat.net>2011-11-03 09:39:37 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-12-11 11:22:07 -0200
commitedbaa39842793fc4ac6603b277f2ad76f2057a45 (patch)
tree6a7a2213fb36540587a8dc77953efa3dcc6ba812 /drivers/media/video/uvc/uvc_debugfs.c
parentc4d99f89e20c87c8e2a992ce4cf9aa4325dc7fa7 (diff)
downloadblackbird-op-linux-edbaa39842793fc4ac6603b277f2ad76f2057a45.tar.gz
blackbird-op-linux-edbaa39842793fc4ac6603b277f2ad76f2057a45.zip
[media] uvcvideo: Add debugfs support
Create a debugfs entry per UVC stream. This will be used to export stream statistics. Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [mchehab@redhat.com: add incude <linux/module.h> to avoid compilation breakage] Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/uvc/uvc_debugfs.c')
-rw-r--r--drivers/media/video/uvc/uvc_debugfs.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/drivers/media/video/uvc/uvc_debugfs.c b/drivers/media/video/uvc/uvc_debugfs.c
new file mode 100644
index 000000000000..39fd43b3e1d2
--- /dev/null
+++ b/drivers/media/video/uvc/uvc_debugfs.c
@@ -0,0 +1,77 @@
+/*
+ * uvc_debugfs.c -- USB Video Class driver - Debugging support
+ *
+ * Copyright (C) 2011
+ * Laurent Pinchart (laurent.pinchart@ideasonboard.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/debugfs.h>
+#include <linux/slab.h>
+#include <linux/usb.h>
+
+#include "uvcvideo.h"
+
+/* -----------------------------------------------------------------------------
+ * Global and stream initialization/cleanup
+ */
+
+static struct dentry *uvc_debugfs_root_dir;
+
+int uvc_debugfs_init_stream(struct uvc_streaming *stream)
+{
+ struct usb_device *udev = stream->dev->udev;
+ struct dentry *dent;
+ char dir_name[32];
+
+ if (uvc_debugfs_root_dir == NULL)
+ return -ENODEV;
+
+ sprintf(dir_name, "%u-%u", udev->bus->busnum, udev->devnum);
+
+ dent = debugfs_create_dir(dir_name, uvc_debugfs_root_dir);
+ if (IS_ERR_OR_NULL(dent)) {
+ uvc_printk(KERN_INFO, "Unable to create debugfs %s directory.\n",
+ dir_name);
+ return -ENODEV;
+ }
+
+ stream->debugfs_dir = dent;
+
+ return 0;
+}
+
+void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream)
+{
+ if (stream->debugfs_dir == NULL)
+ return;
+
+ debugfs_remove_recursive(stream->debugfs_dir);
+ stream->debugfs_dir = NULL;
+}
+
+int uvc_debugfs_init(void)
+{
+ struct dentry *dir;
+
+ dir = debugfs_create_dir("uvcvideo", usb_debug_root);
+ if (IS_ERR_OR_NULL(dir)) {
+ uvc_printk(KERN_INFO, "Unable to create debugfs directory\n");
+ return -ENODATA;
+ }
+
+ uvc_debugfs_root_dir = dir;
+ return 0;
+}
+
+void uvc_debugfs_cleanup(void)
+{
+ if (uvc_debugfs_root_dir != NULL)
+ debugfs_remove_recursive(uvc_debugfs_root_dir);
+}
OpenPOWER on IntegriCloud