usbdiag.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2008-2010, 2012-2014, The Linux Foundation.
  4. * All rights reserved.
  5. */
  6. #ifndef _DRIVERS_USB_DIAG_H_
  7. #define _DRIVERS_USB_DIAG_H_
  8. #include <linux/err.h>
  9. #define DIAG_LEGACY "diag"
  10. #define DIAG_MDM "diag_mdm"
  11. #define DIAG_QSC "diag_qsc"
  12. #define DIAG_MDM2 "diag_mdm2"
  13. #define USB_DIAG_CONNECT 0
  14. #define USB_DIAG_DISCONNECT 1
  15. #define USB_DIAG_WRITE_DONE 2
  16. #define USB_DIAG_READ_DONE 3
  17. struct diag_request {
  18. char *buf;
  19. int length;
  20. int actual;
  21. int status;
  22. void *context;
  23. };
  24. struct usb_diag_ch {
  25. const char *name;
  26. struct list_head list;
  27. void (*notify)(void *priv, unsigned int event,
  28. struct diag_request *d_req);
  29. void *priv;
  30. void *priv_usb;
  31. };
  32. #if IS_ENABLED(CONFIG_USB_F_DIAG)
  33. int usb_diag_request_size(struct usb_diag_ch *ch);
  34. struct usb_diag_ch *usb_diag_open(const char *name, void *priv,
  35. void (*notify)(void *, unsigned int, struct diag_request *));
  36. void usb_diag_close(struct usb_diag_ch *ch);
  37. int usb_diag_alloc_req(struct usb_diag_ch *ch, int n_write, int n_read);
  38. int usb_diag_read(struct usb_diag_ch *ch, struct diag_request *d_req);
  39. int usb_diag_write(struct usb_diag_ch *ch, struct diag_request *d_req);
  40. #else
  41. static inline struct usb_diag_ch *usb_diag_open(const char *name, void *priv,
  42. void (*notify)(void *, unsigned int, struct diag_request *))
  43. {
  44. return ERR_PTR(-ENODEV);
  45. }
  46. static inline void usb_diag_close(struct usb_diag_ch *ch)
  47. {
  48. }
  49. static inline
  50. int usb_diag_alloc_req(struct usb_diag_ch *ch, int n_write, int n_read)
  51. {
  52. return -ENODEV;
  53. }
  54. static inline
  55. int usb_diag_read(struct usb_diag_ch *ch, struct diag_request *d_req)
  56. {
  57. return -ENODEV;
  58. }
  59. static inline
  60. int usb_diag_write(struct usb_diag_ch *ch, struct diag_request *d_req)
  61. {
  62. return -ENODEV;
  63. }
  64. #endif /* CONFIG_USB_F_DIAG */
  65. #endif /* _DRIVERS_USB_DIAG_H_ */