Inaky Perez-Gonzalez | df36542 | 2008-09-17 16:34:29 +0100 | [diff] [blame] | 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 | */ |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 25 | #include <linux/slab.h> |
Paul Gortmaker | 6eb0de8 | 2011-07-03 16:09:31 -0400 | [diff] [blame] | 26 | #include <linux/module.h> |
Inaky Perez-Gonzalez | df36542 | 2008-09-17 16:34:29 +0100 | [diff] [blame] | 27 | #include "wusbhc.h" |
| 28 | #include "wa-hc.h" |
| 29 | |
| 30 | /** |
| 31 | * Assumes |
| 32 | * |
| 33 | * wa->usb_dev and wa->usb_iface initialized and refcounted, |
| 34 | * wa->wa_descr initialized. |
| 35 | */ |
| 36 | int wa_create(struct wahc *wa, struct usb_interface *iface) |
| 37 | { |
| 38 | int result; |
| 39 | struct device *dev = &iface->dev; |
| 40 | |
| 41 | result = wa_rpipes_create(wa); |
| 42 | if (result < 0) |
| 43 | goto error_rpipes_create; |
| 44 | /* Fill up Data Transfer EP pointers */ |
| 45 | wa->dti_epd = &iface->cur_altsetting->endpoint[1].desc; |
| 46 | wa->dto_epd = &iface->cur_altsetting->endpoint[2].desc; |
Kuninori Morimoto | 29cc889 | 2011-08-23 03:12:03 -0700 | [diff] [blame] | 47 | wa->xfer_result_size = usb_endpoint_maxp(wa->dti_epd); |
Inaky Perez-Gonzalez | df36542 | 2008-09-17 16:34:29 +0100 | [diff] [blame] | 48 | wa->xfer_result = kmalloc(wa->xfer_result_size, GFP_KERNEL); |
Julia Lawall | fd4d72c | 2012-08-14 08:47:36 +0200 | [diff] [blame] | 49 | if (wa->xfer_result == NULL) { |
| 50 | result = -ENOMEM; |
Inaky Perez-Gonzalez | df36542 | 2008-09-17 16:34:29 +0100 | [diff] [blame] | 51 | goto error_xfer_result_alloc; |
Julia Lawall | fd4d72c | 2012-08-14 08:47:36 +0200 | [diff] [blame] | 52 | } |
Inaky Perez-Gonzalez | df36542 | 2008-09-17 16:34:29 +0100 | [diff] [blame] | 53 | result = wa_nep_create(wa, iface); |
| 54 | if (result < 0) { |
| 55 | dev_err(dev, "WA-CDS: can't initialize notif endpoint: %d\n", |
| 56 | result); |
| 57 | goto error_nep_create; |
| 58 | } |
| 59 | return 0; |
| 60 | |
| 61 | error_nep_create: |
| 62 | kfree(wa->xfer_result); |
| 63 | error_xfer_result_alloc: |
| 64 | wa_rpipes_destroy(wa); |
| 65 | error_rpipes_create: |
| 66 | return result; |
| 67 | } |
| 68 | EXPORT_SYMBOL_GPL(wa_create); |
| 69 | |
| 70 | |
| 71 | void __wa_destroy(struct wahc *wa) |
| 72 | { |
| 73 | if (wa->dti_urb) { |
| 74 | usb_kill_urb(wa->dti_urb); |
| 75 | usb_put_urb(wa->dti_urb); |
| 76 | usb_kill_urb(wa->buf_in_urb); |
| 77 | usb_put_urb(wa->buf_in_urb); |
| 78 | } |
| 79 | kfree(wa->xfer_result); |
| 80 | wa_nep_destroy(wa); |
| 81 | wa_rpipes_destroy(wa); |
| 82 | } |
| 83 | EXPORT_SYMBOL_GPL(__wa_destroy); |
| 84 | |
| 85 | /** |
| 86 | * wa_reset_all - reset the WA device |
| 87 | * @wa: the WA to be reset |
| 88 | * |
| 89 | * For HWAs the radio controller and all other PALs are also reset. |
| 90 | */ |
| 91 | void wa_reset_all(struct wahc *wa) |
| 92 | { |
| 93 | /* FIXME: assuming HWA. */ |
| 94 | wusbhc_reset_all(wa->wusb); |
| 95 | } |
| 96 | |
| 97 | MODULE_AUTHOR("Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>"); |
| 98 | MODULE_DESCRIPTION("Wireless USB Wire Adapter core"); |
| 99 | MODULE_LICENSE("GPL"); |