Release 4.11 drivers/usb/usbip/vhci_hcd.c
/*
* Copyright (C) 2003-2008 Takahiro Hirofuchi
* Copyright (C) 2015-2016 Nobuo Iwata
*
* This 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 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include <linux/init.h>
#include <linux/file.h>
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include "usbip_common.h"
#include "vhci.h"
#define DRIVER_AUTHOR "Takahiro Hirofuchi"
#define DRIVER_DESC "USB/IP 'Virtual' Host Controller (VHCI) Driver"
/*
* TODO
* - update root hub emulation
* - move the emulation code to userland ?
* porting to other operating systems
* minimize kernel code
* - add suspend/resume code
* - clean up everything
*/
/* See usb gadget dummy hcd */
static int vhci_hub_status(struct usb_hcd *hcd, char *buff);
static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
u16 wIndex, char *buff, u16 wLength);
static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
gfp_t mem_flags);
static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status);
static int vhci_start(struct usb_hcd *vhci_hcd);
static void vhci_stop(struct usb_hcd *hcd);
static int vhci_get_frame_number(struct usb_hcd *hcd);
static const char driver_name[] = "vhci_hcd";
static const char driver_desc[] = "USB/IP Virtual Host Controller";
int vhci_num_controllers = VHCI_NR_HCS;
struct platform_device **vhci_pdevs;
static const char * const bit_desc[] = {
"CONNECTION", /*0*/
"ENABLE", /*1*/
"SUSPEND", /*2*/
"OVER_CURRENT", /*3*/
"RESET", /*4*/
"R5", /*5*/
"R6", /*6*/
"R7", /*7*/
"POWER", /*8*/
"LOWSPEED", /*9*/
"HIGHSPEED", /*10*/
"PORT_TEST", /*11*/
"INDICATOR", /*12*/
"R13", /*13*/
"R14", /*14*/
"R15", /*15*/
"C_CONNECTION", /*16*/
"C_ENABLE", /*17*/
"C_SUSPEND", /*18*/
"C_OVER_CURRENT", /*19*/
"C_RESET", /*20*/
"R21", /*21*/
"R22", /*22*/
"R23", /*23*/
"R24", /*24*/
"R25", /*25*/
"R26", /*26*/
"R27", /*27*/
"R28", /*28*/
"R29", /*29*/
"R30", /*30*/
"R31", /*31*/
};
static void dump_port_status_diff(u32 prev_status, u32 new_status)
{
int i = 0;
u32 bit = 1;
pr_debug("status prev -> new: %08x -> %08x\n", prev_status, new_status);
while (bit) {
u32 prev = prev_status & bit;
u32 new = new_status & bit;
char change;
if (!prev && new)
change = '+';
else if (prev && !new)
change = '-';
else
change = ' ';
if (prev || new)
pr_debug(" %c%s\n", change, bit_desc[i]);
bit <<= 1;
i++;
}
pr_debug("\n");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Márton Németh | 76 | 67.86% | 1 | 33.33% |
Takahiro Hirofuchi | 33 | 29.46% | 1 | 33.33% |
Matt Mooney | 3 | 2.68% | 1 | 33.33% |
Total | 112 | 100.00% | 3 | 100.00% |
void rh_port_connect(struct vhci_device *vdev, enum usb_device_speed speed)
{
struct vhci_hcd *vhci = vdev_to_vhci(vdev);
int rhport = vdev->rhport;
u32 status;
unsigned long flags;
usbip_dbg_vhci_rh("rh_port_connect %d\n", rhport);
spin_lock_irqsave(&vhci->lock, flags);
status = vhci->port_status[rhport];
status |= USB_PORT_STAT_CONNECTION | (1 << USB_PORT_FEAT_C_CONNECTION);
switch (speed) {
case USB_SPEED_HIGH:
status |= USB_PORT_STAT_HIGH_SPEED;
break;
case USB_SPEED_LOW:
status |= USB_PORT_STAT_LOW_SPEED;
break;
default:
break;
}
vhci->port_status[rhport] = status;
spin_unlock_irqrestore(&vhci->lock, flags);
usb_hcd_poll_rh_status(vhci_to_hcd(vhci));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 71 | 56.80% | 1 | 25.00% |
Nobuo Iwata | 43 | 34.40% | 1 | 25.00% |
Andrew Goodbody | 10 | 8.00% | 1 | 25.00% |
Brian G. Merrell | 1 | 0.80% | 1 | 25.00% |
Total | 125 | 100.00% | 4 | 100.00% |
static void rh_port_disconnect(struct vhci_device *vdev)
{
struct vhci_hcd *vhci = vdev_to_vhci(vdev);
int rhport = vdev->rhport;
u32 status;
unsigned long flags;
usbip_dbg_vhci_rh("rh_port_disconnect %d\n", rhport);
spin_lock_irqsave(&vhci->lock, flags);
status = vhci->port_status[rhport];
status &= ~USB_PORT_STAT_CONNECTION;
status |= (1 << USB_PORT_FEAT_C_CONNECTION);
vhci->port_status[rhport] = status;
spin_unlock_irqrestore(&vhci->lock, flags);
usb_hcd_poll_rh_status(vhci_to_hcd(vhci));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Nobuo Iwata | 42 | 41.58% | 1 | 16.67% |
Takahiro Hirofuchi | 40 | 39.60% | 1 | 16.67% |
Andrew Goodbody | 10 | 9.90% | 1 | 16.67% |
Max Vozeler | 7 | 6.93% | 1 | 16.67% |
Brian G. Merrell | 1 | 0.99% | 1 | 16.67% |
Bart Westgeest | 1 | 0.99% | 1 | 16.67% |
Total | 101 | 100.00% | 6 | 100.00% |
#define PORT_C_MASK \
((USB_PORT_STAT_C_CONNECTION \
| USB_PORT_STAT_C_ENABLE \
| USB_PORT_STAT_C_SUSPEND \
| USB_PORT_STAT_C_OVERCURRENT \
| USB_PORT_STAT_C_RESET) << 16)
/*
* Returns 0 if the status hasn't changed, or the number of bytes in buf.
* Ports are 0-indexed from the HCD point of view,
* and 1-indexed from the USB core pointer of view.
*
* @buf: a bitmap to show which port status has been changed.
* bit 0: reserved
* bit 1: the status of port 0 has been changed.
* bit 2: the status of port 1 has been changed.
* ...
*/
static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
{
struct vhci_hcd *vhci;
int retval;
int rhport;
int changed = 0;
unsigned long flags;
retval = DIV_ROUND_UP(VHCI_HC_PORTS + 1, 8);
memset(buf, 0, retval);
vhci = hcd_to_vhci(hcd);
spin_lock_irqsave(&vhci->lock, flags);
if (!HCD_HW_ACCESSIBLE(hcd)) {
usbip_dbg_vhci_rh("hw accessible flag not on?\n");
goto done;
}
/* check pseudo status register for each port */
for (rhport = 0; rhport < VHCI_HC_PORTS; rhport++) {
if ((vhci->port_status[rhport] & PORT_C_MASK)) {
/* The status of a port has been changed, */
usbip_dbg_vhci_rh("port %d status changed\n", rhport);
buf[(rhport + 1) / 8] |= 1 << (rhport + 1) % 8;
changed = 1;
}
}
if ((hcd->state == HC_STATE_SUSPENDED) && (changed == 1))
usb_hcd_resume_root_hub(hcd);
done:
spin_unlock_irqrestore(&vhci->lock, flags);
return changed ? retval : 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 137 | 70.62% | 1 | 14.29% |
Bart Westgeest | 34 | 17.53% | 1 | 14.29% |
Andrew Goodbody | 10 | 5.15% | 1 | 14.29% |
Navin Patidar | 8 | 4.12% | 1 | 14.29% |
Brian G. Merrell | 2 | 1.03% | 1 | 14.29% |
Nobuo Iwata | 2 | 1.03% | 1 | 14.29% |
Alan Stern | 1 | 0.52% | 1 | 14.29% |
Total | 194 | 100.00% | 7 | 100.00% |
static inline void hub_descriptor(struct usb_hub_descriptor *desc)
{
memset(desc, 0, sizeof(*desc));
desc->bDescriptorType = USB_DT_HUB;
desc->bDescLength = 9;
desc->wHubCharacteristics = cpu_to_le16(
HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM);
desc->bNbrPorts = VHCI_HC_PORTS;
desc->u.hs.DeviceRemovable[0] = 0xff;
desc->u.hs.DeviceRemovable[1] = 0xff;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 64 | 80.00% | 1 | 14.29% |
John Youn | 8 | 10.00% | 1 | 14.29% |
Sergei Shtylyov | 4 | 5.00% | 2 | 28.57% |
Sarah Sharp | 2 | 2.50% | 1 | 14.29% |
Nobuo Iwata | 1 | 1.25% | 1 | 14.29% |
Vaishali Thakkar | 1 | 1.25% | 1 | 14.29% |
Total | 80 | 100.00% | 7 | 100.00% |
static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
u16 wIndex, char *buf, u16 wLength)
{
struct vhci_hcd *dum;
int retval = 0;
int rhport;
unsigned long flags;
u32 prev_port_status[VHCI_HC_PORTS];
if (!HCD_HW_ACCESSIBLE(hcd))
return -ETIMEDOUT;
/*
* NOTE:
* wIndex shows the port number and begins from 1.
*/
usbip_dbg_vhci_rh("typeReq %x wValue %x wIndex %x\n", typeReq, wValue,
wIndex);
if (wIndex > VHCI_HC_PORTS)
pr_err("invalid port number %d\n", wIndex);
rhport = ((__u8)(wIndex & 0x00ff)) - 1;
dum = hcd_to_vhci(hcd);
spin_lock_irqsave(&dum->lock, flags);
/* store old status and compare now and old later */
if (usbip_dbg_flag_vhci_rh) {
memcpy(prev_port_status, dum->port_status,
sizeof(prev_port_status));
}
switch (typeReq) {
case ClearHubFeature:
usbip_dbg_vhci_rh(" ClearHubFeature\n");
break;
case ClearPortFeature:
switch (wValue) {
case USB_PORT_FEAT_SUSPEND:
if (dum->port_status[rhport] & USB_PORT_STAT_SUSPEND) {
/* 20msec signaling */
dum->resuming = 1;
dum->re_timeout =
jiffies + msecs_to_jiffies(20);
}
break;
case USB_PORT_FEAT_POWER:
usbip_dbg_vhci_rh(
" ClearPortFeature: USB_PORT_FEAT_POWER\n");
dum->port_status[rhport] = 0;
dum->resuming = 0;
break;
case USB_PORT_FEAT_C_RESET:
usbip_dbg_vhci_rh(
" ClearPortFeature: USB_PORT_FEAT_C_RESET\n");
switch (dum->vdev[rhport].speed) {
case USB_SPEED_HIGH:
dum->port_status[rhport] |=
USB_PORT_STAT_HIGH_SPEED;
break;
case USB_SPEED_LOW:
dum->port_status[rhport] |=
USB_PORT_STAT_LOW_SPEED;
break;
default:
break;
}
break;
default:
usbip_dbg_vhci_rh(" ClearPortFeature: default %x\n",
wValue);
dum->port_status[rhport] &= ~(1 << wValue);
break;
}
break;
case GetHubDescriptor:
usbip_dbg_vhci_rh(" GetHubDescriptor\n");
hub_descriptor((struct usb_hub_descriptor *) buf);
break;
case GetHubStatus:
usbip_dbg_vhci_rh(" GetHubStatus\n");
*(__le32 *) buf = cpu_to_le32(0);
break;
case GetPortStatus:
usbip_dbg_vhci_rh(" GetPortStatus port %x\n", wIndex);
if (wIndex > VHCI_HC_PORTS || wIndex < 1) {
pr_err("invalid port number %d\n", wIndex);
retval = -EPIPE;
}
/* we do not care about resume. */
/* whoever resets or resumes must GetPortStatus to
* complete it!!
*/
if (dum->resuming && time_after(jiffies, dum->re_timeout)) {
dum->port_status[rhport] |=
(1 << USB_PORT_FEAT_C_SUSPEND);
dum->port_status[rhport] &=
~(1 << USB_PORT_FEAT_SUSPEND);
dum->resuming = 0;
dum->re_timeout = 0;
}
if ((dum->port_status[rhport] & (1 << USB_PORT_FEAT_RESET)) !=
0 && time_after(jiffies, dum->re_timeout)) {
dum->port_status[rhport] |=
(1 << USB_PORT_FEAT_C_RESET);
dum->port_status[rhport] &=
~(1 << USB_PORT_FEAT_RESET);
dum->re_timeout = 0;
if (dum->vdev[rhport].ud.status ==
VDEV_ST_NOTASSIGNED) {
usbip_dbg_vhci_rh(
" enable rhport %d (status %u)\n",
rhport,
dum->vdev[rhport].ud.status);
dum->port_status[rhport] |=
USB_PORT_STAT_ENABLE;
}
}
((__le16 *) buf)[0] = cpu_to_le16(dum->port_status[rhport]);
((__le16 *) buf)[1] =
cpu_to_le16(dum->port_status[rhport] >> 16);
usbip_dbg_vhci_rh(" GetPortStatus bye %x %x\n", ((u16 *)buf)[0],
((u16 *)buf)[1]);
break;
case SetHubFeature:
usbip_dbg_vhci_rh(" SetHubFeature\n");
retval = -EPIPE;
break;
case SetPortFeature:
switch (wValue) {
case USB_PORT_FEAT_SUSPEND:
usbip_dbg_vhci_rh(
" SetPortFeature: USB_PORT_FEAT_SUSPEND\n");
break;
case USB_PORT_FEAT_RESET:
usbip_dbg_vhci_rh(
" SetPortFeature: USB_PORT_FEAT_RESET\n");
/* if it's already running, disconnect first */
if (dum->port_status[rhport] & USB_PORT_STAT_ENABLE) {
dum->port_status[rhport] &=
~(USB_PORT_STAT_ENABLE |
USB_PORT_STAT_LOW_SPEED |
USB_PORT_STAT_HIGH_SPEED);
/* FIXME test that code path! */
}
/* 50msec reset signaling */
dum->re_timeout = jiffies + msecs_to_jiffies(50);
/* FALLTHROUGH */
default:
usbip_dbg_vhci_rh(" SetPortFeature: default %d\n",
wValue);
dum->port_status[rhport] |= (1 << wValue);
break;
}
break;
default:
pr_err("default: no such request\n");
/* "protocol stall" on error */
retval = -EPIPE;
}
if (usbip_dbg_flag_vhci_rh) {
pr_debug("port %d\n", rhport);
/* Only dump valid port status */
if (rhport >= 0) {
dump_port_status_diff(prev_port_status[rhport],
dum->port_status[rhport]);
}
}
usbip_dbg_vhci_rh(" bye\n");
spin_unlock_irqrestore(&dum->lock, flags);
return retval;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 711 | 90.92% | 1 | 6.67% |
Márton Németh | 20 | 2.56% | 3 | 20.00% |
Brian G. Merrell | 17 | 2.17% | 1 | 6.67% |
Andrew Goodbody | 10 | 1.28% | 1 | 6.67% |
Matt Mooney | 9 | 1.15% | 2 | 13.33% |
Keerthimai Janarthanan | 5 | 0.64% | 1 | 6.67% |
Nobuo Iwata | 3 | 0.38% | 1 | 6.67% |
Bart Westgeest | 2 | 0.26% | 1 | 6.67% |
Teodora Baluta | 2 | 0.26% | 1 | 6.67% |
Alan Stern | 1 | 0.13% | 1 | 6.67% |
Alexey Tulia | 1 | 0.13% | 1 | 6.67% |
Gustavo A. R. Silva | 1 | 0.13% | 1 | 6.67% |
Total | 782 | 100.00% | 15 | 100.00% |
static struct vhci_device *get_vdev(struct usb_device *udev)
{
struct platform_device *pdev;
struct usb_hcd *hcd;
struct vhci_hcd *vhci;
int pdev_nr, rhport;
if (!udev)
return NULL;
for (pdev_nr = 0; pdev_nr < vhci_num_controllers; pdev_nr++) {
pdev = *(vhci_pdevs + pdev_nr);
if (pdev == NULL)
continue;
hcd = platform_get_drvdata(pdev);
if (hcd == NULL)
continue;
vhci = hcd_to_vhci(hcd);
for (rhport = 0; rhport < VHCI_HC_PORTS; rhport++) {
if (vhci->vdev[rhport].udev == udev)
return &vhci->vdev[rhport];
}
}
return NULL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Nobuo Iwata | 85 | 63.91% | 1 | 50.00% |
Takahiro Hirofuchi | 48 | 36.09% | 1 | 50.00% |
Total | 133 | 100.00% | 2 | 100.00% |
static void vhci_tx_urb(struct urb *urb)
{
struct vhci_device *vdev = get_vdev(urb->dev);
struct vhci_priv *priv;
struct vhci_hcd *vhci;
unsigned long flags;
if (!vdev) {
pr_err("could not get virtual device");
return;
}
vhci = vdev_to_vhci(vdev);
priv = kzalloc(sizeof(struct vhci_priv), GFP_ATOMIC);
if (!priv) {
usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC);
return;
}
spin_lock_irqsave(&vdev->priv_lock, flags);
priv->seqnum = atomic_inc_return(&vhci->seqnum);
if (priv->seqnum == 0xffff)
dev_info(&urb->dev->dev, "seqnum max\n");
priv->vdev = vdev;
priv->urb = urb;
urb->hcpriv = (void *) priv;
list_add_tail(&priv->list, &vdev->priv_tx);
wake_up(&vdev->waitq_tx);
spin_unlock_irqrestore(&vdev->priv_lock, flags);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 145 | 79.23% | 1 | 16.67% |
Nobuo Iwata | 13 | 7.10% | 2 | 33.33% |
Andrew Goodbody | 10 | 5.46% | 1 | 16.67% |
Matt Mooney | 9 | 4.92% | 1 | 16.67% |
Joe Perches | 6 | 3.28% | 1 | 16.67% |
Total | 183 | 100.00% | 6 | 100.00% |
static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
gfp_t mem_flags)
{
struct vhci_hcd *vhci = hcd_to_vhci(hcd);
struct device *dev = &urb->dev->dev;
u8 portnum = urb->dev->portnum;
int ret = 0;
struct vhci_device *vdev;
unsigned long flags;
usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n",
hcd, urb, mem_flags);
if (portnum > VHCI_HC_PORTS) {
pr_err("invalid port number %d\n", portnum);
return -ENODEV;
}
vdev = &vhci->vdev[portnum-1];
/* patch to usb_sg_init() is in 2.5.60 */
BUG_ON(!urb->transfer_buffer && urb->transfer_buffer_length);
spin_lock_irqsave(&vhci->lock, flags);
if (urb->status != -EINPROGRESS) {
dev_err(dev, "URB already unlinked!, status %d\n", urb->status);
spin_unlock_irqrestore(&vhci->lock, flags);
return urb->status;
}
/* refuse enqueue for dead connection */
spin_lock(&vdev->ud.lock);
if (vdev->ud.status == VDEV_ST_NULL ||
vdev->ud.status == VDEV_ST_ERROR) {
dev_err(dev, "enqueue for inactive port %d\n", vdev->rhport);
spin_unlock(&vdev->ud.lock);
spin_unlock_irqrestore(&vhci->lock, flags);
return -ENODEV;
}
spin_unlock(&vdev->ud.lock);
ret = usb_hcd_link_urb_to_ep(hcd, urb);
if (ret)
goto no_need_unlink;
/*
* The enumeration process is as follows;
*
* 1. Get_Descriptor request to DevAddrs(0) EndPoint(0)
* to get max packet length of default pipe
*
* 2. Set_Address request to DevAddr(0) EndPoint(0)
*
*/
if (usb_pipedevice(urb->pipe) == 0) {
__u8 type = usb_pipetype(urb->pipe);
struct usb_ctrlrequest *ctrlreq =
(struct usb_ctrlrequest *) urb->setup_packet;
if (type != PIPE_CONTROL || !ctrlreq) {
dev_err(dev, "invalid request to devnum 0\n");
ret = -EINVAL;
goto no_need_xmit;
}
switch (ctrlreq->bRequest) {
case USB_REQ_SET_ADDRESS:
/* set_address may come when a device is reset */
dev_info(dev, "SetAddress Request (%d) to port %d\n",
ctrlreq->wValue, vdev->rhport);
usb_put_dev(vdev->udev);
vdev->udev = usb_get_dev(urb->dev);
spin_lock(&vdev->ud.lock);
vdev->ud.status = VDEV_ST_USED;
spin_unlock(&vdev->ud.lock);
if (urb->status == -EINPROGRESS) {
/* This request is successfully completed. */
/* If not -EINPROGRESS, possibly unlinked. */
urb->status = 0;
}
goto no_need_xmit;
case USB_REQ_GET_DESCRIPTOR:
if (ctrlreq->wValue == cpu_to_le16(USB_DT_DEVICE << 8))
usbip_dbg_vhci_hc(
"Not yet?:Get_Descriptor to device 0 (get max pipe size)\n");
usb_put_dev(vdev->udev);
vdev->udev = usb_get_dev(urb->dev);
goto out;
default:
/* NOT REACHED */
dev_err(dev,
"invalid request to devnum 0 bRequest %u, wValue %u\n",
ctrlreq->bRequest,
ctrlreq->wValue);
ret = -EINVAL;
goto no_need_xmit;
}
}
out:
vhci_tx_urb(urb);
spin_unlock_irqrestore(&vhci->lock, flags);
return 0;
no_need_xmit:
usb_hcd_unlink_urb_from_ep(hcd, urb);
no_need_unlink:
spin_unlock_irqrestore(&vhci->lock, flags);
if (!ret)
usb_hcd_giveback_urb(hcd, urb, urb->status);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 357 | 65.62% | 1 | 9.09% |
Max Vozeler | 94 | 17.28% | 2 | 18.18% |
Nobuo Iwata | 56 | 10.29% | 1 | 9.09% |
Andrew Goodbody | 19 | 3.49% | 1 | 9.09% |
Igor Kotrasinski | 5 | 0.92% | 1 | 9.09% |
Teodora Baluta | 3 | 0.55% | 1 | 9.09% |
Brian G. Merrell | 3 | 0.55% | 1 | 9.09% |
Matt Mooney | 3 | 0.55% | 1 | 9.09% |
Shan Wei | 2 | 0.37% | 1 | 9.09% |
Keerthimai Janarthanan | 2 | 0.37% | 1 | 9.09% |
Total | 544 | 100.00% | 11 | 100.00% |
/*
* vhci_rx gives back the urb after receiving the reply of the urb. If an
* unlink pdu is sent or not, vhci_rx receives a normal return pdu and gives
* back its urb. For the driver unlinking the urb, the content of the urb is
* not important, but the calling to its completion handler is important; the
* completion of unlinking is notified by the completion handler.
*
*
* CLIENT SIDE
*
* - When vhci_hcd receives RET_SUBMIT,
*
* - case 1a). the urb of the pdu is not unlinking.
* - normal case
* => just give back the urb
*
* - case 1b). the urb of the pdu is unlinking.
* - usbip.ko will return a reply of the unlinking request.
* => give back the urb now and go to case 2b).
*
* - When vhci_hcd receives RET_UNLINK,
*
* - case 2a). a submit request is still pending in vhci_hcd.
* - urb was really pending in usbip.ko and urb_unlink_urb() was
* completed there.
* => free a pending submit request
* => notify unlink completeness by giving back the urb
*
* - case 2b). a submit request is *not* pending in vhci_hcd.
* - urb was already given back to the core driver.
* => do not give back the urb
*
*
* SERVER SIDE
*
* - When usbip receives CMD_UNLINK,
*
* - case 3a). the urb of the unlink request is now in submission.
* => do usb_unlink_urb().
* => after the unlink is completed, send RET_UNLINK.
*
* - case 3b). the urb of the unlink request is not in submission.
* - may be already completed or never be received
* => send RET_UNLINK
*
*/
static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
{
struct vhci_hcd *vhci = hcd_to_vhci(hcd);
struct vhci_priv *priv;
struct vhci_device *vdev;
unsigned long flags;
pr_info("dequeue a urb %p\n", urb);
spin_lock_irqsave(&vhci->lock, flags);
priv = urb->hcpriv;
if (!priv) {
/* URB was never linked! or will be soon given back by
* vhci_rx. */
spin_unlock_irqrestore(&vhci->lock, flags);
return -EIDRM;
}
{
int ret = 0;
ret = usb_hcd_check_unlink_urb(hcd, urb, status);
if (ret) {
spin_unlock_irqrestore(&vhci->lock, flags);
return ret;
}
}
/* send unlink request here? */
vdev = priv->vdev;
if (!vdev->ud.tcp_socket) {
/* tcp connection is closed */
spin_lock(&vdev->priv_lock);
pr_info("device %p seems to be disconnected\n", vdev);
list_del(&priv->list);
kfree(priv);
urb->hcpriv = NULL;
spin_unlock(&vdev->priv_lock);
/*
* If tcp connection is alive, we have sent CMD_UNLINK.
* vhci_rx will receive RET_UNLINK and give back the URB.
* Otherwise, we give back it here.
*/
pr_info("gives back urb %p\n", urb);
usb_hcd_unlink_urb_from_ep(hcd, urb);
spin_unlock_irqrestore(&vhci->lock, flags);
usb_hcd_giveback_urb(vhci_to_hcd(vhci), urb, urb->status);
spin_lock_irqsave(&vhci->lock, flags);
} else {
/* tcp connection is alive */
struct vhci_unlink *unlink;
spin_lock(&vdev->priv_lock);
/* setup CMD_UNLINK pdu */
unlink = kzalloc(sizeof(struct vhci_unlink), GFP_ATOMIC);
if (!unlink) {
spin_unlock(&vdev->priv_lock);
spin_unlock_irqrestore(&vhci->lock, flags);
usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC);
return -ENOMEM;
}
unlink->seqnum = atomic_inc_return(&vhci->seqnum);
if (unlink->seqnum == 0xffff)
pr_info("seqnum max\n");
unlink->unlink_seqnum = priv->seqnum;
pr_info("device %p seems to be still connected\n", vdev);
/* send cmd_unlink and try to cancel the pending URB in the
* peer */
list_add_tail(&unlink->list, &vdev->unlink_tx);
wake_up(&vdev->waitq_tx);
spin_unlock(&vdev->priv_lock);
}
spin_unlock_irqrestore(&vhci->lock, flags);
usbip_dbg_vhci_hc("leave\n");
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 293 | 74.55% | 1 | 14.29% |
Brian G. Merrell | 40 | 10.18% | 1 | 14.29% |
Andrew Goodbody | 25 | 6.36% | 1 | 14.29% |
Nobuo Iwata | 19 | 4.83% | 1 | 14.29% |
Matt Mooney | 9 | 2.29% | 1 | 14.29% |
Huawei (Harvey) Yang | 5 | 1.27% | 1 | 14.29% |
Igor Kotrasinski | 2 | 0.51% | 1 | 14.29% |
Total | 393 | 100.00% | 7 | 100.00% |
static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
{
struct vhci_hcd *vhci = vdev_to_vhci(vdev);
struct usb_hcd *hcd = vhci_to_hcd(vhci);
struct vhci_unlink *unlink, *tmp;
unsigned long flags;
spin_lock_irqsave(&vhci->lock, flags);
spin_lock(&vdev->priv_lock);
list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) {
pr_info("unlink cleanup tx %lu\n", unlink->unlink_seqnum);
list_del(&unlink->list);
kfree(unlink);
}
while (!list_empty(&vdev->unlink_rx)) {
struct urb *urb;
unlink = list_first_entry(&vdev->unlink_rx, struct vhci_unlink,
list);
/* give back URB of unanswered unlink request */
pr_info("unlink cleanup rx %lu\n", unlink->unlink_seqnum);
urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum);
if (!urb) {
pr_info("the urb (seqnum %lu) was already given back\n",
unlink->unlink_seqnum);
list_del(&unlink->list);
kfree(unlink);
continue;
}
urb->status = -ENODEV;
usb_hcd_unlink_urb_from_ep(hcd, urb);
list_del(&unlink->list);
spin_unlock(&vdev->priv_lock);
spin_unlock_irqrestore(&vhci->lock, flags);
usb_hcd_giveback_urb(hcd, urb, urb->status);
spin_lock_irqsave(&vhci->lock, flags);
spin_lock(&vdev->priv_lock);
kfree(unlink);
}
spin_unlock(&vdev->priv_lock);
spin_unlock_irqrestore(&vhci->lock, flags);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Max Vozeler | 91 | 33.58% | 1 | 16.67% |
Takahiro Hirofuchi | 73 | 26.94% | 1 | 16.67% |
Bernard Blackham | 62 | 22.88% | 1 | 16.67% |
Nobuo Iwata | 26 | 9.59% | 1 | 16.67% |
Andrew Goodbody | 16 | 5.90% | 1 | 16.67% |
Matt Mooney | 3 | 1.11% | 1 | 16.67% |
Total | 271 | 100.00% | 6 | 100.00% |
/*
* The important thing is that only one context begins cleanup.
* This is why error handling and cleanup become simple.
* We do not want to consider race condition as possible.
*/
static void vhci_shutdown_connection(struct usbip_device *ud)
{
struct vhci_device *vdev = container_of(ud, struct vhci_device, ud);
/* need this? see stub_dev.c */
if (ud->tcp_socket) {
pr_debug("shutdown tcp_socket %p\n", ud->tcp_socket);
kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR);
}
/* kill threads related to this sdev */
if (vdev->ud.tcp_rx) {
kthread_stop_put(vdev->ud.tcp_rx);
vdev->ud.tcp_rx = NULL;
}
if (vdev->ud.tcp_tx) {
kthread_stop_put(vdev->ud.tcp_tx);
vdev->ud.tcp_tx = NULL;
}
pr_info("stop threads\n");
/* active connection is closed */
if (vdev->ud.tcp_socket) {
sockfd_put(vdev->ud.tcp_socket);
vdev->ud.tcp_socket = NULL;
}
pr_info("release socket\n");
vhci_device_unlink_cleanup(vdev);
/*
* rh_port_disconnect() is a trigger of ...
* usb_disable_device():
* disable all the endpoints for a USB device.
* usb_disable_endpoint():
* disable endpoints. pending urbs are unlinked(dequeued).
*
* NOTE: After calling rh_port_disconnect(), the USB device drivers of a
* detached device should release used urbs in a cleanup function (i.e.
* xxx_disconnect()). Therefore, vhci_hcd does not need to release
* pushed urbs and their private data in this function.
*
* NOTE: vhci_dequeue() must be considered carefully. When shutting down
* a connection, vhci_shutdown_connection() expects vhci_dequeue()
* gives back pushed urbs and frees their private data by request of
* the cleanup function of a USB driver. When unlinking a urb with an
* active connection, vhci_dequeue() does not give back the urb which
* is actually given back by vhci_rx after receiving its return pdu.
*
*/
rh_port_disconnect(vdev);
pr_info("disconnect device\n");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 107 | 66.05% | 1 | 11.11% |
Navin Patidar | 20 | 12.35% | 1 | 11.11% |
Max Vozeler | 16 | 9.88% | 1 | 11.11% |
Arnd Bergmann | 10 | 6.17% | 1 | 11.11% |
Matt Mooney | 4 | 2.47% | 1 | 11.11% |
Oleg Nesterov | 2 | 1.23% | 1 | 11.11% |
Justin P. Mattock | 1 | 0.62% | 1 | 11.11% |
Bart Westgeest | 1 | 0.62% | 1 | 11.11% |
Al Viro | 1 | 0.62% | 1 | 11.11% |
Total | 162 | 100.00% | 9 | 100.00% |
static void vhci_device_reset(struct usbip_device *ud)
{
struct vhci_device *vdev = container_of(ud, struct vhci_device, ud);
unsigned long flags;
spin_lock_irqsave(&ud->lock, flags);
vdev->speed = 0;
vdev->devid = 0;
usb_put_dev(vdev->udev);
vdev->udev = NULL;
if (ud->tcp_socket) {
sockfd_put(ud->tcp_socket);
ud->tcp_socket = NULL;
}
ud->status = VDEV_ST_NULL;
spin_unlock_irqrestore(&ud->lock, flags);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 64 | 62.75% | 1 | 20.00% |
Bernard Blackham | 14 | 13.73% | 1 | 20.00% |
Max Vozeler | 13 | 12.75% | 1 | 20.00% |
Andrew Goodbody | 10 | 9.80% | 1 | 20.00% |
Al Viro | 1 | 0.98% | 1 | 20.00% |
Total | 102 | 100.00% | 5 | 100.00% |
static void vhci_device_unusable(struct usbip_device *ud)
{
unsigned long flags;
spin_lock_irqsave(&ud->lock, flags);
ud->status = VDEV_ST_ERROR;
spin_unlock_irqrestore(&ud->lock, flags);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 31 | 75.61% | 1 | 50.00% |
Andrew Goodbody | 10 | 24.39% | 1 | 50.00% |
Total | 41 | 100.00% | 2 | 100.00% |
static void vhci_device_init(struct vhci_device *vdev)
{
memset(vdev, 0, sizeof(struct vhci_device));
vdev->ud.side = USBIP_VHCI;
vdev->ud.status = VDEV_ST_NULL;
spin_lock_init(&vdev->ud.lock);
INIT_LIST_HEAD(&vdev->priv_rx);
INIT_LIST_HEAD(&vdev->priv_tx);
INIT_LIST_HEAD(&vdev->unlink_tx);
INIT_LIST_HEAD(&vdev->unlink_rx);
spin_lock_init(&vdev->priv_lock);
init_waitqueue_head(&vdev->waitq_tx);
vdev->ud.eh_ops.shutdown = vhci_shutdown_connection;
vdev->ud.eh_ops.reset = vhci_device_reset;
vdev->ud.eh_ops.unusable = vhci_device_unusable;
usbip_start_eh(&vdev->ud);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 134 | 98.53% | 1 | 50.00% |
Nobuo Iwata | 2 | 1.47% | 1 | 50.00% |
Total | 136 | 100.00% | 2 | 100.00% |
static int hcd_name_to_id(const char *name)
{
char *c;
long val;
int ret;
c = strchr(name, '.');
if (c == NULL)
return 0;
ret = kstrtol(c+1, 10, &val);
if (ret < 0)
return ret;
return val;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Nobuo Iwata | 65 | 100.00% | 1 | 100.00% |
Total | 65 | 100.00% | 1 | 100.00% |
static int vhci_start(struct usb_hcd *hcd)
{
struct vhci_hcd *vhci = hcd_to_vhci(hcd);
int id, rhport;
int err = 0;
usbip_dbg_vhci_hc("enter vhci_start\n");
/* initialize private data of usb_hcd */
for (rhport = 0; rhport < VHCI_HC_PORTS; rhport++) {
struct vhci_device *vdev = &vhci->vdev[rhport];
vhci_device_init(vdev);
vdev->rhport = rhport;
}
atomic_set(&vhci->seqnum, 0);
spin_lock_init(&vhci->lock);
hcd->power_budget = 0; /* no limit */
hcd->uses_new_polling = 1;
id = hcd_name_to_id(hcd_name(hcd));
if (id < 0) {
pr_err("invalid vhci name %s\n", hcd_name(hcd));
return -EINVAL;
}
/* vhci_hcd is now ready to be controlled through sysfs */
if (id == 0) {
err = vhci_init_attr_group();
if (err) {
pr_err("init attr group\n");
return err;
}
err = sysfs_create_group(&hcd_dev(hcd)->kobj, &vhci_attr_group);
if (err) {
pr_err("create sysfs files\n");
vhci_finish_attr_group();
return err;
}
pr_info("created sysfs %s\n", hcd_name(hcd));
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 133 | 62.44% | 1 | 25.00% |
Nobuo Iwata | 78 | 36.62% | 1 | 25.00% |
Brian G. Merrell | 1 | 0.47% | 1 | 25.00% |
Matt Mooney | 1 | 0.47% | 1 | 25.00% |
Total | 213 | 100.00% | 4 | 100.00% |
static void vhci_stop(struct usb_hcd *hcd)
{
struct vhci_hcd *vhci = hcd_to_vhci(hcd);
int id, rhport;
usbip_dbg_vhci_hc("stop VHCI controller\n");
/* 1. remove the userland interface of vhci_hcd */
id = hcd_name_to_id(hcd_name(hcd));
if (id == 0) {
sysfs_remove_group(&hcd_dev(hcd)->kobj, &vhci_attr_group);
vhci_finish_attr_group();
}
/* 2. shutdown all the ports of vhci_hcd */
for (rhport = 0; rhport < VHCI_HC_PORTS; rhport++) {
struct vhci_device *vdev = &vhci->vdev[rhport];
usbip_event_add(&vdev->ud, VDEV_EVENT_REMOVED);
usbip_stop_eh(&vdev->ud);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 86 | 75.44% | 1 | 33.33% |
Nobuo Iwata | 27 | 23.68% | 1 | 33.33% |
Brian G. Merrell | 1 | 0.88% | 1 | 33.33% |
Total | 114 | 100.00% | 3 | 100.00% |
static int vhci_get_frame_number(struct usb_hcd *hcd)
{
dev_err_ratelimited(&hcd->self.root_hub->dev, "Not yet implemented\n");
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 18 | 64.29% | 1 | 50.00% |
Greg Kroah-Hartman | 10 | 35.71% | 1 | 50.00% |
Total | 28 | 100.00% | 2 | 100.00% |
#ifdef CONFIG_PM
/* FIXME: suspend/resume */
static int vhci_bus_suspend(struct usb_hcd *hcd)
{
struct vhci_hcd *vhci = hcd_to_vhci(hcd);
unsigned long flags;
dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__);
spin_lock_irqsave(&vhci->lock, flags);
hcd->state = HC_STATE_SUSPENDED;
spin_unlock_irqrestore(&vhci->lock, flags);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 60 | 85.71% | 1 | 50.00% |
Andrew Goodbody | 10 | 14.29% | 1 | 50.00% |
Total | 70 | 100.00% | 2 | 100.00% |
static int vhci_bus_resume(struct usb_hcd *hcd)
{
struct vhci_hcd *vhci = hcd_to_vhci(hcd);
int rc = 0;
unsigned long flags;
dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__);
spin_lock_irqsave(&vhci->lock, flags);
if (!HCD_HW_ACCESSIBLE(hcd))
rc = -ESHUTDOWN;
else
hcd->state = HC_STATE_RUNNING;
spin_unlock_irqrestore(&vhci->lock, flags);
return rc;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 78 | 87.64% | 1 | 33.33% |
Andrew Goodbody | 10 | 11.24% | 1 | 33.33% |
Alan Stern | 1 | 1.12% | 1 | 33.33% |
Total | 89 | 100.00% | 3 | 100.00% |
#else
#define vhci_bus_suspend NULL
#define vhci_bus_resume NULL
#endif
static struct hc_driver vhci_hc_driver = {
.description = driver_name,
.product_desc = driver_desc,
.hcd_priv_size = sizeof(struct vhci_hcd),
.flags = HCD_USB2,
.start = vhci_start,
.stop = vhci_stop,
.urb_enqueue = vhci_urb_enqueue,
.urb_dequeue = vhci_urb_dequeue,
.get_frame_number = vhci_get_frame_number,
.hub_status_data = vhci_hub_status,
.hub_control = vhci_hub_control,
.bus_suspend = vhci_bus_suspend,
.bus_resume = vhci_bus_resume,
};
static int vhci_hcd_probe(struct platform_device *pdev)
{
struct usb_hcd *hcd;
int ret;
usbip_dbg_vhci_hc("name %s id %d\n", pdev->name, pdev->id);
/*
* Allocate and initialize hcd.
* Our private data is also allocated automatically.
*/
hcd = usb_create_hcd(&vhci_hc_driver, &pdev->dev, dev_name(&pdev->dev));
if (!hcd) {
pr_err("create hcd failed\n");
return -ENOMEM;
}
hcd->has_tt = 1;
/*
* Finish generic HCD structure initialization and register.
* Call the driver's reset() and start() routines.
*/
ret = usb_add_hcd(hcd, 0, 0);
if (ret != 0) {
pr_err("usb_add_hcd failed %d\n", ret);
usb_put_hcd(hcd);
return ret;
}
usbip_dbg_vhci_hc("bye\n");
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 105 | 88.24% | 1 | 20.00% |
Alan Stern | 6 | 5.04% | 1 | 20.00% |
Kay Sievers | 4 | 3.36% | 1 | 20.00% |
Brian G. Merrell | 2 | 1.68% | 1 | 20.00% |
Matt Mooney | 2 | 1.68% | 1 | 20.00% |
Total | 119 | 100.00% | 5 | 100.00% |
static int vhci_hcd_remove(struct platform_device *pdev)
{
struct usb_hcd *hcd;
hcd = platform_get_drvdata(pdev);
if (!hcd)
return 0;
/*
* Disconnects the root hub,
* then reverses the effects of usb_add_hcd(),
* invoking the HCD's stop() methods.
*/
usb_remove_hcd(hcd);
usb_put_hcd(hcd);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 45 | 100.00% | 1 | 100.00% |
Total | 45 | 100.00% | 1 | 100.00% |
#ifdef CONFIG_PM
/* what should happen for USB/IP under suspend/resume? */
static int vhci_hcd_suspend(struct platform_device *pdev, pm_message_t state)
{
struct usb_hcd *hcd;
struct vhci_hcd *vhci;
int rhport;
int connected = 0;
int ret = 0;
unsigned long flags;
hcd = platform_get_drvdata(pdev);
if (!hcd)
return 0;
vhci = hcd_to_vhci(hcd);
spin_lock_irqsave(&vhci->lock, flags);
for (rhport = 0; rhport < VHCI_HC_PORTS; rhport++)
if (vhci->port_status[rhport] & USB_PORT_STAT_CONNECTION)
connected += 1;
spin_unlock_irqrestore(&vhci->lock, flags);
if (connected > 0) {
dev_info(&pdev->dev,
"We have %d active connection%s. Do not suspend.\n",
connected, (connected == 1 ? "" : "s"));
ret = -EBUSY;
} else {
dev_info(&pdev->dev, "suspend vhci_hcd");
clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
}
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 125 | 72.67% | 1 | 20.00% |
Nobuo Iwata | 24 | 13.95% | 1 | 20.00% |
Matt Mooney | 12 | 6.98% | 1 | 20.00% |
Andrew Goodbody | 10 | 5.81% | 1 | 20.00% |
Keerthimai Janarthanan | 1 | 0.58% | 1 | 20.00% |
Total | 172 | 100.00% | 5 | 100.00% |
static int vhci_hcd_resume(struct platform_device *pdev)
{
struct usb_hcd *hcd;
dev_dbg(&pdev->dev, "%s\n", __func__);
hcd = platform_get_drvdata(pdev);
if (!hcd)
return 0;
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
usb_hcd_poll_rh_status(hcd);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 53 | 86.89% | 1 | 50.00% |
Nobuo Iwata | 8 | 13.11% | 1 | 50.00% |
Total | 61 | 100.00% | 2 | 100.00% |
#else
#define vhci_hcd_suspend NULL
#define vhci_hcd_resume NULL
#endif
static struct platform_driver vhci_driver = {
.probe = vhci_hcd_probe,
.remove = vhci_hcd_remove,
.suspend = vhci_hcd_suspend,
.resume = vhci_hcd_resume,
.driver = {
.name = driver_name,
},
};
static int add_platform_device(int id)
{
struct platform_device *pdev;
int dev_nr;
if (id == 0)
dev_nr = -1;
else
dev_nr = id;
pdev = platform_device_register_simple(driver_name, dev_nr, NULL, 0);
if (IS_ERR(pdev))
return PTR_ERR(pdev);
*(vhci_pdevs + id) = pdev;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Nobuo Iwata | 53 | 74.65% | 1 | 33.33% |
Takahiro Hirofuchi | 11 | 15.49% | 1 | 33.33% |
Wei Yongjun | 7 | 9.86% | 1 | 33.33% |
Total | 71 | 100.00% | 3 | 100.00% |
static void del_platform_devices(void)
{
struct platform_device *pdev;
int i;
for (i = 0; i < vhci_num_controllers; i++) {
pdev = *(vhci_pdevs + i);
if (pdev != NULL)
platform_device_unregister(pdev);
*(vhci_pdevs + i) = NULL;
}
sysfs_remove_link(&platform_bus.kobj, driver_name);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Nobuo Iwata | 69 | 98.57% | 1 | 50.00% |
Takahiro Hirofuchi | 1 | 1.43% | 1 | 50.00% |
Total | 70 | 100.00% | 2 | 100.00% |
static int __init vhci_hcd_init(void)
{
int i, ret;
if (usb_disabled())
return -ENODEV;
if (vhci_num_controllers < 1)
vhci_num_controllers = 1;
vhci_pdevs = kcalloc(vhci_num_controllers, sizeof(void *), GFP_KERNEL);
if (vhci_pdevs == NULL)
return -ENOMEM;
ret = platform_driver_register(&vhci_driver);
if (ret)
goto err_driver_register;
for (i = 0; i < vhci_num_controllers; i++) {
ret = add_platform_device(i);
if (ret)
goto err_platform_device_register;
}
pr_info(DRIVER_DESC " v" USBIP_VERSION "\n");
return ret;
err_platform_device_register:
del_platform_devices();
platform_driver_unregister(&vhci_driver);
err_driver_register:
kfree(vhci_pdevs);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 66 | 49.25% | 1 | 25.00% |
Nobuo Iwata | 62 | 46.27% | 1 | 25.00% |
Matt Mooney | 6 | 4.48% | 2 | 50.00% |
Total | 134 | 100.00% | 4 | 100.00% |
static void __exit vhci_hcd_exit(void)
{
del_platform_devices();
platform_driver_unregister(&vhci_driver);
kfree(vhci_pdevs);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 15 | 65.22% | 1 | 33.33% |
Nobuo Iwata | 7 | 30.43% | 1 | 33.33% |
Matt Mooney | 1 | 4.35% | 1 | 33.33% |
Total | 23 | 100.00% | 3 | 100.00% |
module_init(vhci_hcd_init);
module_exit(vhci_hcd_exit);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");
MODULE_VERSION(USBIP_VERSION);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Takahiro Hirofuchi | 3507 | 68.85% | 1 | 1.89% |
Nobuo Iwata | 694 | 13.62% | 2 | 3.77% |
Max Vozeler | 221 | 4.34% | 5 | 9.43% |
Andrew Goodbody | 160 | 3.14% | 1 | 1.89% |
Matt Mooney | 101 | 1.98% | 8 | 15.09% |
Márton Németh | 96 | 1.88% | 3 | 5.66% |
Bernard Blackham | 79 | 1.55% | 2 | 3.77% |
Brian G. Merrell | 68 | 1.33% | 1 | 1.89% |
Bart Westgeest | 39 | 0.77% | 3 | 5.66% |
Navin Patidar | 28 | 0.55% | 2 | 3.77% |
Arnd Bergmann | 13 | 0.26% | 1 | 1.89% |
Greg Kroah-Hartman | 10 | 0.20% | 1 | 1.89% |
Alan Stern | 9 | 0.18% | 2 | 3.77% |
Keerthimai Janarthanan | 8 | 0.16% | 1 | 1.89% |
John Youn | 8 | 0.16% | 1 | 1.89% |
Igor Kotrasinski | 7 | 0.14% | 2 | 3.77% |
Wei Yongjun | 7 | 0.14% | 1 | 1.89% |
Joe Perches | 6 | 0.12% | 1 | 1.89% |
Teodora Baluta | 5 | 0.10% | 1 | 1.89% |
Huawei (Harvey) Yang | 5 | 0.10% | 1 | 1.89% |
Kay Sievers | 4 | 0.08% | 1 | 1.89% |
Sergei Shtylyov | 4 | 0.08% | 2 | 3.77% |
Shan Wei | 2 | 0.04% | 1 | 1.89% |
Sarah Sharp | 2 | 0.04% | 1 | 1.89% |
Oleg Nesterov | 2 | 0.04% | 1 | 1.89% |
Al Viro | 2 | 0.04% | 1 | 1.89% |
Tejun Heo | 2 | 0.04% | 1 | 1.89% |
Justin P. Mattock | 1 | 0.02% | 1 | 1.89% |
Gustavo A. R. Silva | 1 | 0.02% | 1 | 1.89% |
Robert P. J. Day | 1 | 0.02% | 1 | 1.89% |
Vaishali Thakkar | 1 | 0.02% | 1 | 1.89% |
Alexey Tulia | 1 | 0.02% | 1 | 1.89% |
Total | 5094 | 100.00% | 53 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.