usba_ugen.c revision 0a05e7057ae5537db2da83492d375e6524599463
0N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
#include "sys/usb/clients/ugen/usb_ugen.h"
#include "sys/usb/usba/usba_ugen.h"
#include "sys/usb/usba/usba_ugend.h"
int ugen_enable_pm = 0;
static int ugen_cr2lcstat(int);
KM_SLEEP);
int rval;
return (NULL);
0)) != USB_SUCCESS) {
return (NULL);
char *name;
if (limit == 0) {
return (NULL);
if (limit == 0) {
return (NULL);
if (usb_ugen_hdl_impl) {
if (ugenp) {
return (USB_FAILURE);
switch (cmd) {
case DDI_ATTACH:
case DDI_RESUME:
return (USB_SUCCESS);
return (USB_FAILURE);
goto fail;
goto fail;
goto fail;
return (DDI_SUCCESS);
fail:
if (ugenp) {
return (DDI_FAILURE);
if (usb_ugen_hdl) {
switch (cmd) {
case DDI_DETACH:
case DDI_SUSPEND:
return (rval);
USB_WAIT, 0);
return (USB_SUCCESS);
int prev_state;
case USB_DEV_ONLINE:
case USB_DEV_DISCONNECTED:
for (i = 0; i < ugen_busy_loop; i++) {
USB_WAIT, 0);
case USB_DEV_SUSPENDED:
return (rval);
return (USB_FAILURE);
return (USB_SUCCESS);
return (USB_SUCCESS);
USB_FAILURE) {
case USB_DEV_DISCONNECTED:
case USB_DEV_SUSPENDED:
int rval;
int minor_node_type;
return (EINVAL);
return (EINVAL);
return (rval);
USB_WAIT_SIG, 0) <= 0) {
return (EINTR);
case USB_DEV_ONLINE:
case USB_DEV_DISCONNECTED:
goto done;
case USB_DEV_SUSPENDED:
goto done;
switch (minor_node_type) {
case UGEN_MINOR_EP_XFER_NODE:
if (rval == 0) {
case UGEN_MINOR_EP_STAT_NODE:
if (rval == 0) {
case UGEN_MINOR_DEV_STAT_NODE:
done:
return (rval);
int minor_node_type;
return (EINVAL);
return (EINVAL);
USB_WAIT_SIG, 0) <= 0) {
return (EINTR);
switch (minor_node_type) {
case UGEN_MINOR_EP_XFER_NODE:
case UGEN_MINOR_EP_STAT_NODE:
case UGEN_MINOR_DEV_STAT_NODE:
return (EINVAL);
* usb_ugen_read/write()
return (EINVAL);
return (EINVAL);
return (EINVAL);
return (EINVAL);
int minor_node_type;
return (EINVAL);
return (EINVAL);
*reventsp = 0;
switch (minor_node_type) {
case UGEN_MINOR_EP_XFER_NODE:
UGEN_EP_STATE_INTR_IN_POLLING_ON) == 0)) {
} else if (!anyyet) {
UGEN_EP_STATE_ISOC_IN_POLLING_ON) == 0)) {
} else if (!anyyet) {
case UGEN_MINOR_DEV_STAT_NODE:
} else if (!anyyet) {
case UGEN_MINOR_EP_STAT_NODE:
} else if (!anyyet) {
int rval = 0;
return (EINVAL);
switch (minor_node_type) {
case UGEN_MINOR_EP_XFER_NODE:
case UGEN_MINOR_EP_STAT_NODE:
case UGEN_MINOR_DEV_STAT_NODE:
if (rval) {
switch (minor_node_type) {
case UGEN_MINOR_EP_XFER_NODE:
case USB_EP_ATTR_BULK:
case USB_EP_ATTR_INTR:
case USB_EP_ATTR_CONTROL:
case USB_EP_ATTR_ISOCH:
case UGEN_MINOR_EP_STAT_NODE:
case UGEN_MINOR_DEV_STAT_NODE:
int ep;
return (USB_SUCCESS);
return (USB_FAILURE);
int rval = 0;
switch (minor_node_type) {
case UGEN_MINOR_EP_XFER_NODE:
return (ENODEV);
case USB_EP_ATTR_CONTROL:
case USB_EP_ATTR_ISOCH:
case USB_EP_ATTR_BULK:
case USB_EP_ATTR_INTR:
case UGEN_MINOR_DEV_STAT_NODE:
case UGEN_MINOR_EP_STAT_NODE:
return (rval);
* create/initialize all endpoint xfer/stat structures
return (USB_FAILURE);
ep++) {
USB_SUCCESS) {
return (USB_FAILURE);
return (USB_SUCCESS);
int ep_index;
for (i = 0; i < UGEN_N_ENDPOINTS; i++) {
if (epp) {
int minor_index;
UGEN_OWNS_DEVICE : 0);
int ep_index =
int ep_addr =
int ep_type =
int ep_dir =
return (USB_FAILURE);
if (minor_index < 0) {
return (USB_SUCCESS);
return (USB_FAILURE);
if (minor_index < 0) {
return (USB_SUCCESS);
return (USB_FAILURE);
return (USB_SUCCESS);
for (i = 0; i < UGEN_N_ENDPOINTS; i++) {
USB_WAIT, 0);
int cfgidx;
return (cfgidx);
return (USB_SUCCESS);
return (USB_FAILURE);
return (USB_FAILURE);
return (USB_SUCCESS);
int switched = 0;
return (rval);
return (rval);
USB_SUCCESS) {
return (USB_BUSY);
return (rval);
switched++;
return (USB_BUSY);
USB_SUCCESS) {
return (rval);
return (rval);
int ep;
bEndpointAddress) ==
bEndpointAddress)) {
int rval;
return (EBUSY);
USB_SUCCESS) {
max_size =
return (rval);
int len;
int n_pkt;
len);
int rval = 0;
return (EINTR);
case USB_DEV_ONLINE:
case USB_DEV_DISCONNECTED:
case USB_DEV_SUSPENDED:
#ifndef __lock_lint
if (rval) {
return (rval);
case USB_EP_ATTR_CONTROL:
case USB_EP_ATTR_BULK:
case USB_EP_ATTR_INTR:
case USB_EP_ATTR_ISOCH:
int rval;
return (USB_SUCCESS);
return (USB_NO_RESOURCES);
goto fail;
case USB_REQ_SET_CFG:
case USB_REQ_SET_IF:
goto fail;
goto fail;
goto fail;
goto fail;
done:
return (USB_SUCCESS);
fail:
return (rval);
case USB_CR_OK:
case USB_CR_PIPE_RESET:
int rval;
return (USB_NO_RESOURCES);
return (rval);
if (epp) {
if (len) {
case USB_CR_OK:
case USB_CR_PIPE_RESET:
int len = 0;
if (len == 0) {
goto done;
goto done;
done:
if (*wait) {
return (rval);
return (rval);
return (rval);
goto done;
case USB_CR_OK:
case USB_CR_PIPE_RESET:
case USB_CR_STOPPED_POLLING:
done:
return (USB_NO_RESOURCES);
return (rval);
if (epp) {
int len;
case USB_CR_OK:
case USB_CR_PIPE_RESET:
goto done;
return (rval);
return (USB_SUCCESS);
goto done;
if (len == 0) {
goto done;
goto done;
done:
if (mp) {
if (*wait) {
return (rval);
return (rval);
return (USB_NO_RESOURCES);
return (rval);
goto done;
for (i = 0; i < n_pkt; i++) {
case USB_CR_OK:
case USB_CR_PIPE_RESET:
case USB_CR_STOPPED_POLLING:
case USB_CR_PIPE_CLOSING:
done:
goto done;
if ((n_pkt == 0) ||
goto done;
goto done;
goto done;
n_pkt);
goto done;
n_pkt);
goto done;
n_pkt);
goto done;
goto done;
goto done;
sizeof (ugen_isoc_pkt_descr_t) *
goto done;
done:
return (rval);
if (epp) {
int len, i;
int headlen;
sizeof (ugen_isoc_pkt_descr_t);
case USB_CR_OK:
(sizeof (ugen_isoc_pkt_descr_t) *
case USB_CR_PIPE_RESET:
rval = 0;
return (rval);
if (len) {
return (EINVAL);
return (EINVAL);
return (USB_FAILURE);
return (USB_SUCCESS);
return (EBUSY);
UGEN_DEV_STATUS_CHANGED) == 0) {
return (EINTR);
case USB_DEV_ONLINE:
case USB_DEV_DISCONNECTED:
case USB_DEV_SUSPENDED:
int minor_index;
UGEN_OWNS_DEVICE : 0);
return (USB_FAILURE);
if (owns_device) {
if (minor_index < 0) {
return (USB_FAILURE);
return (USB_FAILURE);
return (USB_SUCCESS);
static struct ugen_cr2lcstat_entry {
int cr;
int lcstat;
} ugen_cr2lcstat_table[] = {
sizeof (struct ugen_cr2lcstat_entry))
for (i = 0; i < UGEN_CR2LCSTAT_TABLE_SIZE; i++) {
return (USB_LC_STAT_UNSPECIFIED_ERR);
minor);
static ugen_minor_t
(idx > 0)) {
return (USB_SUCCESS);
return (USB_FAILURE);
uint_t i, j;
for (i = 0; i < UGEN_MINOR_NODE_SIZE; i++) {
for (j = i; j < UGEN_MINOR_NODE_SIZE; j++) {
*shift = i;
int rval;
return (USB_FAILURE);
return (USB_SUCCESS);
USB_WAIT, 0);
* If we are disconnected/suspended, return success. Note that if we
case USB_DEV_ONLINE:
case USB_DEV_DISCONNECTED:
case USB_DEV_SUSPENDED:
"ugen_power: disconnected/suspended "
goto done;
goto done;
switch (level) {
case USB_DEV_OS_PWR_OFF :
case USB_DEV_ONLINE:
case USB_DEV_OS_FULL_PWR :
done:
return (rval);
t = t->list_next;
static ugen_state_t *
return (ugenp);
index++;
return (ugenp);
t = t->list_next;
return (ugenp);
if (e->list_next) {
prev = e;