wa-hc.c 2.6 KB

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