wa-hc.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Wire Adapter Host Controller Driver
  3. * Common items to HWA and DWA based HCDs
  4. *
  5. * Copyright (C) 2005-2006 Intel Corporation
  6. * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License version
  10. * 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  20. * 02110-1301, USA.
  21. *
  22. *
  23. * FIXME: docs
  24. */
  25. #include "wusbhc.h"
  26. #include "wa-hc.h"
  27. /**
  28. * Assumes
  29. *
  30. * wa->usb_dev and wa->usb_iface initialized and refcounted,
  31. * wa->wa_descr initialized.
  32. */
  33. int wa_create(struct wahc *wa, struct usb_interface *iface)
  34. {
  35. int result;
  36. struct device *dev = &iface->dev;
  37. result = wa_rpipes_create(wa);
  38. if (result < 0)
  39. goto error_rpipes_create;
  40. /* Fill up Data Transfer EP pointers */
  41. wa->dti_epd = &iface->cur_altsetting->endpoint[1].desc;
  42. wa->dto_epd = &iface->cur_altsetting->endpoint[2].desc;
  43. wa->xfer_result_size = le16_to_cpu(wa->dti_epd->wMaxPacketSize);
  44. wa->xfer_result = kmalloc(wa->xfer_result_size, GFP_KERNEL);
  45. if (wa->xfer_result == NULL)
  46. goto error_xfer_result_alloc;
  47. result = wa_nep_create(wa, iface);
  48. if (result < 0) {
  49. dev_err(dev, "WA-CDS: can't initialize notif endpoint: %d\n",
  50. result);
  51. goto error_nep_create;
  52. }
  53. return 0;
  54. error_nep_create:
  55. kfree(wa->xfer_result);
  56. error_xfer_result_alloc:
  57. wa_rpipes_destroy(wa);
  58. error_rpipes_create:
  59. return result;
  60. }
  61. EXPORT_SYMBOL_GPL(wa_create);
  62. void __wa_destroy(struct wahc *wa)
  63. {
  64. if (wa->dti_urb) {
  65. usb_kill_urb(wa->dti_urb);
  66. usb_put_urb(wa->dti_urb);
  67. usb_kill_urb(wa->buf_in_urb);
  68. usb_put_urb(wa->buf_in_urb);
  69. }
  70. kfree(wa->xfer_result);
  71. wa_nep_destroy(wa);
  72. wa_rpipes_destroy(wa);
  73. }
  74. EXPORT_SYMBOL_GPL(__wa_destroy);
  75. /**
  76. * wa_reset_all - reset the WA device
  77. * @wa: the WA to be reset
  78. *
  79. * For HWAs the radio controller and all other PALs are also reset.
  80. */
  81. void wa_reset_all(struct wahc *wa)
  82. {
  83. /* FIXME: assuming HWA. */
  84. wusbhc_reset_all(wa->wusb);
  85. }
  86. MODULE_AUTHOR("Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>");
  87. MODULE_DESCRIPTION("Wireless USB Wire Adapter core");
  88. MODULE_LICENSE("GPL");