Release 4.7 drivers/staging/vt6656/usbpipe.c
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* File: usbpipe.c
*
* Purpose: Handle USB control endpoint
*
* Author: Warren Hsu
*
* Date: Mar. 29, 2005
*
* Functions:
* vnt_control_out - Write variable length bytes to MEM/BB/MAC/EEPROM
* vnt_control_in - Read variable length bytes from MEM/BB/MAC/EEPROM
* vnt_control_out_u8 - Write one byte to MEM/BB/MAC/EEPROM
* vnt_control_in_u8 - Read one byte from MEM/BB/MAC/EEPROM
*
* Revision History:
* 04-05-2004 Jerry Chen: Initial release
* 11-24-2004 Warren Hsu: Add ControlvWriteByte,ControlvReadByte,ControlvMaskByte
*
*/
#include "int.h"
#include "rxtx.h"
#include "dpc.h"
#include "desc.h"
#include "device.h"
#include "usbpipe.h"
#define USB_CTL_WAIT 500
/* ms */
int vnt_control_out(struct vnt_private *priv, u8 request, u16 value,
u16 index, u16 length, u8 *buffer)
{
int status = 0;
if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags))
return STATUS_FAILURE;
mutex_lock(&priv->usb_lock);
status = usb_control_msg(priv->usb,
usb_sndctrlpipe(priv->usb, 0), request, 0x40, value,
index, buffer, length, USB_CTL_WAIT);
mutex_unlock(&priv->usb_lock);
if (status < (int)length)
return STATUS_FAILURE;
return STATUS_SUCCESS;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
malcolm priestley | malcolm priestley | 58 | 53.21% | 7 | 63.64% |
forest bond | forest bond | 47 | 43.12% | 1 | 9.09% |
andres more | andres more | 3 | 2.75% | 2 | 18.18% |
jim lieb | jim lieb | 1 | 0.92% | 1 | 9.09% |
| Total | 109 | 100.00% | 11 | 100.00% |
void vnt_control_out_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 data)
{
vnt_control_out(priv, MESSAGE_TYPE_WRITE,
reg_off, reg, sizeof(u8), &data);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
malcolm priestley | malcolm priestley | 38 | 100.00% | 1 | 100.00% |
| Total | 38 | 100.00% | 1 | 100.00% |
int vnt_control_in(struct vnt_private *priv, u8 request, u16 value,
u16 index, u16 length, u8 *buffer)
{
int status;
if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags))
return STATUS_FAILURE;
mutex_lock(&priv->usb_lock);
status = usb_control_msg(priv->usb,
usb_rcvctrlpipe(priv->usb, 0), request, 0xc0, value,
index, buffer, length, USB_CTL_WAIT);
mutex_unlock(&priv->usb_lock);
if (status < (int)length)
return STATUS_FAILURE;
return STATUS_SUCCESS;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
malcolm priestley | malcolm priestley | 59 | 55.14% | 7 | 63.64% |
forest bond | forest bond | 44 | 41.12% | 1 | 9.09% |
andres more | andres more | 3 | 2.80% | 2 | 18.18% |
jim lieb | jim lieb | 1 | 0.93% | 1 | 9.09% |
| Total | 107 | 100.00% | 11 | 100.00% |
void vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data)
{
vnt_control_in(priv, MESSAGE_TYPE_READ,
reg_off, reg, sizeof(u8), data);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
malcolm priestley | malcolm priestley | 38 | 100.00% | 1 | 100.00% |
| Total | 38 | 100.00% | 1 | 100.00% |
static void vnt_start_interrupt_urb_complete(struct urb *urb)
{
struct vnt_private *priv = urb->context;
int status = urb->status;
switch (status) {
case 0:
case -ETIMEDOUT:
break;
case -ECONNRESET:
case -ENOENT:
case -ESHUTDOWN:
priv->int_buf.in_use = false;
return;
default:
break;
}
if (status) {
priv->int_buf.in_use = false;
dev_dbg(&priv->usb->dev, "%s status = %d\n", __func__, status);
} else {
vnt_int_process_data(priv);
}
status = usb_submit_urb(priv->interrupt_urb, GFP_ATOMIC);
if (status)
dev_dbg(&priv->usb->dev, "Submit int URB failed %d\n", status);
else
priv->int_buf.in_use = true;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
malcolm priestley | malcolm priestley | 86 | 61.43% | 9 | 52.94% |
forest bond | forest bond | 37 | 26.43% | 1 | 5.88% |
alexander beregalov | alexander beregalov | 4 | 2.86% | 1 | 5.88% |
alison schofield | alison schofield | 4 | 2.86% | 1 | 5.88% |
jim lieb | jim lieb | 3 | 2.14% | 1 | 5.88% |
joe perches | joe perches | 3 | 2.14% | 1 | 5.88% |
andres more | andres more | 3 | 2.14% | 3 | 17.65% |
| Total | 140 | 100.00% | 17 | 100.00% |
int vnt_start_interrupt_urb(struct vnt_private *priv)
{
int status = STATUS_FAILURE;
if (priv->int_buf.in_use)
return STATUS_FAILURE;
priv->int_buf.in_use = true;
usb_fill_int_urb(priv->interrupt_urb,
priv->usb,
usb_rcvintpipe(priv->usb, 1),
priv->int_buf.data_buf,
MAX_INTERRUPT_SIZE,
vnt_start_interrupt_urb_complete,
priv,
priv->int_interval);
status = usb_submit_urb(priv->interrupt_urb, GFP_ATOMIC);
if (status) {
dev_dbg(&priv->usb->dev, "Submit int URB failed %d\n", status);
priv->int_buf.in_use = false;
}
return status;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
malcolm priestley | malcolm priestley | 112 | 100.00% | 1 | 100.00% |
| Total | 112 | 100.00% | 1 | 100.00% |
static void vnt_submit_rx_urb_complete(struct urb *urb)
{
struct vnt_rcb *rcb = urb->context;
struct vnt_private *priv = rcb->priv;
switch (urb->status) {
case 0:
break;
case -ECONNRESET:
case -ENOENT:
case -ESHUTDOWN:
return;
case -ETIMEDOUT:
default:
dev_dbg(&priv->usb->dev, "BULK In failed %d\n", urb->status);
break;
}
if (urb->actual_length) {
if (vnt_rx_data(priv, rcb, urb->actual_length)) {
rcb->skb = dev_alloc_skb(priv->rx_buf_sz);
if (!rcb->skb) {
dev_dbg(&priv->usb->dev,
"Failed to re-alloc rx skb\n");
rcb->in_use = false;
return;
}
} else {
skb_push(rcb->skb, skb_headroom(rcb->skb));
skb_trim(rcb->skb, 0);
}
urb->transfer_buffer = skb_put(rcb->skb,
skb_tailroom(rcb->skb));
}
if (usb_submit_urb(urb, GFP_ATOMIC)) {
dev_dbg(&priv->usb->dev, "Failed to re submit rx skb\n");
rcb->in_use = false;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
malcolm priestley | malcolm priestley | 146 | 69.19% | 14 | 82.35% |
forest bond | forest bond | 60 | 28.44% | 1 | 5.88% |
alexander beregalov | alexander beregalov | 4 | 1.90% | 1 | 5.88% |
andres more | andres more | 1 | 0.47% | 1 | 5.88% |
| Total | 211 | 100.00% | 17 | 100.00% |
int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb)
{
int status = 0;
struct urb *urb = rcb->urb;
if (!rcb->skb) {
dev_dbg(&priv->usb->dev, "rcb->skb is null\n");
return status;
}
usb_fill_bulk_urb(urb,
priv->usb,
usb_rcvbulkpipe(priv->usb, 2),
skb_put(rcb->skb, skb_tailroom(rcb->skb)),
MAX_TOTAL_SIZE_WITH_ALL_HEADERS,
vnt_submit_rx_urb_complete,
rcb);
status = usb_submit_urb(urb, GFP_ATOMIC);
if (status) {
dev_dbg(&priv->usb->dev, "Submit Rx URB failed %d\n", status);
return STATUS_FAILURE;
}
rcb->in_use = true;
return status;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
malcolm priestley | malcolm priestley | 129 | 97.73% | 1 | 33.33% |
alison schofield | alison schofield | 3 | 2.27% | 2 | 66.67% |
| Total | 132 | 100.00% | 3 | 100.00% |
static void vnt_tx_context_complete(struct urb *urb)
{
struct vnt_usb_send_context *context = urb->context;
struct vnt_private *priv = context->priv;
switch (urb->status) {
case 0:
dev_dbg(&priv->usb->dev, "Write %d bytes\n", context->buf_len);
break;
case -ECONNRESET:
case -ENOENT:
case -ESHUTDOWN:
context->in_use = false;
return;
case -ETIMEDOUT:
default:
dev_dbg(&priv->usb->dev, "BULK Out failed %d\n", urb->status);
break;
}
if (context->type == CONTEXT_DATA_PACKET)
ieee80211_wake_queues(priv->hw);
if (urb->status || context->type == CONTEXT_BEACON_PACKET) {
if (context->skb)
ieee80211_free_txskb(priv->hw, context->skb);
context->in_use = false;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
malcolm priestley | malcolm priestley | 117 | 78.00% | 12 | 75.00% |
forest bond | forest bond | 27 | 18.00% | 1 | 6.25% |
alexander beregalov | alexander beregalov | 4 | 2.67% | 1 | 6.25% |
andres more | andres more | 2 | 1.33% | 2 | 12.50% |
| Total | 150 | 100.00% | 16 | 100.00% |
int vnt_tx_context(struct vnt_private *priv,
struct vnt_usb_send_context *context)
{
int status;
struct urb *urb = context->urb;
if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) {
context->in_use = false;
return STATUS_RESOURCES;
}
usb_fill_bulk_urb(urb,
priv->usb,
usb_sndbulkpipe(priv->usb, 3),
context->data,
context->buf_len,
vnt_tx_context_complete,
context);
status = usb_submit_urb(urb, GFP_ATOMIC);
if (status) {
dev_dbg(&priv->usb->dev, "Submit Tx URB failed %d\n", status);
context->in_use = false;
return STATUS_FAILURE;
}
return STATUS_PENDING;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
malcolm priestley | malcolm priestley | 117 | 96.69% | 4 | 80.00% |
alison schofield | alison schofield | 4 | 3.31% | 1 | 20.00% |
| Total | 121 | 100.00% | 5 | 100.00% |
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
malcolm priestley | malcolm priestley | 904 | 76.48% | 48 | 81.36% |
forest bond | forest bond | 234 | 19.80% | 1 | 1.69% |
andres more | andres more | 12 | 1.02% | 4 | 6.78% |
alexander beregalov | alexander beregalov | 12 | 1.02% | 1 | 1.69% |
alison schofield | alison schofield | 11 | 0.93% | 2 | 3.39% |
jim lieb | jim lieb | 5 | 0.42% | 1 | 1.69% |
joe perches | joe perches | 3 | 0.25% | 1 | 1.69% |
othmar pasteka | othmar pasteka | 1 | 0.08% | 1 | 1.69% |
| Total | 1182 | 100.00% | 59 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.