Linux Audio

Check our new training course

Real-Time Linux with PREEMPT_RT training

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