cregit-Linux how code gets into the kernel

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

PersonTokensPropCommitsCommitProp
malcolm priestleymalcolm priestley5853.21%763.64%
forest bondforest bond4743.12%19.09%
andres moreandres more32.75%218.18%
jim liebjim lieb10.92%19.09%
Total109100.00%11100.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

PersonTokensPropCommitsCommitProp
malcolm priestleymalcolm priestley38100.00%1100.00%
Total38100.00%1100.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

PersonTokensPropCommitsCommitProp
malcolm priestleymalcolm priestley5955.14%763.64%
forest bondforest bond4441.12%19.09%
andres moreandres more32.80%218.18%
jim liebjim lieb10.93%19.09%
Total107100.00%11100.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

PersonTokensPropCommitsCommitProp
malcolm priestleymalcolm priestley38100.00%1100.00%
Total38100.00%1100.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

PersonTokensPropCommitsCommitProp
malcolm priestleymalcolm priestley8661.43%952.94%
forest bondforest bond3726.43%15.88%
alexander beregalovalexander beregalov42.86%15.88%
alison schofieldalison schofield42.86%15.88%
jim liebjim lieb32.14%15.88%
joe perchesjoe perches32.14%15.88%
andres moreandres more32.14%317.65%
Total140100.00%17100.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

PersonTokensPropCommitsCommitProp
malcolm priestleymalcolm priestley112100.00%1100.00%
Total112100.00%1100.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

PersonTokensPropCommitsCommitProp
malcolm priestleymalcolm priestley14669.19%1482.35%
forest bondforest bond6028.44%15.88%
alexander beregalovalexander beregalov41.90%15.88%
andres moreandres more10.47%15.88%
Total211100.00%17100.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

PersonTokensPropCommitsCommitProp
malcolm priestleymalcolm priestley12997.73%133.33%
alison schofieldalison schofield32.27%266.67%
Total132100.00%3100.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

PersonTokensPropCommitsCommitProp
malcolm priestleymalcolm priestley11778.00%1275.00%
forest bondforest bond2718.00%16.25%
alexander beregalovalexander beregalov42.67%16.25%
andres moreandres more21.33%212.50%
Total150100.00%16100.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

PersonTokensPropCommitsCommitProp
malcolm priestleymalcolm priestley11796.69%480.00%
alison schofieldalison schofield43.31%120.00%
Total121100.00%5100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
malcolm priestleymalcolm priestley90476.48%4881.36%
forest bondforest bond23419.80%11.69%
andres moreandres more121.02%46.78%
alexander beregalovalexander beregalov121.02%11.69%
alison schofieldalison schofield110.93%23.39%
jim liebjim lieb50.42%11.69%
joe perchesjoe perches30.25%11.69%
othmar pastekaothmar pasteka10.08%11.69%
Total1182100.00%59100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}