wa-hc.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 <linux/slab.h>
  26. #include "wusbhc.h"
  27. #include "wa-hc.h"
  28. /**
  29. * Assumes
  30. *
  31. * wa->usb_dev and wa->usb_iface initialized and refcounted,
  32. * wa->wa_descr initialized.
  33. */
  34. int wa_create(struct wahc *wa, struct usb_interface *iface)
  35. {
  36. int result;
  37. struct device *dev = &iface->dev;
  38. result = wa_rpipes_create(wa);
  39. if (result < 0)
  40. goto error_rpipes_create;
  41. /* Fill up Data Transfer EP pointers */
  42. wa->dti_epd = &iface->cur_altsetting->endpoint[1].desc;
  43. wa->dto_epd = &iface->cur_altsetting->endpoint[2].desc;
  44. wa->xfer_result_size = le16_to_cpu(wa->dti_epd->wMaxPacketSize);
  45. wa->xfer_result = kmalloc(wa->xfer_result_size, GFP_KERNEL);
  46. if (wa->xfer_result == NULL)
  47. goto error_xfer_result_alloc;
  48. result = wa_nep_create(wa, iface);
  49. if (result < 0) {
  50. dev_err(dev, "WA-CDS: can't initialize notif endpoint: %d\n",
  51. result);
  52. goto error_nep_create;
  53. }
  54. return 0;
  55. error_nep_create:
  56. kfree(wa->xfer_result);
  57. error_xfer_result_alloc:
  58. wa_rpipes_destroy(wa);
  59. error_rpipes_create:
  60. return result;
  61. }
  62. EXPORT_SYMBOL_GPL(wa_create);
  63. void __wa_destroy(struct wahc *wa)
  64. {
  65. if (wa->dti_urb) {
  66. usb_kill_urb(wa->dti_urb);
  67. usb_put_urb(wa->dti_urb);
  68. usb_kill_urb(wa->buf_in_urb);
  69. usb_put_urb(wa->buf_in_urb);
  70. }
  71. kfree(wa->xfer_result);
  72. wa_nep_destroy(wa);
  73. wa_rpipes_destroy(wa);
  74. }
  75. EXPORT_SYMBOL_GPL(__wa_destroy);
  76. /**
  77. * wa_reset_all - reset the WA device
  78. * @wa: the WA to be reset
  79. *
  80. * For HWAs the radio controller and all other PALs are also reset.
  81. */
  82. void wa_reset_all(struct wahc *wa)
  83. {
  84. /* FIXME: assuming HWA. */
  85. wusbhc_reset_all(wa->wusb);
  86. }
  87. MODULE_AUTHOR("Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>");
  88. MODULE_DESCRIPTION("Wireless USB Wire Adapter core");
  89. MODULE_LICENSE("GPL");