Skip to content

Commit

Permalink
Staging: USB/IP: add host driver
Browse files Browse the repository at this point in the history
This adds the USB IP client driver

Brian Merrell cleaned up a lot of this code and submitted it for
inclusion.  Greg also did a lot of cleanup.

Signed-off-by: Brian G. Merrell <bgmerrell@novell.com>
Cc: Takahiro Hirofuchi <hirofuchi@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Takahiro Hirofuchi authored and Greg Kroah-Hartman committed Oct 10, 2008
1 parent 04679b3 commit 4d7b5c7
Show file tree
Hide file tree
Showing 7 changed files with 1,878 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/staging/usbip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@ config USB_IP_VHCI_HCD

To compile this driver as a module, choose M here: the
module will be called vhci_hcd.

config USB_IP_HOST
tristate "USB IP host driver"
depends on USB_IP_COMMON
default N
---help---
This enables the USB IP device driver which will run on the
host machine.

To compile this driver as a module, choose M here: the
module will be called usbip.
3 changes: 3 additions & 0 deletions drivers/staging/usbip/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ usbip_common_mod-objs := usbip_common.o usbip_event.o
obj-$(CONFIG_USB_IP_VHCI_HCD) += vhci-hcd.o
vhci-hcd-objs := vhci_sysfs.o vhci_tx.o vhci_rx.o vhci_hcd.o

obj-$(CONFIG_USB_IP_HOST) += usbip.o
usbip-objs := stub_dev.o stub_main.o stub_rx.o stub_tx.o

ifeq ($(CONFIG_USB_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG
endif
95 changes: 95 additions & 0 deletions drivers/staging/usbip/stub.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Copyright (C) 2003-2008 Takahiro Hirofuchi
*
* 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/kernel.h>
#include <linux/list.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/module.h>
#include <linux/net.h>

struct stub_device {
struct usb_interface *interface;
struct list_head list;

struct usbip_device ud;
__u32 devid;

/*
* stub_priv preserves private data of each urb.
* It is allocated as stub_priv_cache and assigned to urb->context.
*
* stub_priv is always linked to any one of 3 lists;
* priv_init: linked to this until the comletion of a urb.
* priv_tx : linked to this after the completion of a urb.
* priv_free: linked to this after the sending of the result.
*
* Any of these list operations should be locked by priv_lock.
*/
spinlock_t priv_lock;
struct list_head priv_init;
struct list_head priv_tx;
struct list_head priv_free;

/* see comments for unlinking in stub_rx.c */
struct list_head unlink_tx;
struct list_head unlink_free;


wait_queue_head_t tx_waitq;
};

/* private data into urb->priv */
struct stub_priv {
unsigned long seqnum;
struct list_head list;
struct stub_device *sdev;
struct urb *urb;

int unlinking;
};

struct stub_unlink {
unsigned long seqnum;
struct list_head list;
__u32 status;
};


extern struct kmem_cache *stub_priv_cache;


/*-------------------------------------------------------------------------*/
/* prototype declarations */

/* stub_tx.c */
void stub_complete(struct urb *);
void stub_tx_loop(struct usbip_task *);

/* stub_dev.c */
extern struct usb_driver stub_driver;

/* stub_rx.c */
void stub_rx_loop(struct usbip_task *);
void stub_enqueue_ret_unlink(struct stub_device *, __u32, __u32);

/* stub_main.c */
int match_busid(char *busid);
void stub_device_cleanup_urbs(struct stub_device *sdev);
Loading

0 comments on commit 4d7b5c7

Please sign in to comment.