uvc_debugfs.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  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. #include <linux/module.h>
  14. #include <linux/debugfs.h>
  15. #include <linux/slab.h>
  16. #include <linux/usb.h>
  17. #include "uvcvideo.h"
  18. /* -----------------------------------------------------------------------------
  19. * Global and stream initialization/cleanup
  20. */
  21. static struct dentry *uvc_debugfs_root_dir;
  22. int uvc_debugfs_init_stream(struct uvc_streaming *stream)
  23. {
  24. struct usb_device *udev = stream->dev->udev;
  25. struct dentry *dent;
  26. char dir_name[32];
  27. if (uvc_debugfs_root_dir == NULL)
  28. return -ENODEV;
  29. sprintf(dir_name, "%u-%u", udev->bus->busnum, udev->devnum);
  30. dent = debugfs_create_dir(dir_name, uvc_debugfs_root_dir);
  31. if (IS_ERR_OR_NULL(dent)) {
  32. uvc_printk(KERN_INFO, "Unable to create debugfs %s directory.\n",
  33. dir_name);
  34. return -ENODEV;
  35. }
  36. stream->debugfs_dir = dent;
  37. return 0;
  38. }
  39. void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream)
  40. {
  41. if (stream->debugfs_dir == NULL)
  42. return;
  43. debugfs_remove_recursive(stream->debugfs_dir);
  44. stream->debugfs_dir = NULL;
  45. }
  46. int uvc_debugfs_init(void)
  47. {
  48. struct dentry *dir;
  49. dir = debugfs_create_dir("uvcvideo", usb_debug_root);
  50. if (IS_ERR_OR_NULL(dir)) {
  51. uvc_printk(KERN_INFO, "Unable to create debugfs directory\n");
  52. return -ENODATA;
  53. }
  54. uvc_debugfs_root_dir = dir;
  55. return 0;
  56. }
  57. void uvc_debugfs_cleanup(void)
  58. {
  59. if (uvc_debugfs_root_dir != NULL)
  60. debugfs_remove_recursive(uvc_debugfs_root_dir);
  61. }