wa-hc.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Wire Adapter Host Controller Driver
  4. * Common items to HWA and DWA based HCDs
  5. *
  6. * Copyright (C) 2005-2006 Intel Corporation
  7. * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
  8. *
  9. * FIXME: docs
  10. */
  11. #include <linux/slab.h>
  12. #include <linux/module.h>
  13. #include "wusbhc.h"
  14. #include "wa-hc.h"
  15. /**
  16. * Assumes
  17. *
  18. * wa->usb_dev and wa->usb_iface initialized and refcounted,
  19. * wa->wa_descr initialized.
  20. */
  21. int wa_create(struct wahc *wa, struct usb_interface *iface,
  22. kernel_ulong_t quirks)
  23. {
  24. int result;
  25. struct device *dev = &iface->dev;
  26. if (iface->cur_altsetting->desc.bNumEndpoints < 3)
  27. return -ENODEV;
  28. result = wa_rpipes_create(wa);
  29. if (result < 0)
  30. goto error_rpipes_create;
  31. wa->quirks = quirks;
  32. /* Fill up Data Transfer EP pointers */
  33. wa->dti_epd = &iface->cur_altsetting->endpoint[1].desc;
  34. wa->dto_epd = &iface->cur_altsetting->endpoint[2].desc;
  35. wa->dti_buf_size = usb_endpoint_maxp(wa->dti_epd);
  36. wa->dti_buf = kmalloc(wa->dti_buf_size, GFP_KERNEL);
  37. if (wa->dti_buf == NULL) {
  38. result = -ENOMEM;
  39. goto error_dti_buf_alloc;
  40. }
  41. result = wa_nep_create(wa, iface);
  42. if (result < 0) {
  43. dev_err(dev, "WA-CDS: can't initialize notif endpoint: %d\n",
  44. result);
  45. goto error_nep_create;
  46. }
  47. return 0;
  48. error_nep_create:
  49. kfree(wa->dti_buf);
  50. error_dti_buf_alloc:
  51. wa_rpipes_destroy(wa);
  52. error_rpipes_create:
  53. return result;
  54. }
  55. EXPORT_SYMBOL_GPL(wa_create);
  56. void __wa_destroy(struct wahc *wa)
  57. {
  58. if (wa->dti_urb) {
  59. usb_kill_urb(wa->dti_urb);
  60. usb_put_urb(wa->dti_urb);
  61. }
  62. kfree(wa->dti_buf);
  63. wa_nep_destroy(wa);
  64. wa_rpipes_destroy(wa);
  65. }
  66. EXPORT_SYMBOL_GPL(__wa_destroy);
  67. /**
  68. * wa_reset_all - reset the WA device
  69. * @wa: the WA to be reset
  70. *
  71. * For HWAs the radio controller and all other PALs are also reset.
  72. */
  73. void wa_reset_all(struct wahc *wa)
  74. {
  75. /* FIXME: assuming HWA. */
  76. wusbhc_reset_all(wa->wusb);
  77. }
  78. MODULE_AUTHOR("Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>");
  79. MODULE_DESCRIPTION("Wireless USB Wire Adapter core");
  80. MODULE_LICENSE("GPL");