objtool: Re-arrange validate_functions()
[linux-block.git] / drivers / staging / wusbcore / wa-hc.c
CommitLineData
5fd54ace 1// SPDX-License-Identifier: GPL-2.0
df365423
IPG
2/*
3 * Wire Adapter Host Controller Driver
4 * Common items to HWA and DWA based HCDs
5 *
6 * Copyright (C) 2005-2006 Intel Corporation
7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8 *
df365423
IPG
9 * FIXME: docs
10 */
5a0e3ad6 11#include <linux/slab.h>
6eb0de82 12#include <linux/module.h>
df365423
IPG
13#include "wusbhc.h"
14#include "wa-hc.h"
15
16/**
17 * Assumes
18 *
19 * wa->usb_dev and wa->usb_iface initialized and refcounted,
20 * wa->wa_descr initialized.
21 */
f07ddb9e
TP
22int wa_create(struct wahc *wa, struct usb_interface *iface,
23 kernel_ulong_t quirks)
df365423
IPG
24{
25 int result;
26 struct device *dev = &iface->dev;
27
03ace948
JH
28 if (iface->cur_altsetting->desc.bNumEndpoints < 3)
29 return -ENODEV;
30
df365423
IPG
31 result = wa_rpipes_create(wa);
32 if (result < 0)
33 goto error_rpipes_create;
f07ddb9e 34 wa->quirks = quirks;
df365423
IPG
35 /* Fill up Data Transfer EP pointers */
36 wa->dti_epd = &iface->cur_altsetting->endpoint[1].desc;
37 wa->dto_epd = &iface->cur_altsetting->endpoint[2].desc;
0367eef2
TP
38 wa->dti_buf_size = usb_endpoint_maxp(wa->dti_epd);
39 wa->dti_buf = kmalloc(wa->dti_buf_size, GFP_KERNEL);
40 if (wa->dti_buf == NULL) {
fd4d72cb 41 result = -ENOMEM;
0367eef2 42 goto error_dti_buf_alloc;
fd4d72cb 43 }
df365423
IPG
44 result = wa_nep_create(wa, iface);
45 if (result < 0) {
46 dev_err(dev, "WA-CDS: can't initialize notif endpoint: %d\n",
47 result);
48 goto error_nep_create;
49 }
50 return 0;
51
52error_nep_create:
0367eef2
TP
53 kfree(wa->dti_buf);
54error_dti_buf_alloc:
df365423
IPG
55 wa_rpipes_destroy(wa);
56error_rpipes_create:
57 return result;
58}
59EXPORT_SYMBOL_GPL(wa_create);
60
61
62void __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);
df365423 67 }
0367eef2 68 kfree(wa->dti_buf);
df365423
IPG
69 wa_nep_destroy(wa);
70 wa_rpipes_destroy(wa);
71}
72EXPORT_SYMBOL_GPL(__wa_destroy);
73
74/**
75 * wa_reset_all - reset the WA device
76 * @wa: the WA to be reset
77 *
78 * For HWAs the radio controller and all other PALs are also reset.
79 */
80void wa_reset_all(struct wahc *wa)
81{
82 /* FIXME: assuming HWA. */
83 wusbhc_reset_all(wa->wusb);
84}
85
86MODULE_AUTHOR("Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>");
87MODULE_DESCRIPTION("Wireless USB Wire Adapter core");
88MODULE_LICENSE("GPL");